- dynamo.pp.calc_sz_factor(adata_ori, layers='all', total_layers=None, splicing_total_layers=False, X_total_layers=False, locfunc=<function nanmean>, round_exprs=False, method='median', scale_to=None, use_all_genes_cells=True, genes_use_for_norm=None)
Calculate the size factor of each cell using geometric mean or median of total UMI across cells for a AnnData object.
This function is partly based on Monocle R package (https://github.com/cole-trapnell-lab/monocle3).
AnnData) – an AnnData object.
str]]) – the layer(s) that can be summed up to get the total mRNA. For example, [“spliced”, “unspliced”], [“uu”, “ul”, “su”, “sl”] or [“new”, “old”], etc. Defaults to None.
bool) – whether to also normalize spliced / unspliced layers by size factor from total RNA. Defaults to False.
bool) – whether to also normalize adata.X by size factor from total RNA. Defaults to False.
Callable) – the function to normalize the data. Defaults to np.nanmean.
bool) – whether the gene expression should be rounded into integers. Defaults to False.
'median']) – 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 mean-geometric-mean-total is used, size factors will be calculated using the geometric mean with given mean function. When median is used, locfunc will be replaced with np.nanmedian. When mean is used, locfunc will be replaced with np.nanmean. Defaults to “median”.
bool) – whether all cells and genes should be used for the size factor calculation. Defaults to True.
str]]) – A list of gene names that will be used to calculate total RNA for each cell and then the size factor for normalization. This is often very useful when you want to use only the host genes to normalize the dataset in a virus infection experiment (i.e. CMV or SARS-CoV-2 infection). Defaults to None.
- Return type:
An updated anndata object that are updated with the Size_Factor (layer_ + Size_Factor) column(s) in the obs attribute.