scanpy.pp.normalize_shifted_clr#
- scanpy.pp.normalize_shifted_clr(adata, *, alpha=None, layer=None, inplace=True, copy=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.- layer
str|None(default:None) Layer to normalize instead of
X.- inplace
bool(default:True) Whether to update
adataor return a dictionary with the normalized matrix.- copy
bool(default:False) Whether to modify a copied input object. Not compatible with
inplace=False.
- adata
- Return type:
- Returns:
Returns a dictionary with the normalized matrix or updates
adata, depending oninplace.
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