Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Single-cell quality control

Objective: fit pooled MAD thresholds to QC metrics, inspect the resulting flags, then choose how to handle observations that cannot be classified.

Start with an AnnData object whose QC metrics have already been calculated; the quick start creates one. This example uses a named run so it remains separate from the default fit.

import verymadpy as vm

vm.pp.flag_mad_outliers(adata, key_added="pooled_qc")
qc_table = vm.pp.summarize_mad(adata, key_added="pooled_qc", include_combined=True)

The default policy uses four scaled MADs in both tails of log1p(total_counts) and log1p(n_genes_by_counts), plus four scaled MADs in the upper tail of pct_counts_mt. The two count metrics are required. If mitochondrial percentage is unavailable, veryMADpy warns and fits the two count metrics only. The default does not include other percentage metrics.

The combined flag is true when any metric flags a cell, false when all metric results are defined and false, and undefined otherwise. summarize_mad() distinguishes fit-time counts from counts on the current object. Before filtering, inspect undefined values and decide whether to raise, keep, or drop them:

adata_reviewed = vm.pp.filter(adata, key_added="pooled_qc", na_policy="keep")

filter() uses the existing combined flag; it does not refit thresholds. Its default na_policy="raise" prevents undefined cells from silently passing QC. Flagging and filtering do not automatically alter genes or normalize expression. See flag_mad_outliers, summarize_mad, and filter.