![cover](https://img-blog.csdnimg.cn/img_convert/89c797f0ded64fa0a06b807ee1f65077.png)
MR分析——剔除与混淆因素相关的SNP
remove_snp <- read.table(‘C:/Users/DELL/Desktop/要剔除的SNP.txt’, sep = ‘\t’, header = T)
·
i = "ukb-b-6134"
# trait = 'Age_Of_Smoking_Initiation'
# remove_snp <- read.table('C:/Users/DELL/Desktop/路易性痴呆/要剔除的SNP.txt', sep = '\t', header = T)
exposure = extract_instruments(outcomes = i)
outcome <- read_outcome_data(snps = exposure$SNP, filename = 'C:/Users/DELL/Desktop/路易性痴呆/GCST90001390_buildGRCh38.tsv', sep = '\t', snp_col = 'SNP', beta_col = 'beta', se_col = 'se', effect_allele_col = 'effect_allele', other_allele_col = 'other_allele', pval_col = 'p_value', eaf_col = 'effect_allele_frequency')
# dat1 <- harmonise_data(exposure_dat = exposure, outcome_dat = outcome)
# dat <- dat1[!(dat1$SNP %in% remove_snp$BB[remove_snp$AA==trait]),] # 剔除SNP
dat <- harmonise_data(exposure_dat = exposure, outcome_dat = outcome)
sum(dat$mr_keep=='TRUE')
a <- generate_odds_ratios(mr_res = mr(dat))
b <- mr_heterogeneity(dat)
c <- mr_pleiotropy_test(dat)
filenamea <- paste0('mr_', i, '.txt')
filenameb <- paste0('heter_', i, '.txt')
filenamec <- paste0('pleio_', i, '.txt')
write.table(a, file = filenamea, quote = F, sep = '\t')
write.table(b, file = filenameb, quote = F, sep = '\t')
write.table(c, file = filenamec, quote = F, sep = '\t')
filename <- paste0("outfig_", i, '.pdf')
pdf(file = filename)
a <- mr_scatter_plot(mr_results = mr(dat, method_list = c("mr_ivw", "mr_egger_regression", "mr_weighted_median")), dat)
b <- mr_funnel_plot(singlesnp_results = mr_singlesnp(dat))
c <- mr_leaveoneout_plot(leaveoneout_results = mr_leaveoneout(dat))
print(a)
print(b)
print(c)
dev.off()
要剔除的SNP.txt:
AA BB CC
Alcoholic_drinks_per_week rs1260326 3
Alcoholic_drinks_per_week rs13107325 3
Cholesterol_total rs112552009 2
Cholesterol_total rs7412 2
Cigarettes_smoked_per_day rs56113850 2
Cigarettes_smoked_per_day rs73229090 2
Fluid_intelligence_score rs13107325 3
Fluid_intelligence_score rs7963801 2
Granulocyte_percentage_of_myeloid_white_cells rs1260326 3
Granulocyte_percentage_of_myeloid_white_cells rs10732976 2
更多推荐
所有评论(0)