1. 安裝孟德爾隨機化分析相應(yīng)的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. 概述:
孟德爾隨機化流程如下:
- 選擇暴露的工具變量(篩選顯著的SNP[P < 5e-8]逞力,并進行LD clumping分析,【計算F統(tǒng)計值】)
- 從IEU GWAS數(shù)據(jù)庫或本地結(jié)局GWAS數(shù)據(jù)中提取相應(yīng)的工具變量
- 校正Exposure-SNP及Outcome-SNP等位基因方向
- 進行MR分析饺蔑,敏感性分析,繪制圖表抓歼,匯編報告舟山。
3. 示例:
一個以BMI為暴露,冠心病為結(jié)局的基本孟德爾隨機化分析:
#設(shè)置路徑
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)
#生成匯總結(jié)果
mr_report(
dat,
output_path = ".",
output_type = "html",
author = "Analyst",
study = "Two Sample MR",
path = system.file("reports", package = "TwoSampleMR")
)