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
| Name | Type | Default | Description |
|---|---|---|---|
data | `anndata.AnnData | pandas.DataFrame` | required |
key_added | `str | None` | None |
na_policy | str | 'raise' | Raise on undefined flags (raise), retain them (keep), or remove them (drop). |
copy | bool | True | Return 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")