knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The R package mrsensemakr
implements sensitivity analysis tools for Mendelian Randomization, as discussed in Cinelli et al (2020). Robust Mendelian randomization in the presence of residual population stratification, batch effects and horizontal pleiotropy.
To install the development version on GitHub make sure you have the R package devtools
installed. Also make sure to have the latest version of sensemakr
(link) installed.
# install.packages("devtools") devtools::install_github("carloscinelli/sensemakr") devtools::install_github("carloscinelli/mrsensemakr")
CRAN version coming soon.
## loads package library(mrsensemakr) ## simulated data example data("sim_data") ## create vectors indicating variable names in the data outcome <- "out.trait" # name of outcome trait exposure <- "exp.trait" # name of exposure trait instrument <- "prs" # genetic instrument (e.g, polygenic risk score) age.sex <- c("age", "sex") # age and sex variables (if applicable) alc.smok <- c("alcohol", "smoking") # putative pleoitropic vars. pcs <- paste0("pc", 1:20) # first 20 principal components pc1 ... pc20 ## runs MR sensitivity analysis mr.sense <- mr_sensemakr(outcome = outcome, exposure = exposure, instrument = instrument, covariates = c(age.sex, alc.smok, pcs), data = sim_data, benchmark_covariates = list(alc.smok = alc.smok, pcs = pcs)) ## print results mr.sense ## sensitivity contour plots plot(mr.sense, benchmark_covariates = list(alc.smok = alc.smok, pcs = pcs), k = list(alc.smok = 1, pcs = 1))
Code to reproduce the simulations of the paper can be found in the vignettes folder.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.