filter_obs#

Pseudobulk.filter_obs(*predicates, cell_types=None, excluded_cell_types=None, **constraints)[source]#

Equivalent to df.filter() from polars, but applied to both obs and X for each cell type.

Parameters:
  • *predicates : str | Expr | Series | Iterable[str | Expr | Series] | bool | list[bool] | ndarray[dtype[bool]]

    one or more column names, expressions that evaluate to Boolean Series, Boolean Series, lists of Booleans, and/or 1D Boolean NumPy arrays

  • cell_types : str | Iterable[str] | None

    one or more cell types to operate on; if None, operate on all cell types. Mutually exclusive with excluded_cell_types.

  • excluded_cell_types : str | Iterable[str] | None

    one or more cell types to exclude from the operation; mutually exclusive with cell_types

  • **constraints : Any

    column filters: name=value filters to samples where the column named name has the value value

Returns:

A new Pseudobulk dataset filtered to samples passing all the Boolean filters in predicates and constraints.

Return type:

Pseudobulk