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

vm.pp.filter

Remove observations flagged by an existing QC run.

Signature

def filter(
    data: anndata.AnnData | pandas.DataFrame,
    *,
    key_added: str | None = None,
    na_policy: str = "raise",
    copy: bool = True,
) -> anndata.AnnData | pandas.DataFrame | None: ...

Parameters

NameTypeDefaultDescription
data`anndata.AnnDatapandas.DataFrame`required
key_added`strNone`None
na_policystr'raise'Raise on undefined flags (raise), retain them (keep), or remove them (drop).
copyboolTrueReturn a filtered copy. False subsets the supplied object in place.

Returns

AnnData, pandas.DataFrame, or None

Filtered copy, or None for an in-place operation. The selected run records the latest filtering counts alongside the original fit.

Raises

KeyError

If the selected run or its combined flag is missing.

TypeError

If the combined flag is not Boolean or copy is not Boolean.

ValueError

If na_policy is invalid, classifications are undefined under na_policy='raise', or backed AnnData must first be loaded into memory.

Notes

AnnData filtering subsets observations and preserves the other annotated data fields. The stored fit and thresholds remain unchanged; filtering counts are added to the selected run. DataFrame filtering preserves row order and records metadata in .attrs. No thresholds are refit.

See Also

Examples

import verymadpy as vm

adata_filtered = vm.pp.filter(adata, na_policy="keep")