troutpy.tl.adaptative_source_score_optimized#
- troutpy.tl.adaptative_source_score_optimized(sdata, chunk_size=100000, max_dist=100, lmbda=0.1, max_k=10, ambient_floor=1.0, signal_threshold=10, residual=0.1, cell_type_col='leiden', copy=False)#
Score extracellular transcripts against nearby cells using a chunked, numba-accelerated kernel.
A faster, chunked reimplementation of
adaptative_source_score(). Cells are represented by a “shell” of their outermost assigned transcripts, and each extracellular transcript is scored against shell points withinmax_distusing_core_scoring_engine_chunk, processingchunk_sizetranscripts at a time.- Parameters:
sdata (
SpatialData) – SpatialData object containing a"table"AnnData (with"cell_id"in.obs) and a"transcripts"points layer with"cell_id","enrichment_over_random","gene","x", and"y"columns.chunk_size (
int(default:100000)) – Number of extracellular transcripts processed per chunk.max_dist (
float(default:100)) – Maximum distance (in coordinate units) to search for candidate parent cells.lmbda (
float(default:0.1)) – Decay rate for the exponential distance weighting.max_k (
int(default:10)) – Maximum number of extracellular neighbors used to build the context gene set.ambient_floor (
float(default:1.0)) –"enrichment_over_random"value at or below whichk_adaptiveis 1.signal_threshold (
float(default:10)) –"enrichment_over_random"value at or above whichk_adaptiveismax_k.residual (
float(default:0.1)) – Constant added to the denominator when normalizing candidate weights.cell_type_col (
str(default:'leiden')) – Column insdata["table"].obscontaining cell-type annotations.copy (
bool(default:False)) – IfTrue, returnsdata. Otherwise modify in place and returnNone.
- Return type:
- Returns:
If
copy=True,sdata. OtherwiseNone, modifyingsdatain place.
Notes
Adds a
"source_score"table tosdata; an"urna_source_score"column tosdata["table"].obs; and"aggregated_source_score"/"mean_assignment_score"columns tosdata["xrna_metadata"].var. This is one of two overlapping source-scoring implementations in this module, alongsideadaptative_source_score().