Title: | MVMR |
---|---|
Description: | An R package for performing multivariable Mendelian randomization analyses. |
Authors: | Wes Spiller [aut, cre] , Jack Bowden [aut] , Eleanor Sanderson [aut] |
Maintainer: | Wes Spiller <[email protected]> |
License: | GPL-3 |
Version: | 0.4 |
Built: | 2024-10-27 21:13:24 UTC |
Source: | https://github.com/WSpiller/MVMR |
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_mvmr(BXGs, BYG, seBXGs, seBYG, RSID)
format_mvmr(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 of class mvmr_format
.
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Sanderson, E., et al., An examination of multivariable Mendelian randomization in the single-sample and two-sample summary data settings. International Journal of Epidemiology, 2019, 48, 3, 713-727. doi:10.1093/ije/dyy262
r_input <- format_mvmr( BXGs = rawdat_mvmr[,c("LDL_beta","HDL_beta")], BYG = rawdat_mvmr$SBP_beta, seBXGs = rawdat_mvmr[,c("LDL_se","HDL_se")], seBYG = rawdat_mvmr$SBP_se, RSID = rawdat_mvmr$SNP) names(r_input) class(r_input)
r_input <- format_mvmr( BXGs = rawdat_mvmr[,c("LDL_beta","HDL_beta")], BYG = rawdat_mvmr$SBP_beta, seBXGs = rawdat_mvmr[,c("LDL_se","HDL_se")], seBYG = rawdat_mvmr$SBP_se, RSID = rawdat_mvmr$SNP) names(r_input) class(r_input)
Fits an IVW multivariable Mendelian randomization model using first order weights.
ivw_mvmr(r_input, gencov = 0)
ivw_mvmr(r_input, gencov = 0)
r_input |
A formatted data frame using the |
gencov |
Calculating heterogeneity statistics 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 |
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.
Sanderson, E., et al., An examination of multivariable Mendelian randomization in the single-sample and two-sample summary data settings. International Journal of Epidemiology, 2019, 48, 3, 713-727. doi:10.1093/ije/dyy262
r_input <- format_mvmr( BXGs = rawdat_mvmr[,c("LDL_beta","HDL_beta")], BYG = rawdat_mvmr$SBP_beta, seBXGs = rawdat_mvmr[,c("LDL_se","HDL_se")], seBYG = rawdat_mvmr$SBP_se, RSID = rawdat_mvmr$SNP) ivw_mvmr(r_input)
r_input <- format_mvmr( BXGs = rawdat_mvmr[,c("LDL_beta","HDL_beta")], BYG = rawdat_mvmr$SBP_beta, seBXGs = rawdat_mvmr[,c("LDL_se","HDL_se")], seBYG = rawdat_mvmr$SBP_se, RSID = rawdat_mvmr$SNP) ivw_mvmr(r_input)
Creates a data.frame with additional class mvmr_format
from an object of class MRMVInput
generated by MendelianRandomization::mr_mvinput
.
mrmvinput_to_mvmr_format(dat)
mrmvinput_to_mvmr_format(dat)
dat |
Object from |
Object of class mvmr_format
, the MVMR format
if (require("MendelianRandomization", quietly = TRUE)) { bx <- as.matrix(rawdat_mvmr[,c("LDL_beta", "HDL_beta")]) bxse <- as.matrix(rawdat_mvmr[,c("LDL_se", "HDL_se")]) dat <- MendelianRandomization::mr_mvinput(bx = bx, bxse = bxse, by = rawdat_mvmr$SBP_beta, byse = rawdat_mvmr$SBP_se, snps = rawdat_mvmr$SNP) dat <- mrmvinput_to_mvmr_format(dat) head(dat) class(dat) }
if (require("MendelianRandomization", quietly = TRUE)) { bx <- as.matrix(rawdat_mvmr[,c("LDL_beta", "HDL_beta")]) bxse <- as.matrix(rawdat_mvmr[,c("LDL_se", "HDL_se")]) dat <- MendelianRandomization::mr_mvinput(bx = bx, bxse = bxse, by = rawdat_mvmr$SBP_beta, byse = rawdat_mvmr$SBP_se, snps = rawdat_mvmr$SNP) dat <- mrmvinput_to_mvmr_format(dat) head(dat) class(dat) }
Note: This function is from the old version of the MVMR package and will be replaced in the future: The gencov argument should be set to zero when using mvmr()
.
mvmr(r_input, gencov, weights)
mvmr(r_input, gencov, weights)
r_input |
A formatted data frame using the |
gencov |
Calculating heterogeneity statistics 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 |
weights |
A value specifying the inverse variance weights used to calculate IVW estimate and Cochran's Q statistic. Currently only first order weights are available ( |
Fits an IVW multivariable Mendelian randomization model using first order weights. The function returns an object of class "MVMRIVW"
, containing regression estimates, estimated heterogeneity as a measure of instrument strength (Q_strength
), and estimated heterogeneity as a measure of instrument validity (Q_valid
).
An object of class "MVMRIVW"
containing the following components:
summary
A summary of the MVMR regression model, including estimated coefficients, standard errors, t-statistics, p-values, and heterogeneity statistics.
coef
The estimated coefficients, their standard errors, t-statistics, and corresponding (two-sided) p-values.
Q_strength
A data frame displaying modified Cochran's Q statistics for assessing instrument strength with respect to each exposure. The Q-statistic increases proportionally with instrument strength, and analogous to univariate MR analyses, a value equal to or greater than 10 can be used as a minimum threshold for instrument strength. Note that for these statistics it is not informative to evaluate p-values.
Q_valid
A modified form of Cochran's Q statistic measuring heterogeneity in causal effect estimates obtained using each genetic variant. Observed heterogeneity is indicative of a violation of the exclusion restriction assumption in MR (validity), which can result in biased effect estimates.
p_valid
A p-value corresponding to the heterogeneity measure for instrument validity (Q_valid
)
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Sanderson, E., et al., An examination of multivariable Mendelian randomization in the single-sample and two-sample summary data settings. International Journal of Epidemiology, 2019, 48, 3, 713-727. doi:10.1093/ije/dyy262
# Example using format_mvmr formatted data r_input <- format_mvmr( BXGs = rawdat_mvmr[,c("LDL_beta","HDL_beta")], BYG = rawdat_mvmr$SBP_beta, seBXGs = rawdat_mvmr[,c("LDL_se","HDL_se")], seBYG = rawdat_mvmr$SBP_se, RSID = rawdat_mvmr$SNP) mvmr(r_input, 0, 1) # Example using MRMVInput formatted data from the MendelianRandomization package if (require("MendelianRandomization", quietly = TRUE)) { bx <- as.matrix(rawdat_mvmr[,c("LDL_beta", "HDL_beta")]) bxse <- as.matrix(rawdat_mvmr[,c("LDL_se", "HDL_se")]) dat <- MendelianRandomization::mr_mvinput(bx = bx, bxse = bxse, by = rawdat_mvmr$SBP_beta, byse = rawdat_mvmr$SBP_se, snps = rawdat_mvmr$SNP) mvmr(r_input = r_input, gencov = 0, weights = 1) }
# Example using format_mvmr formatted data r_input <- format_mvmr( BXGs = rawdat_mvmr[,c("LDL_beta","HDL_beta")], BYG = rawdat_mvmr$SBP_beta, seBXGs = rawdat_mvmr[,c("LDL_se","HDL_se")], seBYG = rawdat_mvmr$SBP_se, RSID = rawdat_mvmr$SNP) mvmr(r_input, 0, 1) # Example using MRMVInput formatted data from the MendelianRandomization package if (require("MendelianRandomization", quietly = TRUE)) { bx <- as.matrix(rawdat_mvmr[,c("LDL_beta", "HDL_beta")]) bxse <- as.matrix(rawdat_mvmr[,c("LDL_se", "HDL_se")]) dat <- MendelianRandomization::mr_mvinput(bx = bx, bxse = bxse, by = rawdat_mvmr$SBP_beta, byse = rawdat_mvmr$SBP_se, snps = rawdat_mvmr$SNP) mvmr(r_input = r_input, gencov = 0, weights = 1) }
Uses an external phenotypic covariance matrix and summary data to estimate covariance matrices for estimated effects of individual genetic variants on each exposure. The phenotypic covariance matrix should be constructed using standardised phenotype measures. The function returns a number of covariance matrices equal to the number of SNPs, where SNP and row numbers reference ordered exposures.
phenocov_mvmr(Pcov, seBXGs)
phenocov_mvmr(Pcov, seBXGs)
Pcov |
A phenotypic matrix using exposures, constructed using individual level exposure data. Columns should be ordered by exposure so as to match |
seBXGs |
A matrix containing standard errors corresponding in relation to the gene-exposure association for each SNP. |
A list of covariance matrices with respect to each genetic variant, retaining the ordering in seBXGs
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Sanderson, E., et al., An examination of multivariable Mendelian randomization in the single-sample and two-sample summary data settings. International Journal of Epidemiology, 2019, 48, 3, 713-727. doi:10.1093/ije/dyy262
## Not run: phenocov_mvmr(Pcov, summarydata[,c(3,4)]) ## End(Not run)
## Not run: phenocov_mvmr(Pcov, summarydata[,c(3,4)]) ## End(Not run)
Calculates modified form of Cochran's Q statistic measuring heterogeneity in causal effect estimates obtained using each genetic variant. Observed heterogeneity is indicative of a violation of the exclusion restriction assumption in MR (validity), which can result in biased effect estimates.
The function takes a formatted dataframe as an input, obtained using the function format_mvmr
. Additionally, covariance matrices
for estimated effects of individual genetic variants on each exposure can also be provided. These can be estimated using external data by
applying the snpcov_mvmr
or phenocov_mvmr
functions, are input manually. The function returns a dataframe including the conditional
Q-statistic for instrument validity, and a corresponding P-value.
pleiotropy_mvmr(r_input, gencov = 0)
pleiotropy_mvmr(r_input, gencov = 0)
r_input |
A formatted data frame using the |
gencov |
Calculating heterogeneity statistics 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 |
A Q-statistic for instrument validity and the corresponding p-value
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Sanderson, E., et al., An examination of multivariable Mendelian randomization in the single-sample and two-sample summary data settings. International Journal of Epidemiology, 2019, 48, 3, 713-727. doi:10.1093/ije/dyy262
## Not run: pleiotropy_mvmr(r_input, covariances) ## End(Not run)
## Not run: pleiotropy_mvmr(r_input, covariances) ## End(Not run)
Fits a multivariable Mendelian randomization model adjusting for weak instruments. The functions requires a formatted dataframe using the format_mvmr
function, as well a phenotypic correlation matrix pcor
. This should be obtained from individual level
phenotypic data, or constructed as a correlation matrix where correlations have previously been reported. Confidence intervals are calculated using a non-parametric bootstrap.
By default, standard errors are not produced but can be calculated by setting se = TRUE
. The number of bootstrap iterations is specified using the iterations
argument.
Note that calculating confidence intervals at present can take a substantial amount of time.
qhet_mvmr(r_input, pcor, CI, iterations)
qhet_mvmr(r_input, pcor, CI, iterations)
r_input |
A formatted data frame using the |
pcor |
A phenotypic correlation matrix including the correlation between each exposure included in the MVMR analysis. |
CI |
Indicates whether 95 percent confidence intervals should be calculated using a non-parametric bootstrap. |
iterations |
Specifies number of bootstrap iterations for calculating 95 percent confidence intervals. |
An dataframe containing effect estimates with respect to each exposure.
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Sanderson, E., et al., An examination of multivariable Mendelian randomization in the single-sample and two-sample summary data settings. International Journal of Epidemiology, 2019, 48, 3, 713-727. doi:10.1093/ije/dyy262
## Not run: qhet_mvmr(r_input, pcor, CI = TRUE, iterations = 1000) ## End(Not run)
## Not run: qhet_mvmr(r_input, pcor, CI = TRUE, iterations = 1000) ## End(Not run)
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, and corresponding standard errors.
rawdat_mvmr
rawdat_mvmr
A data frame with 145 rows and 9 variables. A full description of the data is available
by using the command vignette("MVMR")
.
rawdat_mvmr
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Uses individual level genetic and exposure data to generate covariance matrices for estimated effects of individual genetic variants on each exposure. The function returns a number of covariance matrices equal to the number of SNPs, where SNP and row numbers reference ordered exposures.
snpcov_mvmr(Gs, Xs)
snpcov_mvmr(Gs, Xs)
Gs |
A matrix or dataframe containing genetic instrument measures. Columns should indicate genetic variant number, with rows representing an observed measure of the genetic variant. |
Xs |
A matrix or dataframe containing exposure measures. Columns should indicate exposure number, with rows representing an observed measure for the given exposure. |
A list of covariance matrices with respect to each genetic variant, retaining the ordering in Gs
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Sanderson, E., et al., An examination of multivariable Mendelian randomization in the single-sample and two-sample summary data settings. International Journal of Epidemiology, 2019, 48, 3, 713-727. doi:10.1093/ije/dyy262
## Not run: snpcov_mvmr(data[,1:10], data[,11:13]) ## End(Not run)
## Not run: snpcov_mvmr(data[,1:10], data[,11:13]) ## End(Not run)
Calculates the conditional F-statistic for assessing instrument strength in two sample summary multivariable Mendelian randomization.
The function takes a formatted dataframe as an input, obtained using the function format_mvmr
. Additionally, covariance matrices
for estimated effects of individual genetic variants on each exposure can also be provided. These can be estimated using external data by
applying the snpcov_mvmr
or phenocov_mvmr
functions, are input manually. The function returns a dataframe including the conditional
F-statistic with respect to each exposure. A conventional F-statistic threshold of 10 is used in basic assessments of instrument strength.
strength_mvmr(r_input, gencov = 0)
strength_mvmr(r_input, gencov = 0)
r_input |
r_input A formatted data frame using the |
gencov |
Calculating heterogeneity statistics 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 |
A dataframe showing the conditional F-statistic for each exposure.
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Sanderson, E., et al., An examination of multivariable Mendelian randomization in the single-sample and two-sample summary data settings. International Journal of Epidemiology, 2018, 48, 3, 713-727. Available from: doi:10.1093/ije/dyy262
## Not run: strength_mvmr(data, covariances) ## End(Not run)
## Not run: strength_mvmr(data, covariances) ## End(Not run)
Calculates the conditional F-statistic for assessing instrument strength in two sample summary multivariable Mendelian randomization through minimisation of Q-statistics.
The function takes a formatted dataframe as an input, obtained using the function format_mvmr
. Additionally, covariance matrices
for estimated effects of individual genetic variants on each exposure can also be provided. These can be estimated using external data by
applying the snpcov_mvmr
or phenocov_mvmr
functions, are input manually. The function returns a dataframe including the conditional
F-statistic with respect to each exposure. A conventional F-statistic threshold of 10 is used in basic assessments of instrument strength.
strhet_mvmr(r_input, gencov)
strhet_mvmr(r_input, gencov)
r_input |
A formatted data frame using the |
gencov |
Calculating heterogeneity statistics 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 |
A dataframe showing the conditional F-statistic for each exposure.
Wes Spiller; Eleanor Sanderson; Jack Bowden.
Sanderson, E., et al., An examination of multivariable Mendelian randomization in the single-sample and two-sample summary data settings. International Journal of Epidemiology, 2019, 48, 3, 713-727. doi:10.1093/ije/dyy262
## Not run: strhet_mvmr(r_input, covariances) ## End(Not run)
## Not run: strhet_mvmr(r_input, covariances) ## End(Not run)