troutpy.tl.compute_source_score#
- troutpy.tl.compute_source_score(sdata, layer='transcripts', gene_key='gene', coord_keys=None, lambda_decay=0.1, copy=False, celltype_key='cell type', n_jobs=-1)#
Compute a source score for extracellular transcripts based on nearby cell types and gene expression profiles, using exponential distance decay.
- Parameters:
sdata (spatialdata.SpatialData) – SpatialData object with a transcript layer and an AnnData table.
layer (str) – Name of the layer in sdata.points containing transcripts. Default is “transcripts”.
gene_key (str) – Column name in transcript table corresponding to gene names. Default is “gene”.
coord_keys (list) – List of coordinate column names to use (e.g., [“x”, “y”]). Default is [“x”, “y”].
lambda_decay (float) – Decay rate for the exponential function applied to distances. Default is 0.1.
copy (bool) – If True, return a copy of the SpatialData object with results added. Default is False.
celltype_key (str) – Column name in adata.obs specifying cell type labels. Default is “cell type”.
n_jobs (int) – Number of parallel jobs to run (-1 uses all processors). Default is -1.
- Returns:
SpatialData or None Updated SpatialData object with added transcript-level and cell-level source scores. Returns None if copy=False (modifies sdata in place).