pipe_X#

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

Apply a function to a SingleCell dataset’s X.

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

Parameters:
  • function: Callable[[csr_array | csc_array, ...], csr_array | csc_array]

    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 SingleCell dataset where the function has been applied to X.

Return type:

SingleCell