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_strengtharray stored insdata["source_score"].unsby gene (usinggene_keyfromsource_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 withuns["interaction_strength"](produced bycommunication_strength()).copy (bool, optional) – If
True, return the updated SpatialData object; otherwise modify in place and returnNone. Defaults toFalse.gene_key (str, optional) – Column in
sdata["source_score"].obscontaining 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)) andsdata["source_score"].uns["gene_interaction_names"](gene name array) ifcopy=True; otherwiseNone.