pipe_obsm_key#

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

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

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

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

Parameters:
  • key : str

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

  • function : Callable[[ndarray | DataFrame, ...], ndarray | DataFrame]

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

Return type:

SingleCell