map_obs#
- Pseudobulk.map_obs(function, /, *args, cell_types=None, excluded_cell_types=None, **kwargs)[source]#
Apply a function to each cell type’s obs.
To apply a function to obs as a whole, rather than each cell type’s obs, use pipe_obs().
- Parameters:
function : Callable[[DataFrame, ...], DataFrame]
the function to apply to each cell type’s obs. It must take the old obs for a cell type and return the new obs. The function may also take other arguments after obs, which can be specified via args and kwargs.
*args : Any
the positional arguments to the function
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
**kwargs : Any
the keyword arguments to the function
- Returns:
A new Pseudobulk dataset where the function has been applied to each cell type’s obs.
- Return type: