troutpy.pp.define_urna_probability#
- troutpy.pp.define_urna_probability(sdata, p_threshold=0.5, copy=False)#
Classify transcripts as extracellular (uRNA) via a Bayesian probability from grid-interpolated KDEs.
Fits Gaussian KDEs of
cosine_similarityfor transcripts inside cells versus background transcripts outside cells, evaluates both on a shared grid to deriveP(uRNA | cosine_similarity), and interpolates this probability back onto every transcript.- Parameters:
sdata (spatialdata.SpatialData) – SpatialData object with a
"transcripts"points layer containingoverlaps_cell,cosine_similarity, andenrichment_classcolumns.p_threshold (float, optional) – Minimum
prob_is_urnavalue for a transcript to be classified as extracellular. Defaults to0.5.copy (bool, optional) – If
True, return the modified SpatialData object. Otherwise modifysdatain place and returnNone. Defaults toFalse.
- Returns:
spatialdata.SpatialData or None SpatialData with
prob_is_urnaandextracellularcolumns added to the"transcripts"layer ifcopy=True; otherwiseNone. If fewer than 10 reference transcripts are available inside or outside cells,sdatais returned unchanged.