scanpy.pp.scale
- scanpy.pp.scale(X, zero_center=True, max_value=None, copy=False, layer=None, obsm=None)
- scanpy.pp.scale(X, *, zero_center=True, max_value=None, copy=False, return_mean_std=False)
- scanpy.pp.scale(X, *, zero_center=True, max_value=None, copy=False, return_mean_std=False)
- scanpy.pp.scale(adata, *, zero_center=True, max_value=None, copy=False, layer=None, obsm=None)
Scale data to unit variance and zero mean.
Note
Variables (genes) that do not display any variation (are constant across all observations) are retained and (for zero_center==True) set to 0 during this operation. In the future, they might be set to NaNs.
- Parameters
- X :
AnnData
|spmatrix
|ndarray
Union
[AnnData
,spmatrix
,ndarray
] The (annotated) data matrix of shape
n_obs
×n_vars
. Rows correspond to cells and columns to genes.- zero_center :
bool
bool
(default:True
) If
False
, omit zero-centering variables, which allows to handle sparse input efficiently.- max_value :
float
|None
Optional
[float
] (default:None
) Clip (truncate) to this value after scaling. If
None
, do not clip.- copy :
bool
bool
(default:False
) Whether this function should be performed inplace. If an AnnData object is passed, this also determines if a copy is returned.
- layer :
str
|None
Optional
[str
] (default:None
) If provided, which element of layers to scale.
- obsm :
str
|None
Optional
[str
] (default:None
) If provided, which element of obsm to scale.
- X :
- Returns
Depending on
copy
returns or updatesadata
with a scaledadata.X
, annotated with'mean'
and'std'
inadata.var
.