netmap.grn.inferrence.inferrence_model_wise_level¶
- netmap.grn.inferrence.inferrence_model_wise_level(models, data_train_full_tensor, gene_names, xai_method='GradientShap', n_models=[10, 25, 50], background_type='zeros')[source]¶
Compute the GRN model-wise and save intermediate aggregates as layers.
Processes one complete model at a time (same order as
inferrence_model_wise()), but additionally saves a snapshot of the mean attribution matrix at each model-count checkpoint listed inn_models. Snapshots after the first checkpoint are stored as named layers in the returned AnnData object so that downstream analysis can compare GRN stability across ensemble sizes.- Parameters:
models (list) – List of trained PyTorch autoencoder models. The
forward_mu_onlyflag is set toTrueon each model internally.data_train_full_tensor (torch.Tensor) – Expression tensor of shape
(cells, genes)on CUDA.gene_names (array-like) – Ordered gene names corresponding to columns of
data_train_full_tensor.xai_method (str) – Captum XAI method to use. One of
'GradientShap'(default),'GuidedBackprop','Deconvolution'.n_models (list of int) – Checkpoints (1-based model counts) at which the current running mean attribution matrix is saved as a layer. For example,
[10, 25, 50]saves snapshots after models 10, 25, and 50 have been processed. The first checkpoint becomesgrn_adata.X; subsequent checkpoints are stored asgrn_adata.layers['aggregated_<n>']. Default[10, 25, 50].background_type (str) – Baseline strategy for SHAP-style attribution. One of
'zeros'(default),'randomize','data'.
- Returns:
GRN object with shape
(cells, genes^2)whereXholds the mean attributions at the first checkpoint and each additional checkpoint is stored as a named layer. ReturnsNoneif no checkpoint inn_modelswas reached (e.g. fewer models were provided than the smallest value inn_models).- Return type:
anndata.AnnData or None