pipe_obsp_key#

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

Apply a function to a specific key in a SingleCell dataset’s obsp.

sc = sc.pipe_obsp_key(func, key) is equivalent to sc.obsp[key] = func(sc.obsp[key]). sc = sc.pipe_obsp_key(key, func, 1, a=2) is equivalent to sc.obsp[key] = func(sc.obsp[key], 1, a=2).

To apply a function to obsp as a whole, rather than to a specific key of obsp, use pipe_obsp().

Parameters:
  • key: str

    the key in obsp to which the function will be applied.

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

    the function to apply to obsp[key]. It must take the old obsp[key] as its first argument and return the new obsp[key]. The function may also take other arguments after obsp[key], 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 obsp[key].

Return type:

SingleCell