scmagnify.MAGNI#
- class scmagnify.MAGNI(data, modal='RNA', layer=None, time_key='palantir_pseudotime', gene_selected=None, basal_grn=None, use_rep='X_pca', func=<class 'scmagnify.models._modules.MSNGC'>, hidden=[50], lag=5, max_iter=1000, batch_size=32, lr=0.001, weight_decay=0.0, lmbd=3, gamma=0.02, alpha=0.5, seed=42, early_stopping=True, patience=20, device='cuda')#
Class implementing Multi-Scale Gene Regulation Inference (MAGNI).
This model integrates single-cell multi-omic data and pseudotemporal information through a nonlinear Granger causality model to infer multi-scale GRNs.
- See :doc:`` on how to
compute the
- Parameters:
data (
AnnData|MuData) – Single cell data object. Can be ananndata.AnnData,mudata.MuData,scmagnify.GRNMuDatamodal (
str(default:'RNA')) – Modality key (e.g., ‘RNA’, ‘ATAC’) when using multi-modal data.mudata.MuDataorscmagnify.GRNMuDatamust be provided.layer (
Optional[str] (default:None)) – Layer inlayers. IfNone, defaults toX.time_key (
str(default:'palantir_pseudotime')) – Key inobsthat stores pseudotime values.func (nn.Module, optional) – Neural network model to use, by default MSNGC.
chrom_constraint – Prior network matrix, by default None.
hidden (
list[int] (default:[50])) – Number of hidden units per layer, by default [50].lag (
int(default:5)) – Number of time lags, by default 5.max_iter (
int(default:1000)) – Maximum number of iterations, by default 1000.batch_size (
int(default:32)) – Batch size for training, by default 32.lr (
float(default:0.001)) – Learning rate, by default 1e-3.weight_decay (
float(default:0.0)) – Weight decay for optimizer, by default 0.0.lmbd (
float(default:3)) – Regularization parameter, by default 3.gamma (
float(default:0.02)) – Smoothness penalty parameter, by default 0.02.alpha (
float(default:0.5)) – Sparsity-inducing penalty parameter, by default 0.5.patience (
int(default:20)) – Patience for early stopping, by default 20.seed (
int(default:42)) – Random seed for reproducibility.device (
str(default:'cuda')) – Device to run the computation on. Can be a string like ‘cpu’, ‘cuda’, ‘cuda:0’, or an integer specifying the CUDA device index (e.g., 0). If a CUDA device is requested but is not available, it will automatically fall back to ‘cpu’.basal_grn (NDArray | None)
use_rep (str)
early_stopping (bool)
Methods table#
|
Estimate optimal lags. |
|
Load a trained model's state dictionary from a file. |
|
Estimate causal structure. |
|
Save the trained model's state dictionary. |
|
Train the model. |
Methods#
- MAGNI.estimate_lags(multiscale_network)#
Estimate optimal lags.
- MAGNI.load(filename)#
Load a trained model’s state dictionary from a file.
You must initialize the MAGNI class with the same parameters as the saved model before calling this method.
- Parameters:
filename (
str) – Path to the file where the model state is saved.
- MAGNI.regulation_inference(cv_thres=0.2, filter=['quantile', 0.9, True], acts_method='mlm', save_atten=True)#
Estimate causal structure.
- Parameters:
- Return type:
- Returns:
GRNMuData Gene regulatory network object.