snapatac2.pp.filter_doublets#
- snapatac2.pp.filter_doublets(adata, probability_threshold=0.5, score_threshold=None, inplace=True, n_jobs=8, verbose=True)[source]#
Remove cells classified as doublets.
Use this function after
scrubletto subset an AnnData object or return a boolean mask of cells to keep. Filter by either calibrated doublet probability or raw doublet score.Anti-Patterns#
Do NOT call this function before
snap.pp.scrublet; it requiresdoublet_probabilityordoublet_scorein.obs.Do NOT set both
probability_thresholdandscore_threshold; choose one filtering criterion.
- type adata:
AnnData|list[AnnData]- param adata:
AnnData-like object with Scrublet scores in
.obs, or a list of such objects. When a list is provided, the function processes objects in parallel.- type probability_threshold:
- param probability_threshold:
Remove cells with
doublet_probabilitygreater than this value. Lower values remove more cells. Set toNonewhen usingscore_threshold.- type score_threshold:
- param score_threshold:
Remove cells with
doublet_scoregreater than this value. Set toNonewhen usingprobability_threshold.- type inplace:
- param inplace:
If
True, subsetadatain place. IfFalse, return a keep mask.- type n_jobs:
- param n_jobs:
Number of jobs to run in parallel when
adatais a list.- type verbose:
- param verbose:
Whether to print progress messages.
- returns:
If
inplace=False, returns a boolean mask whereTruekeeps a cell andFalseremoves a doublet. Ifinplace=True, returnsNoneand subsets the object in place.- rtype:
See also
Examples
>>> import snapatac2 as snap >>> adata = snap.read(snap.datasets.pbmc5k(type="h5ad"), backed=None) >>> snap.pp.select_features(adata) >>> snap.pp.scrublet(adata, n_comps=5, sim_doublet_ratio=0.5, verbose=False) >>> keep = snap.pp.filter_doublets(adata, probability_threshold=0.5, inplace=False, verbose=False) >>> keep.dtype == bool True