转自:https://www.jianshu.com/p/f063a4aa980a
1.例子
from anndata import AnnData import scanpy as sc adata = ad.AnnData(np.array([ [3, 3, 3, 6, 6], [1, 1, 1, 2, 2], [1, 22, 1, 2, 2], ])) X_norm = sc.pp.normalize_total(adata, inplace=False) # 输出: X_norm {'X': array([[ 3. , 3. , 3. , 6. , 6. ], [ 3. , 3. , 3. , 6. , 6. ], [ 0.75, 16.5 , 0.75, 1.5 , 1.5 ]], dtype=float32), 'norm_factor': array([21., 7., 28.], dtype=float32)}
在target_sum参数为None的情况下,
target_sum
If ``None``, after normalization, each observation (cell) has a total count
equal to the median of total counts for observations (cells)
before normalization.
如果为None,将每个cell的library size归一化到中值,此中值是指所有cells的library size的中值。
如在上例中,所有cell的library size向量为:
array([21., 7., 28.], dtype=float32)
那么中值为21,归一化后,所有cell的library size都为21.