<jupyter_start><jupyter_text>QTL mapping with tensorQTLThe V8 *cis*-eQTLs and *cis*-sQTLs were mapped using [FastQTL](https://github.com/francois-a/fastqtl). This notebook provides the equivalent commands for tensorQTL, which contains additional built-in commands, including for mapping conditionally independent eQTLs. Required input filesThe VCF can be obtained from [AnVIL](https://app.terra.bio/workspaces/anvil-datastorage/AnVIL_GTEx_V8_hg38)The following files are needed for tensorQTL:```gs://fc-secure-ff8156a3-ddf3-42e4-9211-0fd89da62108/GTEx_Analysis_2017-06-05_v8_WGS_VCF_files/GTEx_Analysis_2017-06-05_v8_WholeGenomeSeq_838Indiv_Analysis_Freeze.SHAPEIT2_phased.MAF01.bedgs://fc-secure-ff8156a3-ddf3-42e4-9211-0fd89da62108/GTEx_Analysis_2017-06-05_v8_WGS_VCF_files/GTEx_Analysis_2017-06-05_v8_WholeGenomeSeq_838Indiv_Analysis_Freeze.SHAPEIT2_phased.MAF01.bimgs://fc-secure-ff8156a3-ddf3-42e4-9211-0fd89da62108/GTEx_Analysis_2017-06-05_v8_WGS_VCF_files/GTEx_Analysis_2017-06-05_v8_WholeGenomeSeq_838Indiv_Analysis_Freeze.SHAPEIT2_phased.MAF01.fam```The expression and covariate matrices can be obtained from the [GTEx Portal](https://gtexportal.org/home/datasets), specifically the following archives (which need to be unpacked):```GTEx_Analysis_v8_eQTL_expression_matrices.tarGTEx_Analysis_v8_eQTL_covariates.tar.gz```<jupyter_code>import pandas as pd
import tensorqtl
from tensorqtl import genotypeio, cis, post
# load VCF
plink_prefix_path = '/resources/vcfs/GTEx_Analysis_2017-06-05_v8_WholeGenomeSeq_838Indiv_Analysis_Freeze.SHAPEIT2_phased.MAF01'
pr = genotypeio.PlinkReader(plink_prefix_path)
genotype_df = pr.load_genotypes()
variant_df = pr.bim.set_index('snp')[['chrom', 'pos']]
# Example: mapping eQTLs for 'Brain_Cortex'
tissue_id = 'Brain_Cortex'
phenotype_df, phenotype_pos_df = tensorqtl.read_phenotype_bed('/resources/GTEx_Analysis_v8_eQTL_expression_matrices/{}.v8.normalized_expression.bed.gz'.format(tissue_id))
covariates_df = pd.read_csv('/resources/GTEx_Analysis_v8_eQTL_covariates/{}.v8.covariates.txt'.format(tissue_id), sep='\t', index_col=0).T
# 1) compute permutations and define eGenes
egenes_df = cis.map_cis(genotype_df, variant_df, phenotype_df, phenotype_pos_df, covariates_df)
post.calculate_qvalues(egenes_df, fdr=0.05, qvalue_lambda=0.85)
# 2) compute nominal associations for all variant-gene pairs
cis.map_nominal(genotype_df, variant_df, phenotype_df, phenotype_pos_df,
                covariates_df, tissue_id, output_dir='.')
# 3) compute significant variant-gene pairs
pairs_df = post.get_significant_pairs(egenes_df, '{}'.format(tissue_id))
# 4) compute conditionally independent eQTLs
indep_df = cis.map_independent(genotype_df, variant_df, egenes_df,
                               phenotype_df, phenotype_pos_df, covariates_df)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09886201991465149, 'fraction_numerical': 0.060810810810810814, 'mean_word_length': 7.422155688622754, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '322130', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1051, 'n_words': 152, 'path': 'analyses/GTEx_v8_QTL_mapping.ipynb', 'repo_name': 'broadinstitute/gtex-v8', 'size': '2812'}