pipe_obs#

Pseudobulk.pipe_obs(function, /, *args, **kwargs)[source]#

Apply a function to a Pseudobulk dataset’s obs.

pb = pb.pipe_obs(func) is equivalent to pb.obs = func(pb.obs). pb = pb.pipe_obs(func, 1, a=2) is equivalent to pb.obs = func(pb.obs, 1, a=2).

To apply a function to each cell type’s obs, rather than to obs as a whole, use map_obs().

Parameters:
  • function: Callable[[dict[str, DataFrame], ...], dict[str, DataFrame]]

    the function to apply to obs. It must take the old obs as its first argument 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

  • **kwargs: Any

    the keyword arguments to the function

Returns:

A new Pseudobulk dataset where the function has been applied to obs.

Return type:

Pseudobulk