# 有相关性就有因果关系吗，教你玩转孟德尔随机化分析（mendelian randomization ）

### 4 怎么做孟德尔随机化分析

##### 4.1 安装R包

install.packages("devtools")

library(devtools)

install_github("MRCIEU/TwoSampleMR")

##### 4.2 导入大胸（exposure）的显著信号位点

library(TwoSampleMR)

bmi_file <- system.file("data/bmi.txt", package="TwoSampleMR")

exposure_dat <- read_exposure_data(bmi_file)

##### 4.3 导入显著信号位点与不爱运动的相关性数据

outcome_dat <- read_outcome_data(snps = exposure_dat\$SNP,filename = "F:/download/test.csv", sep = ",",snp_col = "SNP",beta_col = "beta",se_col = "se",effect_allele_col = "effect_allele",other_allele_col = "other_allele",eaf_col = "eaf",samplesize_col = "samplesize")

##### 4.4 统一大胸和不爱运动的效应值方向

dat <- harmonise_data(exposure_dat, outcome_dat)

##### 4.5 孟德尔随机化分析

res <- mr(dat)

##### 4.6 画散点图

p1 <- mr_scatter_plot(res, dat)

p1[[1]]

#### 4.7.1 Heterogeneity statistics

mr_heterogeneity(dat)

#### 4.7.2 Horizontal pleiotropy

mr_pleiotropy_test(dat)

#### 4.7.3 Single SNP analysis

res_single <- mr_singlesnp(dat)

#### 4.7.4 Leave-one-out analysis

res_loo <- mr_leaveoneout(dat)

#### 4.7.5 Forest plot

res_single <- mr_singlesnp(dat)

p2 <- mr_forest_plot(res_single)

p2[[1]]

#### 4.7.6 Leave-one-out plot

res_loo <- mr_leaveoneout(dat)

p3 <- mr_leaveoneout_plot(res_loo)

p3[[1]]

#### 4.7.7 Funnel plot

res_single <- mr_singlesnp(dat)

p4 <- mr_funnel_plot(res_single)

p4[[1]]

posted @ 2019-07-22 11:01  橙子牛奶糖  阅读(...)  评论(...编辑  收藏