Package 'mrsensemakr'

Title: Sensitivity Analysis Tools for Mendelian Randomization
Description: The R package mrsensemakr implements sensitivity analysis tools for Mendelian Randomization.
Authors: Carlos Cinelli,
Maintainer: Carlos Cinelli <[email protected]>
License: GPL-3
Version: 0.3
Built: 2024-10-05 03:25:36 UTC
Source: https://github.com/carloscinelli/mrsensemakr

Help Index


MR-sensemakr

Description

MR-sensemakr

Usage

mr_sensemakr(
  outcome,
  exposure,
  instrument,
  covariates = NULL,
  data,
  benchmark_covariates = NULL,
  k = 1,
  alpha = 0.05
)

Arguments

outcome

A character vector with the name of the outcome trait.

exposure

A character vector with the name of the exposure trait.

instrument

A character vector with the name of the genetic instrument.

covariates

A character vector with the name of the control covariates, such as age, sex, genomic principal components, batch effect dummies and putative pleiotropic pathways.

data

An object of the class data.frame containing the variables used in the analysis.

benchmark_covariates

Covariates for benchmarking. Must be a subset of the covariates argument. The user has two options: (i) character vector of the names of covariates that will be used to bound the plausible strength of the unobserved confounders. Each variable will be considered separately; (ii) a named list with character vector names of covariates that will be used, as a group, to bound the plausible strength of the unobserved confounders. The names of the list will be used for the benchmark labels.

k

numeric vector. Parameterizes how many times stronger residual biases are related to the treatment and the outcome in comparison to the observed benchmark covariates.

alpha

significance level

Examples

## 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 = 25,
              pcs = 35))

Simulated Data

Description

Simulated Data

Format

A data frame with 200,000 observations and 27 variables.