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-10-27 21:13:55 UTC |
Source: | https://github.com/WSpiller/RMVMR |
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.
format_rmvmr(BXGs, BYG, seBXGs, seBYG, RSID)
format_rmvmr(BXGs, BYG, seBXGs, seBYG, RSID)
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 |
seBYG |
A numeric vector of standard errors corresponding to the beta-coefficients |
RSID |
A vector of names for genetic variants included in the analysis. If variant IDs are not provided ( |
A formatted data frame with additional classes rmvmr_format
and mvmr_format
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Spiller, W., et al., Estimating and visualising multivariable Mendelian randomization analyses within a radial framework. Forthcoming.
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)
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)
Fits a radial IVW multivariable Mendelian randomization model using first order weights.
ivw_rmvmr(r_input, summary = TRUE)
ivw_rmvmr(r_input, summary = TRUE)
r_input |
A formatted data frame using the |
summary |
A logical argument ( |
An dataframe containing MVMR results, including estimated coefficients, their standard errors, t-statistics, and corresponding (two-sided) p-values.
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Spiller, W., et al., Estimating and visualising multivariable Mendelian randomization analyses within a radial framework. Forthcoming.
# 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) }
# 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) }
Creates a data.frame with additional classes rmvmr_format
and mvmr_format
from an object of class MRMVInput
generated by MendelianRandomization::mr_mvinput
.
mrmvinput_to_rmvmr_format(dat)
mrmvinput_to_rmvmr_format(dat)
dat |
Object from |
data.frame with additoinal classes rmvmr_format
, the RMVMR format, and mvmr_format
.
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) }
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) }
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
.
pleiotropy_rmvmr(r_input, rmvmr)
pleiotropy_rmvmr(r_input, rmvmr)
r_input |
A formatted data frame using the |
rmvmr |
An object containing the output from the |
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
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Spiller, W., et al., Estimating and visualising multivariable Mendelian randomization analyses within a radial framework. Forthcoming.
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)
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)
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.
plot_rmvmr(r_input, rmvmr)
plot_rmvmr(r_input, rmvmr)
r_input |
A formatted data frame using the |
rmvmr |
An object containing the output from the |
An object of class "RMVMR_plot"
containing the following components:
p1
A radial MVMR plot without correction
p2
A radial MVMR plot with correction
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Spiller, W., et al., Estimating and visualising multivariable Mendelian randomization analyses within a radial framework. Forthcoming.
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
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
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.
rawdat_rmvmr
rawdat_rmvmr
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
rawdat_rmvmr
Wes Spiller; Eleanor Sanderson; Jack Bowden.
head(rawdat_rmvmr)
head(rawdat_rmvmr)
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.
strength_rmvmr(r_input, gencov = 0)
strength_rmvmr(r_input, gencov = 0)
r_input |
A formatted data frame using the |
gencov |
Calculating heterogeneity statistics using the |
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
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Spiller, W., et al., Estimating and visualising multivariable Mendelian randomization analyses within a radial framework. Forthcoming.
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]]
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]]