pipe_uns_key#
- SingleCell.pipe_uns_key(key, function, /, *args, **kwargs)[source]#
Apply a function to a specific key in a SingleCell dataset’s uns.
sc = sc.pipe_uns_key(func, key) is equivalent to sc.uns[key] = func(sc.uns[key]). sc = sc.pipe_uns_key(key, func, 1, a=2) is equivalent to sc.uns[key] = func(sc.uns[key], 1, a=2).
To apply a function to uns as a whole, rather than to a specific key of uns, use pipe_uns().
- Parameters:
key : str
the key in uns to which the function will be applied.
function : Callable[[Dict[str, str | int | float | bool | bool | ndarray | Dict[str, str | int | float | bool | bool | ndarray | UnsDict]], ...], Dict[str, str | int | float | bool | bool | ndarray | Dict[str, str | int | float | bool | bool | ndarray | UnsDict]]]
the function to apply to uns[key]. It must take the old uns[key] as its first argument and return the new uns[key]. The function may also take other arguments after uns[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 uns[key].
- Return type: