netmap.grn.inferrence.inferrence

netmap.grn.inferrence.inferrence(models, data_train_full_tensor, gene_names, xai_method='GradientShap', background_type='zeros', backing_file='grn_adata.h5', return_in_memory=False)[source]

Compute the full GRN for all target genes using an autoencoder ensemble.

For each gene acting as an attribution target, attribution scores are computed across all models in the ensemble, aggregated by mean, and either written as a Parquet shard or collected in memory. The resulting AnnData object has cells as observations and directed edges (SourceGene_TargetGene) as variables.

When backing_file is not None, one Parquet file per target gene is written to <dirname(backing_file)>/grn/<gene>.parquet and grn_adata.X is a zero-shape placeholder. Use retrieve_top_edges() from netmap.utils.data_utils to load attribution values on demand.

Parameters:
  • models (list) – List of trained autoencoder model instances.

  • data_train_full_tensor (torch.Tensor) – Input expression data on CUDA.

  • gene_names (numpy.ndarray) – Gene name array; order must match tensor columns.

  • xai_method (str) – XAI method — 'GradientShap' (default), 'GuidedBackprop', or 'Deconvolution'.

  • background_type (str) – Background for SHAP-like attributions. Defaults to 'zeros'.

  • backing_file (str or None) – Path prefix for output. Parquet shards are written to <dirname(backing_file)>/grn/<gene>.parquet. Set to None to keep the full matrix in memory (high RAM usage).

  • return_in_memory (bool) – If backing_file is set and this is True, load the HDF5 file back into memory before returning. Defaults to False.

Returns:

GRN object with cells as obs and edges as var; X is

an empty placeholder when backed by Parquet.

Return type:

anndata.AnnData