bioalpha.singlecell.preprocessing.scale
- bioalpha.singlecell.preprocessing.scale(X: H5ADMap | AnnData | spmatrix | ndarray, zero_center: bool = False, max_value: float | None = None, copy: bool = False, layer: str | None = None, obsm: str | None = None, key_added: str | None = None, obs_mask: str | None = None, var_mask: str | None = None, **kwargs)
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 (Union[
H5ADMap
,AnnData
,spmatrix
,ndarray
]) – The (annotated) data matrix of shapen_obs
xn_vars
. Rows correspond to cells and columns to genes.zero_center (
bool
, default =False
) – IfFalse
, omit zero-centering variables, which allows to handle sparse input efficiently. Incompatible with sparse data.max_value (Optional[
float
], default =None
,) – Clip (truncate) to this value after scaling. IfNone
, do not clip.copy (
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 (Optional[
str
], default =None
) – If provided, which element of layers to scale.obsm (Optional[
str
], default =None
) – If provided, which element of obsm to scale.obs_mask (Optional[
str
], default =None
) – Ifobs_mask
is notNone
, filter cells byadata.obs[obs_mask]
.var_mask (Optional[
str
], default =None
) – Ifobs_mask
is notNone
, filter genes byadata.obs[obs_mask]
.**kwargs – Other arguments passed to BatchReader
- Returns:
Depending on
copy
returns or updatesadata
with a scaledadata.X
,annotated with
'mean'
and'std'
inadata.var
.