netmap.grn.inferrence.inferrence_h5py

netmap.grn.inferrence.inferrence_h5py(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 and back it with an HDF5 file instead of Parquet.

Functionally equivalent to inferrence(), but attribution data is written into a single HDF5 dataset (key 'data', shape (cells, genes^2), chunked by (cells, genes)) rather than per-gene Parquet shards.

Parameters:
  • models (list) – List of trained PyTorch autoencoder models. The forward_mu_only flag is set to True on each model internally before wrapping it in a Captum explainer.

  • data_train_full_tensor (torch.Tensor) – Expression data 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'.

  • backing_file (str or None) – Path to the HDF5 output file. If not None, the file is created (overwriting any existing file) and attribution data is streamed into it column-block by column-block. The path is stored in grn_adata.uns['backing_file'] so that return_grn_adata_to_memory() can reload it. If None, all attributions are accumulated in memory.

  • return_in_memory (bool) – Only relevant when backing_file is not None. If True, the HDF5 dataset is read back into memory and grn_adata.X is fully populated before returning. Default False.

Returns:

GRN object with shape (cells, genes^2).

obs corresponds to cells; var contains directed edge metadata with columns source, target, edge_sums, and edge_means. When backed by HDF5 and return_in_memory=False, X is a zero-shape placeholder.

Return type:

anndata.AnnData