Anyone can help, many thanks!
when I used TwoSampleMR 0.5.11 I got a lot of errors like:
Error in run_mr_presso(data) : could not find function "run_mr_presso"
Error in mr_heterogeneity(data) :
could not find function “mr_heterogeneity”
I have installed the package:
install_if_not_installed("TwoSampleMR", remotes::install_github("MRCIEU/TwoSampleMR"))
Then, upon I run the following codes, I got errors:
# ---MR-PRESSO 方法进行异常值检测,得到偏倚的 SNP
mr_presso_result <- run_mr_presso(data)
write.csv(mr_presso_result[[1]]$
MR-PRESSO results
$
Outlier Test
, file = “outlier_SNPs.csv”)
—执行孟德尔随机化分析
mr_result <- mr(data)
write.csv(generate_odds_ratios(mr_result), file = “MR-Result.csv”, row.names = FALSE)
—异质性检验
write.csv(mr_heterogeneity(data), file = “heterogeneity.csv”, row.names = FALSE)
—多效性检验
write.csv(mr_pleiotropy_test(data), file = “pleiotropy.csv”, row.names = FALSE)
—绘图
pdf(file = “pic.scatter_plot.pdf”, width = 7.5, height = 7); mr_scatter_plot(mr_result, data); dev.off() # 散点图
res_single <- mr_singlesnp(data)
pdf(file = “pic.forest.pdf”, width = 7, height = 6.5); mr_forest_plot(res_single); dev.off() # 森林图
pdf(file = “pic.funnel_plot.pdf”, width = 7, height = 6.5); mr_funnel_plot(singlesnp_results = res_single); dev.off() # 漏斗图
pdf(file = “pic.leaveoneout.pdf”, width = 7, height = 6.5); mr_leaveoneout_plot(leaveoneout_results = mr_leaveoneout(data)); dev.off() # 敏感性分析
rm(list = setdiff(ls(), GLOBAL_VAR)) # 移除无用的变量
gc() # 垃圾回收