netmap.grn.inferrence.attribution_one_model

netmap.grn.inferrence.attribution_one_model(lrp_model, input_data, xai_type='lrp-like', background_type='randomize')[source]

Compute attributions for all target genes using a single model.

Iterates over every gene index as an attribution target and calls lrp_model.attribute() with the appropriate signature, then horizontally stacks the per-target arrays into one complete attribution matrix for the model.

Parameters:
  • lrp_model – A single Captum explainer instance (e.g. GradientShap or GuidedBackprop) wrapping one trained autoencoder.

  • input_data (torch.Tensor) – Expression tensor of shape (cells, genes) on CUDA.

  • xai_type (str) – Explainer mode. One of 'lrp-like' (no baseline needed) or 'shap-like' (baseline required). Default 'lrp-like'.

  • background_type (str) –

    Strategy for constructing the baseline tensor used by SHAP-style methods. One of:

    • 'randomize': input_data with each column independently shuffled (default).

    • 'zeros': a single all-zero row on CUDA.

    • 'data': use input_data itself as the baseline.

    Any unrecognised value falls back to 'zeros'.

Returns:

Attribution matrix of shape (cells, genes^2) where columns are ordered by target gene (outer) then source gene (inner), matching the edge ordering used in grn_adata.var.

Return type:

np.ndarray