利用scanpy计算adata的obs中的质量控制指标(n_genes_by_counts,total_counts等参数指标)
⚠️注意:只是计算相关质量控制指标,并不会筛选/过滤数据。
需要用的包:scanpy和anndata
导入包和读取adata数据
import anndata
import scanpy as sc
import pandas as pd
import numpy as np
adata=anndata.read(file_address)
print(adata)
print(adata.obs)
使用方法
- 计算质量控制指标
n_genes_by_counts
,total_counts
等参数指标:log1p=False
sc.pp.calculate_qc_metrics(adata, percent_top=None, log1p=False, inplace=True)
print(adata)
print(adata.obs)
- 如果需要log1p变换,即
log1p_n_genes_by_counts
和log1p_total_counts
参数指标:log1p=True
sc.pp.calculate_qc_metrics(adata, percent_top=None, log1p=True, inplace=True)
print(adata)
print(adata.obs)
- 如果需要计算线粒体基因的表达量,即
total_counts_mt
和pct_counts_mt
参数指标:qc_vars=["mt"]
adata.var["mt"] = adata.var_names.str.startswith("MT-")
sc.pp.calculate_qc_metrics( adata, qc_vars=["mt"], percent_top=None, log1p=False, inplace=True)
print(adata)
print(adata.obs)
标签:log1p,genes,scanpy,print,counts,total,adata
From: https://www.cnblogs.com/kingwz/p/18408829