troutpy.tl.extracellular_enrichment

troutpy.tl.extracellular_enrichment#

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

Computes the proportion of transcripts classified as extracellular or intracellular for each gene and calculates additional metrics, including log fold change of extracellular to intracellular proportions. The results are integrated into the sdata object under the ‘xrna_metadata’ layer.

Parameters:
  • sdata (SpatialData) – An spatialData object containing spatial transcriptomics data. The points attribute should include a ‘transcripts’ DataFrame with columns for gene IDs (specified by gene_key) and a boolean ‘extracellular’ column indicating whether each transcript is classified as extracellular.

  • gene_key (str (default: 'gene')) – The name of the column in the ‘transcripts’ DataFrame containing gene identifiers. Defaults to ‘gene’.

  • copy (bool (default: False)) – Whether to return a modified copy of the input sdata object. If False, the input object is modified in place. Defaults to False.

Returns:

If copy=True, returns a modified copy of the input sdata object with updated metadata. Otherwise, modifies sdata in place and returns None.

Notes

  • The function assumes that the sdata object has a ‘points’ layer containing a ‘transcripts’ DataFrame.

  • If the ‘xrna_metadata’ attribute does not exist in sdata, it will be created using the create_urna_metadata function.