knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
R package for Mendelian randomization with mixIE methods proposed in this paper: Lin, Z., Deng, Y., & Pan, W. (2021). Combining the strengths of inverse-variance weighting and Egger regression in Mendelian randomization using a mixture of regressions model. PLoS genetics, 17(11), e1009922..
Install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("ZhaotongL/mixIE")
Here is an example which shows how to apply mixIE methods to make inference about the causal effect from Fast Glucose (FG) to Type-2 Diabetes (T2D)
library(mixIE) library(ggpubr) head(FG_T2D)
Now we perform mixIE-MA with the outcome sample size 69033 and reorientating IVs with all positive associations with the exposure.
set.seed(1) mixIE_MA_result = mixIE_MA(b_exp=FG_T2D$beta_hat_1,b_out=FG_T2D$beta_hat_2, se_exp=FG_T2D$seb1,se_out = FG_T2D$seb2, n=69033,flip=1) mixIE_MA_result
We can also obtain the results for mixIE-MA when directly implementing mixIE-MA-DP:
set.seed(1) mixIE_MA_DP_result = mixIE_MA_DP(b_exp=FG_T2D$beta_hat_1,b_out=FG_T2D$beta_hat_2, se_exp=FG_T2D$seb1,se_out = FG_T2D$seb2, n=69033,flip=1) mixIE_MA_DP_result
We can obtain the diagnostic plots of mixIE-MA-DP by setting diagnostic_plot=TRUE
:
set.seed(1) mixIE_MA_DP_result = mixIE_MA_DP(b_exp=FG_T2D$beta_hat_1,b_out=FG_T2D$beta_hat_2, se_exp=FG_T2D$seb1,se_out = FG_T2D$seb2, n=69033,flip=1, diagnostic_plot = TRUE, point_size = 1.3) g1=ggarrange(mixIE_MA_DP_result$scatter_og.plot, mixIE_MA_DP_result$scatter_dp.plot,labels =c("A:mixIE-MA", "B:mixIE-MA-DP"), common.legend=TRUE,legend = 'bottom',font.label = list(size = 8)) g2=ggarrange(mixIE_MA_DP_result$iv_barplot, mixIE_MA_DP_result$est_hist,labels =c("C", "D"), legend = 'bottom',font.label = list(size = 8)) ggarrange(g1,g2,nrow = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.