Skip to content

msmu.pp.add_filter

Adds a filter to the specified modality in the MuData object based on the given condition.

Missing source values never pass, including for negated conditions. Matrix filters use names prefixed with varm[key]. or obsm[key]. (key repr) to distinguish their source from ordinary .obs/.var columns.

Parameters:

Name Type Description Default
mdata MuData

MuData object to which the filter will be added.

required
modality str

The modality within the MuData object to which the filter will be applied

required
column str

The column in the selected table to apply the filter on.

required
keep Literal['eq', 'ne', 'lt', 'le', 'gt', 'ge', 'contains', 'not_contains']

The condition to apply for filtering.

required
value str | float | None

The value to compare against for filtering.

required
on Literal['var', 'obs', 'varm', 'obsm']

Target table to filter on. One of 'var', 'obs', 'varm', or 'obsm'.

'var'
key str | None

Key to select table from .varm/.obsm when on is 'varm'/'obsm'.

None
name str | None

Optional filter name for selection with apply_filter(columns=...). Must be nonblank and contain no slash (HDF5 key restriction). An existing name can only be reused with the same recorded condition.

None

Returns:

Type Description
MuData

MuData object with the added filter.