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_onlyflag is set toTrueon 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 ingrn_adata.uns['backing_file']so thatreturn_grn_adata_to_memory()can reload it. IfNone, all attributions are accumulated in memory.return_in_memory (bool) – Only relevant when
backing_fileis notNone. IfTrue, the HDF5 dataset is read back into memory andgrn_adata.Xis fully populated before returning. DefaultFalse.
- Returns:
- GRN object with shape
(cells, genes^2). obscorresponds to cells;varcontains directed edge metadata with columnssource,target,edge_sums, andedge_means. When backed by HDF5 andreturn_in_memory=False,Xis a zero-shape placeholder.
- GRN object with shape
- Return type: