troutpy.tl.compare_intra_extra_distribution

troutpy.tl.compare_intra_extra_distribution#

troutpy.tl.compare_intra_extra_distribution(sdata, layer='transcripts', gene_key='gene', copy=False, coord_keys=None, n_bins=30)#

Compare the spatial distribution of intracellular and extracellular transcripts for each gene.

Parameters:
  • sdata (spatialdata.SpatialData) – SpatialData object containing transcript locations and metadata.

  • layer (str) – Layer within sdata.points where transcripts are stored (default: “transcripts”).

  • gene_key (str) – Column name where the gene name is stored (default: “gene”).

  • copy (bool) – Whether to return a modified copy of sdata (default: False).

  • coord_keys (list) – Column names containing x and y transcript positions (default: [“x”, “y”]).

  • n_bins (int) – Number of bins for the 2D histograms (default: 30).

Returns:

  • If copy=True, returns a DataFrame with computed metrics.

  • If copy=False, updates sdata[“xrna_metadata”].var with the computed metrics.