scanpy.api.pp.scale(data, zero_center=True, max_value=None, copy=False)

Scale data to unit variance and zero mean.


Variables (genes) that do not display any variation (are constant across all observations) are retained and set to 0 during this operation. In the future, they might be set to NaNs.

data : AnnData, np.ndarray, sp.sparse

The (annotated) data matrix of shape n_obs × n_vars. Rows correspond to cells and columns to genes.

zero_center : bool, optional (default: True)

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

max_value : float or None, optional (default: None)

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

copy : bool, optional (default: False)

If an AnnData is passed, determines whether a copy is returned.

Return type

AnnData, NoneOptional[AnnData]


Depending on copy returns or updates adata with a scaled adata.X.