1.sc.pp.normalize_per_cell() https://scanpy.readthedocs.io/en/stable/api/scanpy.pp.normalize_per_cell.html Normalize each cell by total counts over all genes, so that every cell has the same total count after normalization. 默认情况下是选择所有cell的UMI的中值作为所有的细胞细胞normalize之后的...
adata_cpdb=adata[~adata.obs['leiden'].isin(['Megakaryocytes'])]#normalize counts=adata_cpdb.X.toarray()adata_cpdb.X=counts sc.pp.normalize_per_cell(adata_cpdb,counts_per_cell_after=1e4)adata_cpdb.layers["norm"]=adata_cpdb.X counts=pd.DataFrame(data=adata_cpdb.layers["norm"],index=a...
adata_merfish.obsm["X_spatial"] = coordinates.to_numpy() sc.pp.normalize_per_cell(adata_merfish, counts_per_cell_after=1e6) sc.pp.log1p(adata_merfish) sc.pp.pca(adata_merfish, n_comps=15) sc.pp.neighbors(adata_merfish) sc.tl.leiden(adata_merfish, key_added='groups', resolution=0.5...
在绘图之前,还要进行一步数据标准化,将表达量用对数计算一遍,这样有利于绘图和展示。 sc.pp.normalize_per_cell(adata,counts_per_cell_after=1e4) sc.pp.log1p(adata) adata.raw=adata# 储存标准化后的AnnaDataObject 识别差异表达基因 sc.pp.highly_variable_genes(adata,min_mean=0.0125,max_mean=3,min_...
sc.pp.normalize_per_cell(# normalize with total UMI count per cell adata, key_n_counts='n_counts_all' ) filter_result = sc.pp.filter_genes_dispersion(# select highly-variable genes adata.X, flavor='cell_ranger', n_top_genes=n_top_genes,log=False ...
sc.pp.normalize_per_cell(# normalizewithtotalUMIcount per cell adata,key_n_counts='n_counts_all')filter_result=sc.pp.filter_genes_dispersion(# select highly-variable genes adata.X,flavor='cell_ranger',n_top_genes=n_top_genes,log=False)adata=adata[:,filter_result.gene_subset]# subset the...
函数pp.normalize_total用于Normalize counts per cell, 其源代码在scanpy/preprocessing/_normalization.py 我们通过一个简单例子来了解该函数主要功能: 将一个简单的矩阵数据转为AnnData对象 fromanndataimportAnnDataimportscanpyasscadata = AnnData(np.array([[3,3,3,6,6],[1,1,1,2,2],[1,22,1,2,2],]...
sc.pp.normalize_total(adata,target_sum=1e4) normalizing counts per cell finished(0:00:00) sc.pp.log1p(adata)#对数据进行log 查看感兴趣的基因的数值大小,可见与先前的count不同 adata[0:6,['ACTB','PPBP','MS4A1']].to_df() sc.pp.highly_variable_genes(adata,min_mean=0.0125,max_mean=3...
#normalizecounts = adata_cpdb.X.toarray()adata_cpdb.X = countssc.pp.normalize_per_cell(adata_cpdb, counts_per_cell_after=1e4)adata_cpdb.layers["norm"] = adata_cpdb.X counts = pd.DataFrame(data=adata_cpdb.layers["norm"], index=adata_cpdb.obs.index.tolist(), columns=adata_cpdb.var...
000 reads per cell, so that counts become comparable among cells.#归一化,10000sc.pp.normalize_...