rapids_singlecell.pp.scale#

rapids_singlecell.pp.scale(data, *, zero_center=True (settings.preset='scanpy-v1' – changes in 2.0), max_value=None, use=None, out=False, mask=None, copy=False, layer=None, obsm=None, mask_obs=None, inplace=True)[source]#

Scales matrix to unit variance and clips values

Parameters:
data AnnData | ndarray | csc_matrix | csr_matrix | Array

The (annotated) data matrix of shape n_obs × n_vars. Rows correspond to cells and columns to genes. If a matrix is passed instead of an AnnData object, the scaled matrix is returned.

zero_center bool | Default (default: True (settings.preset='scanpy-v1' – changes in 2.0))

If False, omit zero-centering variables, which allows to handle sparse input efficiently.

max_value float | None (default: None)

Clip (truncate) to this value after scaling. If None, do not clip.

use LayerAcc | MultiAcc | str | None (default: None)

Which matrix to scale, e.g. A.X, A.layers['counts'] or A.obsm['x']. Strings are resolved by anndata.acc.AdAcc.resolve(), e.g. 'layers.counts'.

out LayerAcc | MultiAcc | str | ScaleOut | bool (default: False)

Where to write the outputs. A single accessor writes scaled to it, a mapping (ScaleOut) writes only the outputs it names, e.g. {'scaled': A.layers['scaled'], 'mean': A.var['m']}. If True, they are returned as a ScaleResult. If False, scaled is written to the place use reads from and mean/std to .var['mean']/.var['std'] (.var['mean of {mask}'] or .var['mean with mask'] if mask is given; not written if use is an .obsm array).

mask ndarray | AdRef | str | None (default: None)

Restrict both the derivation of scaling parameters and the scaling itself to a certain set of observations: a boolean array or a reference like A.obs['m'] (strings are resolved, e.g. 'obs.m'). If the matrix is in csc format and a mask is provided, the matrix will be transformed to csr format.

Return type:

AnnData | ScaleResult | spmatrix | ndarray | None

Returns:

The scaled matrix if a matrix is passed, a ScaleResult if out=True, else None.