美文网首页孟德尔随机化
📘孟德尔随机化之Introduction

📘孟德尔随机化之Introduction

作者: 生信蟹道人 | 来源:发表于2023-10-25 23:48 被阅读0次

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")
)

相关文章

网友评论

    本文标题:📘孟德尔随机化之Introduction

    本文链接:https://www.haomeiwen.com/subject/wsryidtx.html