Package 'RMVMR'

Title: RMVMR
Description: An R package for performing radial multivariable Mendelian randomization analyses.
Authors: Wes Spiller [aut, cre] , Jack Bowden [aut] , Eleanor Sanderson [aut] , Tom Palmer [aut]
Maintainer: Wes Spiller <[email protected]>
License: GPL-2
Version: 0.3
Built: 2024-09-26 05:29:49 UTC
Source: https://github.com/WSpiller/RMVMR

Help Index


format_rmvmr

Description

Reads in summary data. Checks and organises columns for use in calculating multivariable Mendelian Randomization analyses. Where variant IDs are not provided, a vector is generated for variant identification.

Usage

format_rmvmr(BXGs, BYG, seBXGs, seBYG, RSID)

Arguments

BXGs

A matrix containing beta-coefficient values for genetic associations with the each exposure. Columns should indicate exposure number, with rows representing estimates for a given genetic variant.

BYG

A numeric vector of beta-coefficient values for genetic associations with the outcome.

seBXGs

A matrix containing standard errors corresponding to the matrix of beta-coefficients BXGs.

seBYG

A numeric vector of standard errors corresponding to the beta-coefficients BYG.

RSID

A vector of names for genetic variants included in the analysis. If variant IDs are not provided (RSID="NULL"), a vector of ID numbers will be generated.

Value

A formatted data frame with additional classes rmvmr_format and mvmr_format

Author(s)

Wes Spiller; Eleanor Sanderson; Jack Bowden.

References

Spiller, W., et al., Estimating and visualising multivariable Mendelian randomization analyses within a radial framework. Forthcoming.

Examples

f.data <- format_rmvmr(
 BXGs = rawdat_rmvmr[,c("ldl_beta","hdl_beta","tg_beta")],
 BYG = rawdat_rmvmr$sbp_beta,
 seBXGs = rawdat_rmvmr[,c("ldl_se","hdl_se","tg_se")],
 seBYG = rawdat_rmvmr$sbp_se,
 RSID = rawdat_rmvmr$snp)
names(f.data)
class(f.data)

ivw_rmvmr

Description

Fits a radial IVW multivariable Mendelian randomization model using first order weights.

Usage

ivw_rmvmr(r_input, summary = TRUE)

Arguments

r_input

A formatted data frame using the format_rmvmr function or an object of class MRMVInput from MendelianRandomization::mr_mvinput

summary

A logical argument (TRUE or FALSE) indicating whether a summary of results should be presented (default= TRUE).

Value

An dataframe containing MVMR results, including estimated coefficients, their standard errors, t-statistics, and corresponding (two-sided) p-values.

Author(s)

Wes Spiller; Eleanor Sanderson; Jack Bowden.

References

Spiller, W., et al., Estimating and visualising multivariable Mendelian randomization analyses within a radial framework. Forthcoming.

Examples

# Example using format_rmvmr formatted data
f.data <- format_rmvmr(
    BXGs = rawdat_rmvmr[,c("ldl_beta","hdl_beta","tg_beta")],
    BYG = rawdat_rmvmr$sbp_beta,
    seBXGs = rawdat_rmvmr[,c("ldl_se","hdl_se","tg_se")],
    seBYG = rawdat_rmvmr$sbp_se,
    RSID = rawdat_rmvmr$snp)
ivw_rmvmr(f.data, TRUE)

# Example using MRMVInput formatted data from the
#  MendelianRandomization package
if (require("MendelianRandomization", quietly = TRUE)) {
bx <- as.matrix(rawdat_rmvmr[,c("ldl_beta", "hdl_beta", "tg_beta")])
bxse <- as.matrix(rawdat_rmvmr[,c("ldl_se", "hdl_se", "tg_se")])
dat <- MendelianRandomization::mr_mvinput(bx = bx,
                                          bxse = bxse,
                                          by = rawdat_rmvmr$sbp_beta,
                                          byse = rawdat_rmvmr$sbp_se,
                                          snps = rawdat_rmvmr$snp)
ivw_rmvmr(r_input = dat, summary = TRUE)
}

Convert an object of class MRMVInput from the MendelianRandomization package to the RMVMR rmvmr_format class

Description

Creates a data.frame with additional classes rmvmr_format and mvmr_format from an object of class MRMVInput generated by MendelianRandomization::mr_mvinput.

Usage

mrmvinput_to_rmvmr_format(dat)

Arguments

dat

Object from MendelianRandomization::mr_mvinput.

Value

data.frame with additoinal classes rmvmr_format, the RMVMR format, and mvmr_format.

Examples

if (require("MendelianRandomization", quietly = TRUE)) {
bx <- as.matrix(rawdat_rmvmr[,c("ldl_beta", "hdl_beta")])
bxse <- as.matrix(rawdat_rmvmr[,c("ldl_se", "hdl_se")])
dat <- MendelianRandomization::mr_mvinput(bx = bx,
                                          bxse = bxse,
                                          by = rawdat_rmvmr$sbp_beta,
                                          byse = rawdat_rmvmr$sbp_se,
                                          snps = rawdat_rmvmr$snp)
dat <- mrmvinput_to_rmvmr_format(dat)
head(dat)
class(dat)
}

pleiotropy_rmvmr

Description

Generates Q-statistics quantifying the degree of heterogeneity in univariate Radial MR analyses applying a correction using the output from ivw_rmvmr. The function returns two data frames. The first data frame includes the global Q-statistic for each exposure after applying a correction, as well as a corresponding p-value. The second data frame contains the individual Q-statistic for each SNP in the corrected univariate analyses, relative to the exposure given in column exposure.

Usage

pleiotropy_rmvmr(r_input, rmvmr)

Arguments

r_input

A formatted data frame using the format_rmvmr function or an object of class MRMVInput from MendelianRandomization::mr_mvinput

rmvmr

An object containing the output from the ivw_rmvmr function of class IVW_RMVMR.

Value

An object of class "RMVMR_Q" containing the following components:

gq

A data frame containing the global Q-statistic and p-value after applying a correction for each exposure

qdat

A data frame containing the individual Q-statistic and p-value for each SNP after applying a correction for each exposure

Author(s)

Wes Spiller; Eleanor Sanderson; Jack Bowden.

References

Spiller, W., et al., Estimating and visualising multivariable Mendelian randomization analyses within a radial framework. Forthcoming.

Examples

f.data <- format_rmvmr(
    BXGs = rawdat_rmvmr[,c("ldl_beta","hdl_beta","tg_beta")],
    BYG = rawdat_rmvmr$sbp_beta,
    seBXGs = rawdat_rmvmr[,c("ldl_se","hdl_se","tg_se")],
    seBYG = rawdat_rmvmr$sbp_se,
    RSID = rawdat_rmvmr$snp)
rmvmr_output <- ivw_rmvmr(f.data, FALSE)
q_object <- pleiotropy_rmvmr(f.data, rmvmr_output)
q_object$gq
head(q_object$qdat)

plot_rmvmr

Description

Generates two radial multivariable Mendelian randomization (MVMR) plots. The first plot shows shows the estimated direct effect for each exposure obtained by fitting a radial MVMR model. Each data point shows the square root weighting for each SNP on the x-axis, and product of the ratio estimate and square root weighting for each SNP on the y-axis. These values are obtained by performing a univariate radial MR analysis for each exposure using the SNPs displayed, specifically through use of the RadialMR::ivw_radial function. Only SNPs strongly associated with the corresponding exposure are used, such that their first stage F-statistic is greater than 10. The second plot applies a correction to each ratio estimate. In both plots, the distance of each observation from the corresponding regression line is proportional to the contribution of that SNP towards global heterogeneity.

Usage

plot_rmvmr(r_input, rmvmr)

Arguments

r_input

A formatted data frame using the format_rmvmr function or an object of class MRMVInput from MendelianRandomization::mr_mvinput

rmvmr

An object containing the output from the ivw_rmvmr function of class IVW_RMVMR.

Value

An object of class "RMVMR_plot" containing the following components:

p1

A radial MVMR plot without correction

p2

A radial MVMR plot with correction

Author(s)

Wes Spiller; Eleanor Sanderson; Jack Bowden.

References

Spiller, W., et al., Estimating and visualising multivariable Mendelian randomization analyses within a radial framework. Forthcoming.

Examples

f.data <- format_rmvmr(
    BXGs = rawdat_rmvmr[,c("ldl_beta","hdl_beta","tg_beta")],
    BYG = rawdat_rmvmr$sbp_beta,
    seBXGs = rawdat_rmvmr[,c("ldl_se","hdl_se","tg_se")],
    seBYG = rawdat_rmvmr$sbp_se,
    RSID = rawdat_rmvmr$snp)
rmvmr_output <- ivw_rmvmr(f.data, FALSE)
plot_object <- plot_rmvmr(f.data, rmvmr_output)
plot_object$p1
plot_object$p2

Raw multivariable MR summary data using lipid fractions as exposures and systolic blood pressure as an outcome.

Description

A dataset containing summary data on 145 genetic variants associated with either low-density lipoprotein (LDL), high-density lipoprotein (HDL), or triglycerides. Data includes variant rsid numbers, associations with each lipid fraction, the associations between genetic variants and systolic blood pressure (SBP), and corresponding standard errors.

Usage

rawdat_rmvmr

Format

A data frame with 145 rows and 9 variables. Specifically this includes the following information:

snp

The identification number for each variant

ldl_beta

The association estimate for the genetic variant obtained by regressing LDL-C upon the genetic variant

hdl_beta

The association estimate obtained by regressing HDL-C upon the genetic variant

tg_beta

The association estimate obtained by regressing triglycerides upon the genetic variant

sbp_beta

The association estimate for SBP obtained by regressing SBP upon the genetic variant

ldl_se

The standard error corresponding to association estimate ldl_beta

hdl_se

The standard error corresponding to association estimate hdl_beta

tg_se

The standard error corresponding to association estimate tg_beta

sbp_se

The standard error corresponding to association estimate sbp_beta

Details

rawdat_rmvmr

Author(s)

Wes Spiller; Eleanor Sanderson; Jack Bowden.

Source

Examples

head(rawdat_rmvmr)

strength_rmvmr

Description

Calculates Q-statistics quantifying instrument strength. Each exposure is treated as an outcome sequentially, fitting the remaining exposures within a radial MVMR model. High Q-statistics indicate a high instrument strength, comparable to the Q_x statistic in conventional MVMR analyses. The function outputs a list of plots, global Q-statistics, and individual Q-contributions indexed by the exposure number ordered using the format_rmvmr function. Named exposures in each list refer to the remaining exposures in the strength RMVMR model.

Usage

strength_rmvmr(r_input, gencov = 0)

Arguments

r_input

A formatted data frame using the format_rmvmr function or an object of class MRMVInput from MendelianRandomization::mr_mvinput

gencov

Calculating heterogeneity statistics using the MVMR package requires the covariance between the effect of the genetic variants on each exposure to be known. This can either be estimated from individual level data, be assumed to be zero, or fixed at zero using non-overlapping samples of each exposure GWAS. A value of 0 is used by default.

Value

An object of class "S_RMVMR" containing the following components:

plot

A list containing plots for RMVMR analyses regressing each exposure sequentially upon remaining exposures in the r_input object. Plots are indexed by the exposure number serving as the outcome for the RMVMR analysis

qstat

A list containing global Q-statistics for RMVMR analyses regressing each exposure sequentially upon remaining exposures in the r_input object. Indexing follows that of plots and p-values for global heterogeneity are provided

qall

A list containing the individual Q-statistics and data for RMVMR analyses regressing each exposure sequentially upon remaining exposures in the r_input object. Indexing follows that of plots

Author(s)

Wes Spiller; Eleanor Sanderson; Jack Bowden.

References

Spiller, W., et al., Estimating and visualising multivariable Mendelian randomization analyses within a radial framework. Forthcoming.

Examples

f.data <- format_rmvmr(
    BXGs = rawdat_rmvmr[,c("ldl_beta","hdl_beta","tg_beta")],
    BYG = rawdat_rmvmr$sbp_beta,
    seBXGs = rawdat_rmvmr[,c("ldl_se","hdl_se","tg_se")],
    seBYG = rawdat_rmvmr$sbp_se,
    RSID = rawdat_rmvmr$snp)
output <- strength_rmvmr(f.data)

# The following shows the strength plot and Q statistics for exposure 2,
# regressing exposure 2 upon exposures 1 and 3 (which are labeled exposure 1
# and exposure 2 based on ordering in the RMVMR model).

output$plot[[2]]
output$qstat[[2]]