grassp.tl.leiden_mito_sweep#
- leiden_mito_sweep(data, starting_resolution=0.5, resolution_increments=0.5, min_mito_fraction=0.9, increment_threshold=0.005, protein_ground_truth_column='protein_ground_truth', **leiden_kwargs)[source]#
Automated sweep to pick a Leiden resolution that keeps mitochondria intact.
Starting from
starting_resolution
the function iteratively increases or decreases the resolution (binary-search style) until mitochondrial proteins—identified viaprotein_ground_truth_column
—remain grouped in a single Leiden cluster with at leastmin_mito_fraction
of all mitochondrial proteins.The final resolution and the observed fraction are stored in
data.uns['leiden']['params']['resolution']
anddata.uns['leiden']['mito_majority_fraction']
.- Parameters:
- data
AnnData
anndata.AnnData
object afterscanpy.pp.neighbors()
with proteins as observations.- starting_resolution
float
(default:0.5
) Initial Leiden resolution from which to begin the sweep.
- resolution_increments
float
(default:0.5
) Step size added (or subtracted) each iteration; halved whenever the sweep crosses the
min_mito_fraction
threshold.- min_mito_fraction
float
(default:0.9
) Required proportion of mitochondrial proteins that must share a cluster (default
0.9
).- increment_threshold
float
(default:0.005
) When the increment falls below this value the search terminates.
- protein_ground_truth_column
str
(default:'protein_ground_truth'
) Observation column holding the curated ground-truth localisation with the category
"mitochondria"
.- **leiden_kwargs
Extra parameters forwarded to
scanpy.tl.leiden()
(e.g.random_state
).
- data
- Return type:
- Returns:
Updates
data.obs['leiden']
anddata.uns['leiden']
in place.