troutpy.tl.communication_strength

troutpy.tl.communication_strength#

troutpy.tl.communication_strength(sdata, source_layer='source_score', target_layer='target_score', copy=False)#

Compute a 3D interaction strength matrix by multiplying per-transcript source and target scores.

For each extracellular transcript, the outer product of its source-cell-type probability vector and its target-cell-type probability vector is computed. The resulting matrix of shape (n_transcripts, n_source_types, n_target_types) is stored in sdata["source_score"].uns["interaction_strength"].

Parameters:
  • sdata (spatialdata.SpatialData) – SpatialData object containing pre-computed source_score and target_score tables in sdata.tables.

  • source_layer (str, optional) – Key for the source-score AnnData in sdata.tables. Defaults to "source_score".

  • target_layer (str, optional) – Key for the target-score AnnData in sdata.tables. Defaults to "target_score".

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

Returns:

spatialdata.SpatialData or None Updated SpatialData with interaction_strength stored in sdata["source_score"].uns if copy=True; otherwise None.