dynamo.pp.normalize_cells(adata, layers='all', total_szfactor='total_Size_Factor', splicing_total_layers=False, X_total_layers=False, norm_method=None, pseudo_expr=1, relative_expr=True, keep_filtered=True, recalc_sz=False, sz_method='median', scale_to=None, skip_log=False)

Normalize the gene expression value for the AnnData object This function is partly based on Monocle R package (https://github.com/cole-trapnell-lab/monocle3).

  • adata (AnnData) – AnnData object.

  • layers (str (default: all)) – The layer(s) to be normalized. Default is all, including RNA (X, raw) or spliced, unspliced, protein, etc.

  • total_szfactor (str (default: total_Size_Factor)) – The column name in the .obs attribute that corresponds to the size factor for the total mRNA.

  • splicing_total_layers (bool (default False)) – Whether to also normalize spliced / unspliced layers by size factor from total RNA.

  • X_total_layers (bool (default False)) – Whether to also normalize adata.X by size factor from total RNA.

  • norm_method (function or None (default: None)) – The method used to normalize data. Can be either function np.log1p, np.log2 or any other functions or string `clr. By default, only .X will be size normalized and log1p transformed while data in other layers will only be size normalized.

  • pseudo_expr (int (default: 1)) – A pseudocount added to the gene expression value before log/log2 normalization.

  • relative_expr (bool (default: True)) – A logic flag to determine whether we need to divide gene expression values first by size factor before normalization.

  • keep_filtered (bool (default: True)) – A logic flag to determine whether we will only store feature genes in the adata object. If it is False, size factor will be recalculated only for the selected feature genes.

  • recalc_sz (bool (default: False)) – A logic flag to determine whether we need to recalculate size factor based on selected genes before normalization.

  • sz_method (str (default: mean-geometric-mean-total)) – The method used to calculate the expected total reads / UMI used in size factor calculation. Only mean-geometric-mean-total / geometric and median are supported. When median is used, locfunc will be replaced with np.nanmedian.

  • scale_to (float or None (default: None)) – The final total expression for each cell that will be scaled to.


adata – An updated anndata object that are updated with normalized expression values for different layers.

Return type