scanpy.pp.normalize_shifted_clr#
- scanpy.pp.normalize_shifted_clr(adata, *, alpha=None, use=None, out=False)[source]#
Normalize counts with the shifted centered log-ratio (PFlog) transform.
If
alphais not provided, it is estimated from the input matrix. PFlog is then computed aswhich is equivalent to centering because the constant cancels during CLR centering.
Array type support# Array type
supported
… experimentally in dask
Array✅
✅
✅
✅
Note
CLR centering generally maps zeros to non-zero values, so the resulting matrix is dense even when the input is sparse.
- Parameters:
- adata
AnnData The annotated data matrix of shape
n_obs×n_vars. Rows correspond to cells and columns to genes.- alpha
float|None(default:None) Negative-binomial overdispersion of the dataset (
var = μ + α·μ²). IfNone, it is estimated from the input matrix. A positive numeric value uses that value directly. PFlog applieslog1p(4 * alpha * x)before CLR centering.- use
LayerAcc|MultiAcc|str|None(default:None) Which matrix to normalize. Given by an accessor, e.g.
A.X,A.layers['counts']orA.obsm['pca'].strs areanndata.acc.AdAcc.resolve()d, e.g.'layers.counts'.- out
LayerAcc|MultiAcc|str|bool(default:False) Where to write the result, e.g.
A.layers['scaled'].strs areanndata.acc.AdAcc.resolve()d, e.g.'layers.scaled'. IfTrue, the result is returned instead of written. IfFalse, it is written to the placeusereads from.
- adata
- Return type:
- Returns:
The normalized matrix if
out=True, elseNone.
Example
>>> import numpy as np >>> from anndata import AnnData >>> import scanpy as sc >>> adata = AnnData(np.array([[1, 2, 30], [4, 50, 6]], dtype="float32")) >>> sc.pp.normalize_shifted_clr(adata, alpha=0.5) >>> np.allclose(adata.X.sum(axis=1), 0, atol=1e-5) True