pipe_varm_key#

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

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

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

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

Parameters:
  • key: str

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

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

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

Return type:

SingleCell