troutpy.tl.extracellular_enrichment

troutpy.tl.extracellular_enrichment#

troutpy.tl.extracellular_enrichment(sdata, gene_key='gene', copy=False, layer='transcripts')#

Compute the proportion of extracellular vs. intracellular transcripts per gene.

For each gene, calculates the proportion of transcripts classified as extracellular and intracellular, the fold ratio between the two, and its log fold change. Results are stored as new columns in sdata["xrna_metadata"].var.

Parameters:
  • sdata (SpatialData) – SpatialData object. sdata.points[layer] must contain a gene identifier column (gene_key) and a boolean extracellular column.

  • gene_key (str (default: 'gene')) – Column in sdata.points[layer] containing gene identifiers.

  • copy (bool (default: False)) – If True, return a modified copy of sdata. Otherwise modify in place.

  • layer (str (default: 'transcripts')) – Key of the points element in sdata containing the transcripts.

Return type:

SpatialData | None

Returns:

If copy=True, a modified copy of sdata. Otherwise None, modifying sdata in place.

Notes

If sdata["xrna_metadata"] does not exist, it is created via create_urna_metadata().