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