MR——自动绘图

library(TwoSampleMR)
data = read.table('C:/Users/DELL/Desktop/lummr_result.csv',header = T,sep = ',')

for (m in c(147:152)) {
  i = data$id.exposure[m]
  exposure = extract_instruments(outcomes = i)
  outcome <- extract_outcome_data(snps = exposure$SNP, outcomes = 'ukb-b-2349')
  dat <- harmonise_data(exposure_dat = exposure, outcome_dat = outcome)
  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()
  print(m)
}

你可能感兴趣的:(MR,mr)