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 per gene.
For each gene, computes the centroid shift between its intracellular and extracellular transcripts, and the correlation and Jensen-Shannon divergence between their spatial density histograms. Results are stored in
sdata["xrna_metadata"].var.- Parameters:
sdata (
SpatialData) – SpatialData object containing transcript locations and metadata.layer (
str(default:'transcripts')) – Key of the points element insdatacontaining the transcripts.gene_key (
str(default:'gene')) – Column insdata[layer]containing gene identifiers.copy (
bool(default:False)) – IfTrue, return a modified copy ofsdata. Otherwise modify in place.coord_keys (
Optional[list[str]] (default:None)) – Column names for the x and y transcript coordinates. Defaults to["x", "y"].n_bins (
int(default:30)) – Number of bins per axis for the 2D spatial density histograms.
- Return type:
- Returns:
If
copy=True, a modified copy ofsdata. OtherwiseNone, modifyingsdatain place.
Notes
Genes with fewer than 5 intracellular or 5 extracellular transcripts are skipped.