scanpy.experimental.pp.normalize_pearson_residuals#
- scanpy.experimental.pp.normalize_pearson_residuals(adata, *, theta=100, clip=None, check_values=True, layer=None, inplace=True, copy=False)[source]#
- Apply analytic Pearson residual normalization, based on Lause et al. [2021]. - The residuals are based on a negative binomial offset model with overdispersion - thetashared across genes. By default, residuals are clipped to- sqrt(n_obs)and overdispersion- theta=100is used.- Expects raw count input. - Parameters:
- adata AnnData
- The annotated data matrix of shape - n_obs×- n_vars. Rows correspond to cells and columns to genes.
- theta float(default:100)
- The negative binomial overdispersion parameter - thetafor Pearson residuals. Higher values correspond to less overdispersion (- var = mean + mean^2/theta), and- theta=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_obsis the number of cells in the dataset (default behavior).
- If any scalar - c, residuals are clipped to the interval- [-c, c]. Set- clip=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- Falsecan speed up code for large datasets.
- layer str|None(default:None)
- Layer to use as input instead of - X. If- None,- Xis used.
- inplace bool(default:True)
- If - True, update- adatawith results. Otherwise, return results. See below for details of what is returned.
- copy bool(default:False)
- If - True, the function runs on a copy of the input object and returns the modified copy. Otherwise, the input object is modified direcly. Not compatible with- inplace=False.
 
- adata 
- Return type:
- Returns:
- If - inplace=True,- adata.Xor the selected layer in- adata.layersis updated with the normalized values.- adata.unsis updated with the following fields. If- inplace=False, the same fields are returned as dictionary with the normalized values in- results_dict['X'].- .uns['pearson_residuals_normalization']['theta']
- The used value of the overdisperion parameter theta. 
- .uns['pearson_residuals_normalization']['clip']
- The used value of the clipping parameter. 
- .uns['pearson_residuals_normalization']['computed_on']
- The name of the layer on which the residuals were computed.