pipe_X#

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

Apply a function to a Pseudobulk dataset’s X.

pb = pb.pipe_X(func) is equivalent to pb.X = func(pb.X). pb = pb.pipe_X(func, 1, a=2) is equivalent to pb.X = func(pb.X, 1, a=2).

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

Parameters:
  • function: Callable[[dict[str, ndarray[dtype[floating]]], ...], dict[str, ndarray[dtype[floating]]]]

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

  • **kwargs: Any

    the keyword arguments to the function

Returns:

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

Return type:

Pseudobulk