📘孟德尔随机化之Introduction

1. 安装孟德尔随机化分析相应的R包

# 方法一 ---------------------------------------------------------------------
if (!requireNamespace("remotes", quietly = TRUE))install.packages("remotes")
if (!requireNamespace("TwoSampleMR", quietly = TRUE))remotes::install_github("MRCIEU/TwoSampleMR")
library(TwoSampleMR)

# 方法二 ---------------------------------------------------------------------

if (!requireNamespace("devtools", quietly = TRUE))install.packages("devtools")
if (!requireNamespace("TwoSampleMR", quietly = TRUE))devtools::install_github("MRCIEU/TwoSampleMR")
library(TwoSampleMR)

2. 概述:

孟德尔随机化流程如下:

  1. 选择暴露的工具变量(筛选显著的SNP[P < 5e-8],并进行LD clumping分析,【计算F统计值】)
  2. 从IEU GWAS数据库或本地结局GWAS数据中提取相应的工具变量
  3. 校正Exposure-SNP及Outcome-SNP等位基因方向
  4. 进行MR分析,敏感性分析,绘制图表,汇编报告。

3. 示例:

一个以BMI为暴露,冠心病为结局的基本孟德尔随机化分析:

#设置路径
setwd("D:/mylesson/孟德尔随机化/3.孟德尔随机化之Introduction/result")
#加载包
library(TwoSampleMR)

# List available GWASs
ao <- available_outcomes()

# Get instruments
exposure_dat <- extract_instruments("ieu-a-2")

# Get effects of instruments on outcome
outcome_dat <- extract_outcome_data(snps=exposure_dat$SNP, outcomes = "ieu-a-7")

# Harmonise the exposure and outcome data
dat <- harmonise_data(exposure_dat, outcome_dat)

# Perform MR
res <- mr(dat)

#生成汇总结果
mr_report(
  dat,
  output_path = ".",
  output_type = "html",
  author = "Analyst",
  study = "Two Sample MR",
  path = system.file("reports", package = "TwoSampleMR")
)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容