bioneuralnet.network.pysmccnet.wrappers

Functions

get_can_weights_multi(X[, Trait, Lambda, ...])

PyTorch version of get_can_weights_multi wrapper.

get_robust_weights_multi(X, Trait, Lambda[, ...])

PyTorch version of get_robust_weights_multi with subsampling loop.

get_robust_weights_multi_binary(X, Y[, ...])

PyTorch version of get_robust_weights_multi_binary using hybrid GPU/CPU execution.

get_robust_weights_single_binary(X1, Trait, ...)

Compute aggregated sparse PLS-DA canonical weights for single omics data with binary phenotype.

my_multi_cca(xlist[, penalty, ws, niter, ...])

PyTorch version of my_multi_cca performing sparse multiple canonical correlation analysis (SmCCA) on GPU.

r_scale(x)

Numpy scaling using sample standard deviation.

r_scale_torch(x)

Pytorch scaling using sample standard deviation.

Classes

tqdm(*_, **__)

Decorate an iterable object, returning an iterator which acts exactly like the original iterable, but prints a dynamically updating progressbar every time a value is requested.

bioneuralnet.network.pysmccnet.wrappers.get_can_weights_multi(X: List[torch.Tensor], Trait: torch.Tensor | None = None, Lambda: List[float] | ndarray | None = None, cc_coef: List[float] | ndarray | torch.Tensor | None = None, no_trait: bool = True, trace: bool = False, trait_weight: bool = False) List[torch.Tensor][source]

PyTorch version of get_can_weights_multi wrapper.

Parameters:
  • X (List[torch.Tensor]) – List of input data matrices on target device.

  • Trait (torch.Tensor | None) – Optional trait data tensor.

  • Lambda (List[float] | np.ndarray | None) – Penalty parameters; required.

  • cc_coef (List | np.ndarray | torch.Tensor | None) – Pairwise correlation coefficients.

  • no_trait (bool) – If True, run unsupervised CCA; if False, include trait.

  • trace (bool) – If True, print trace info during optimization.

  • trait_weight (bool) – If True, return trait weights in output list.

Returns:

List of weight tensors for each input matrix.

Return type:

List[torch.Tensor]

bioneuralnet.network.pysmccnet.wrappers.get_robust_weights_multi(X: List[torch.Tensor], Trait: torch.Tensor | None, Lambda: List[float] | ndarray, s: List[float] | ndarray | None = None, no_trait: bool = False, subsampling_num: int = 1000, cc_coef: ndarray | None = None, trace: bool = False, trait_weight: bool = False) torch.Tensor[source]

PyTorch version of get_robust_weights_multi with subsampling loop.

Parameters:
  • X (List[torch.Tensor]) – List of input data matrices on target device.

  • Trait (torch.Tensor | None) – Trait data tensor or None.

  • Lambda (List[float] | np.ndarray) – Penalty parameters for CCA/PLS.

  • s (List[float] | np.ndarray | None) – Subsampling proportions for each omics layer.

  • no_trait (bool) – If True, compute weights without using Trait information (unsupervised).

  • subsampling_num (int) – Number of subsampling iterations to perform.

  • cc_coef (np.ndarray | None) – Scaling coefficients for between-omics relationships.

  • trace (bool) – If True, print trace information during execution.

  • trait_weight (bool) – If True, include trait weights in the output.

Returns:

Matrix of weights with shape (total_features, subsampling_num) on the same device as X.

Return type:

torch.Tensor

bioneuralnet.network.pysmccnet.wrappers.get_robust_weights_multi_binary(X: List[torch.Tensor], Y: ndarray | torch.Tensor, between_discriminate_ratio: List[float] | ndarray | None = None, subsampling_percent: List[float] | ndarray | None = None, cc_coef: ndarray | None = None, lambda_between: List[float] | ndarray | None = None, lambda_pheno: float | None = None, subsampling_num: int = 1000, ncomp_pls: int = 3, eval_classifier: bool = False, test_data: List[ndarray | torch.Tensor] | None = None) ndarray | Dict[str, ndarray][source]

PyTorch version of get_robust_weights_multi_binary using hybrid GPU/CPU execution.

Parameters:
  • X (List[torch.Tensor]) – List of omics data matrices (torch tensors on target device).

  • Y (np.ndarray | torch.Tensor) – Binary phenotype vector.

  • between_discriminate_ratio (List[float] | np.ndarray | None) – Ratio for weighting between-omics vs omics-phenotype contributions.

  • subsampling_percent (List[float] | np.ndarray | None) – Proportion of features to subsample per iteration.

  • cc_coef (np.ndarray | None) – Pairwise correlation coefficients.

  • lambda_between (List[float] | np.ndarray | None) – Penalty terms for between-omics CCA.

  • lambda_pheno (float | None) – Penalty term for omics-phenotype PLS.

  • subsampling_num (int) – Number of subsampling iterations.

  • ncomp_pls (int) – Number of latent components for PLS.

  • eval_classifier (bool) – If True, return projections for classifier evaluation instead of weights.

  • test_data (List[np.ndarray | torch.Tensor] | None) – Test data matrices required if eval_classifier is True.

Returns:

Weight matrix (if eval_classifier=False) or dictionary containing train/test projections.

Return type:

np.ndarray | Dict

bioneuralnet.network.pysmccnet.wrappers.get_robust_weights_single_binary(X1: ndarray, Trait: ndarray, Lambda1: float, s1: float = 0.7, subsampling_num: int = 1000, K: int = 3) ndarray[source]

Compute aggregated sparse PLS-DA canonical weights for single omics data with binary phenotype.

Parameters:
  • X1 (np.ndarray) – Input data matrix of shape (n, p1).

  • Trait (np.ndarray) – Binary phenotype vector (0/1) of shape (n,).

  • Lambda1 (float) – LASSO penalty parameter for SPLSDA; between 0 and 1.

  • s1 (float) – Proportion of features to subsample per iteration.

  • subsampling_num (int) – Number of subsampling iterations.

  • K (int) – Number of latent components for PLS-DA.

Returns:

Weight matrix of shape (p1, subsampling_num).

Return type:

np.ndarray