mr_sensemakr: MR-sensemakr

Description Usage Arguments Examples

View source: R/mrsensemakr.R

Description

MR-sensemakr

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## 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))

carloscinelli/mrsensemakr documentation built on Nov. 2, 2021, 4:22 p.m.