基于gpubase的QTL文件
tensorqtl的Python项目详细描述
张量
tensorQTL是一个基于GPU的QTL映射器,与基于CPU的实现相比,cis-和{em1}$trans-QTL映射速度快200-300倍。在
如果您在研究中使用tensorQTL,请引用以下论文: Taylor-Weiner, Aguet, et al., Genome Biol. 20:228, 2019。在
经验β近似p值的计算如FastQTL(Ongen et al., 2016)所述。在
安装
您可以使用pip安装tensorQTL:
pip3 install tensorqtl
或直接从此存储库:
^{pr2}$要求
tensorQTL需要一个配置了GPU的环境。提供了在Google云平台上设置虚拟机的说明here。在
输入格式
tensorQTL需要三个输入文件:基因型、表型和协变量。表型必须以BED格式提供(表型x样本),协变量作为文本文件(协变量x样本)。两者都采用FastQTL使用的格式。基因型目前必须是PLINK格式,并且可以按如下方式转换:
plink2 --make-bed \
--output-chr chrM \
--vcf ${plink_prefix_path}.vcf.gz \
--out ${plink_prefix_path}
示例
有关cis-和trans-QTL映射的示例,请参见tensorqtl_examples.ipynb。在
从命令行运行tensehl>
本节介绍如何从命令行运行tensorQTL。要查看完整的选项列表,请运行
python3 -m tensorqtl --help
cis-QTL定位
表型水平总结统计与经验p值:
python3 -m tensorqtl ${plink_prefix_path} ${expression_bed} ${prefix} \
--covariates ${covariates_file} \
--mode cis
所有变异表型关联:
python3 -m tensorqtl ${plink_prefix_path} ${expression_bed} ${prefix} \
--covariates ${covariates_file} \
--mode cis_nominal
这将为每个染色体生成一个parquet文件。可以使用pandas
读取这些文件:
import pandas as pd
df = pd.read_parquet(file_name)
条件独立的cis-QTL(如GTEx Consortium, 2017所述):
python3 -m tensorqtl ${plink_prefix_path} ${expression_bed} ${prefix} \
--covariates ${covariates_file} \
--cis_results ${cis_results_file} \
--mode cis_independent
trans-QTL定位
python3 -m tensorqtl ${plink_prefix_path} ${expression_bed} ${prefix} \
--covariates ${covariates_file} \
--mode trans
python3 -m tensorqtl ${plink_prefix_path} ${expression_bed} ${prefix} \
--covariates ${covariates_file} \
--mode trans
对于trans-QTL映射,tensorQTL默认生成稀疏输出(与p-value<;1e-5关联)。cis-关联被过滤掉。输出是拼花格式的,有四列:表型_id,variant_id,pval,maf。在
将tensorQTL作为Python模块运行
TensorQTL也可以作为模块运行,以更有效地运行多个分析:
import pandas as pd
import tensorqtl
from tensorqtl import genotypeio, cis, trans
加载输入文件
负荷表型和协变量:
phenotype_df, phenotype_pos_df = tensorqtl.read_phenotype_bed(phenotype_bed_file)
covariates_df = pd.read_csv(covariates_file, sep='\t', index_col=0).T # samples x covariates
基因型可以如下加载,其中plink_prefix_path
是以PLINK格式指向VCF的路径:
pr = genotypeio.PlinkReader(plink_prefix_path)
# load genotypes and variants into data frames
genotype_df = pd.DataFrame(pr.get_all_genotypes(), index=pr.bim['snp'], columns=pr.fam['iid'])
variant_df = pr.bim.set_index('snp')[['chrom', 'pos']]
为了在对样本子集使用基因型时节省内存,可以按如下方式指定样本(这不是严格必要的,因为tensorQTL将从genotype_df
中选择相关样本):
pr = genotypeio.PlinkReader(plink_prefix_path, select_samples=phenotype_df.columns)
cis-QTL定位:排列
cis_df = cis.map_cis(genotype_df, variant_df, phenotype_df, phenotype_pos_df, covariates_df)
tensorqtl.calculate_qvalues(cis_df, qvalue_lambda=0.85)
cis-QTL定位:所有变异表型对的汇总统计
cis.map_nominal(genotype_df, variant_df, phenotype_df, phenotype_pos_df,
covariates_df, prefix, output_dir='.')
cis-QTL定位:条件独立QTL
这需要上面排列步骤(map_cis
)的输出。在
indep_df = cis.map_independent(genotype_df, variant_df, cis_df,
phenotype_df, phenotype_pos_df, covariates_df)
cis-QTL定位:相互作用
不是映射标准线性模型(p~g),而是包含一个交互项(p~g+i+gi),并返回此模型的完整摘要统计信息。交互项是一个pd.Series
将样本ID映射到交互值。
使用run_eigenmt=True
选项,计算eigenMT调整后的p值。在
cis.map_nominal(genotype_df, variant_df, phenotype_df, phenotype_pos_df, covariates_df, prefix,
interaction_s=interaction_s, maf_threshold_interaction=0.05,
group_s=None, run_eigenmt=True, output_dir='.')
trans-QTL定位
trans_df = trans.map_trans(genotype_df, phenotype_df, covariates_df, return_sparse=True)
标签:
- 项目
trans_df = trans.map_trans(genotype_df, phenotype_df, covariates_df, return_sparse=True)
标签: