map_X#
- Pseudobulk.map_X(function, /, *args, cell_types=None, excluded_cell_types=None, **kwargs)[source]#
Apply a function to each cell type’s X.
To apply a function to X as a whole, rather than each cell type’s X, use pipe_X().
- Parameters:
function: Callable[[ndarray[dtype[floating]], ...], ndarray[dtype[floating]]]
the function to apply to each cell type’s X. It must take the old X for a cell type and return the new X. The function may also take other arguments after X, 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 X.
- Return type: