troutpy.tl.gene_specific_interactions

troutpy.tl.gene_specific_interactions#

troutpy.tl.gene_specific_interactions(sdata, copy=False, gene_key='gene')#

Aggregate per-transcript interaction scores into gene-level mean interaction matrices.

Groups the 3-D interaction_strength array stored in sdata["source_score"].uns by gene (using gene_key from source_score.obs) and computes the mean matrix per gene, yielding a (n_genes, n_source_types, n_target_types) array.

Parameters:
  • sdata (spatialdata.SpatialData) – SpatialData object containing a pre-computed "source_score" table with uns["interaction_strength"] (produced by communication_strength()).

  • copy (bool, optional) – If True, return the updated SpatialData object; otherwise modify in place and return None. Defaults to False.

  • gene_key (str, optional) – Column in sdata["source_score"].obs containing gene identifiers. Defaults to "gene".

Returns:

spatialdata.SpatialData or None Updated SpatialData with sdata["source_score"].uns["gene_interaction_strength"] (shape (n_genes, n_source_types, n_target_types)) and sdata["source_score"].uns["gene_interaction_names"] (gene name array) if copy=True; otherwise None.