rapids_singlecell.pp.normalize_pearson_residuals#
- rapids_singlecell.pp.normalize_pearson_residuals(adata, *, theta=100, clip=None, check_values=True, use=None, out=False, layer=None, inplace=True, copy=False)[source]#
Applies analytic Pearson residual normalization [LBK21].
The residuals are based on a negative binomial offset model with overdispersion
thetashared across genes. By default, residuals are clipped tosqrt(n_obs)and overdispersiontheta=100is used.- Parameters:
- adata
AnnData AnnData object
- theta
float(default:100) The negative binomial overdispersion parameter theta for Pearson residuals. Higher values correspond to less overdispersion
(var = mean + mean^2/theta), andtheta=np.infcorresponds to a Poisson model.- clip
float|None(default:None) Determines if and how residuals are clipped: If None, residuals are clipped to the interval [-sqrt(n_obs), sqrt(n_obs)], where n_obs is the number of cells in the dataset (default behavior). If any scalar c, residuals are clipped to the interval
[-c, c]. Setclip=np.inffor no clipping.- check_values
bool(default:True) If True, checks if counts in selected layer are integers as expected by this function, and return a warning if non-integers are found. Otherwise, proceed without checking. Setting this to False can speed up code for large datasets.
- use
LayerAcc|MultiAcc|str|None(default:None) Which matrix to normalize, e.g.
A.X,A.layers['counts']orA.obsm['x']. Strings are resolved byanndata.acc.AdAcc.resolve(), e.g.'layers.counts'.- out
LayerAcc|MultiAcc|str|bool(default:False) Where to write the result, e.g.
A.layers['k'](or'layers.k'). 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. Otherwise writes it tooutand the settings to.uns['pearson_residuals_normalization'](or.uns[k]forout=A.layers[k]).