filter_obs#

SingleCell.filter_obs(*predicates, num_threads=None, **constraints)[source]#

Equivalent to df.filter() from polars, but applied to both obs/obsm and X.

Parameters:
  • *predicates: Expr | Series | str | Iterable[Expr | Series | str] | 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

  • num_threads: int | None

    the number of threads to use when filtering X. Set num_threads=-1 to use all available cores, as determined by os.cpu_count(). By default (num_threads=None), use self.num_threads cores. Does not affect the filtered SingleCell dataset’s num_threads; this will always be the same as the original dataset’s num_threads. Can only be specified when X is not None.

  • **constraints: Any

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

Returns:

A new SingleCell dataset filtered to cells passing all the Boolean filters in predicates and constraints.

Return type:

SingleCell