netmap.grn.inferrence.inferrence_model_wise

netmap.grn.inferrence.inferrence_model_wise(models, data_train_full_tensor, gene_names, xai_method='GradientShap', background_type='zeros')[source]

Compute the full GRN by processing one complete model at a time.

Unlike inferrence(), which iterates over target genes across all models, this function processes each model in full (all target genes) and accumulates a running sum of attribution matrices. The final matrix is normalised implicitly by the last model added. This approach may reduce peak memory when the number of genes is small relative to the number of models.

Parameters:
  • models (list) – List of trained PyTorch autoencoder models. The forward_mu_only flag is set to True on 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'.

  • background_type (str) – Baseline strategy for SHAP-style attribution. One of 'zeros' (default), 'randomize', 'data'.

Returns:

In-memory GRN object with shape (cells, genes^2). var contains directed edge metadata with columns source and target.

Return type:

anndata.AnnData