mr_input: Inputting and formatting data for use in causal estimation

View source: R/new-methods.R

mr_inputR Documentation

Inputting and formatting data for use in causal estimation

Description

The mr_input function is required for inputting and formatting data for use in any of the estimation functions provided in this package. The MRInput class outputted by the function can also be viewed graphically using the mr_plot function.

Usage

mr_input(
  bx = 0,
  bxse = 0,
  by = 0,
  byse = 0,
  correlation = matrix(),
  exposure = "exposure",
  outcome = "outcome",
  snps = "snp",
  effect_allele = NA,
  other_allele = NA,
  eaf = NA
)

Arguments

bx

A numeric vector of beta-coefficient values for genetic associations with the first variable (often referred to as the exposure, risk factor, or modifiable phenotype).

bxse

The standard errors associated with the beta-coefficients bx.

by

A numeric vector of beta-coefficient values for genetic associations with the second variable (often referred to as the outcome). For a disease outcome, the beta coefficients are log odds estimates from logistic regression analyses.

byse

The standard errors associated with the beta-coefficients in by.

correlation

The matrix of correlations between genetic variants. If this variable is not provided, then we assume that genetic variants are uncorrelated.

exposure

The name of the exposure variable.

outcome

The name of the outcome variable.

snps

The names of the genetic variants (SNPs) included in the analysis. The inputs exposure, outcome, and snps are not required, but may be useful for keeping track of various MRInput objects. They are also used by the mr_plot function.

effect_allele

The name of the effect allele for each SNP. The beta-coefficients are the associations with the exposure and outcome per additional copy of the effect allele.

other_allele

The name of the non-effect allele.

eaf

The expected allele frequencies (numeric). The slots effect_allele, other_allele, and eaf are neither required, nor currently used in the MendelianRandomization package. They are included for future compatibility with the MR-Base suite of functions.

Details

The beta-coefficients are assumed to be estimated for uncorrelated (independent) genetic variants, although a correlation matrix can be specified if the variants are correlated in their distributions. We also assume that the beta-coefficients for associations with the exposure and with the outcome are uncorrelated (corresponding to a two-sample Mendelian randomization analysis), although correlation between associations with the exposure and with the outcome generally have little impact on causal estimates or standard errors.

If the four variables are not all the same length, then an error message will be reported. The analyses will still try to run, but the output may be misleading. However, in some analyses (for example, the standard IVW and MR-Egger methods), the values of bxse are not used in the analysis, and can therefore safely be omitted (provided that the other variables are correctly labelled).

Value

An MRInput object containing:

betaX

The genetic associations with the exposure.

betaXse

The corresponding standard errors.

betaY

The genetic associations with the outcome.

betaYse

The corresponding standard errors.

correlation

The matrix of genetic correlations.

exposure

A character string giving the name given to the exposure.

outcome

A character string giving the name given to the outcome.

snps

A vector of character strings with the names of the genetic variants.

effect_allele

A vector of character strings with the names of the effect alleles.

other_allele

A vector of character strings with the names of the non-effect alleles.

eaf

A numeric vector with the effect allele frequencies.

See Also

extract.pheno.csv() for a description of how an MRInput object can be extracted from PhenoScanner (http://www.phenoscanner.medschl.cam.ac.uk/).


MendelianRandomization documentation built on Aug. 9, 2023, 1:05 a.m.