Title: | RadialMR |
---|---|
Description: | A package for implementing radial inverse variance weighted and MR-Egger methods. |
Authors: | Wes Spiller [aut, cre] , Jack Bowden [aut] , Tom Palmer [aut] |
Maintainer: | Wes Spiller <[email protected]> |
License: | GPL-3 |
Version: | 1.1 |
Built: | 2024-10-29 13:27:42 UTC |
Source: | https://github.com/WSpiller/RadialMR |
A dataset containing summary data GWAS data for 185 independent SNPs with respect to lipid fractions and coronary heart disease (CHD), previously published in Do et al (2013). Lipid fractions include low-density lipoprotein (LDL-C),high-density lipoprotein (HDL-C), and triglycerides, with association estimates obtained from the Global Lipids Genetics Consortium (GLGC) (Willer et al, 2013). Summary data for CHD was obtained from the CARDIoGRAM study (Schunkert et al, 2011). Association estimates were obtained by regressing each phenotype upon the genetic variant and additional adjusted covariates, with links to further information related to each study presented below.
data_radial
data_radial
A data frame with 185 rows and 21 variables. Specifically this includes the following information:
rsid
The identification number for each variant
a1
The reference allele for each variant
a2
The other allele for each variant
chr
The chromosome number in which each variant is located
pos
The genomic position for the genetic variant relative to chromosome number
ldlcbeta
The association estimate for the genetic variant obtained by regressing LDL-C upon the genetic variant
hdlcbeta
The association estimate obtained by regressing HDL-C upon the genetic variant
tgbeta
The association estimate obtained by regressing triglycerides upon the genetic variant
chdbeta
The association estimate for CHD obtained by regressing CHD upon the genetic variant
ldlcp2
The p-value corresponding to association estimate ldlcbeta
hdlcp2
The p-value corresponding to association estimate hdlcbeta
tgp2
The p-value corresponding to association estimate tgbeta
chdp2
The p-value corresponding to association estimate chdbeta
ldlcz
The z-score corresponding to association estimate ldlcbeta
ldlcse
The standard error corresponding to association estimate ldlcbeta
hdlcz
The z-score corresponding to association estimate hdlcbeta
hdlcse
The standard error corresponding to association estimate hdlcbeta
tgz
The z-score corresponding to association estimate tgbeta
tgse
The standard error corresponding to association estimate tgbeta
chdz
The z-score corresponding to association estimate chdbeta
chdse
The standard error corresponding to association estimate chdbeta
data_radial
Wes Spiller; Jack Bowden; Tom Palmer.
head(data_radial)
head(data_radial)
Fits a radial MR-Egger model using first order, second order, or modified second order weights. Outliers are identified using a significance threshold specified by the user. The function returns an object of class "egger"
, containing regression estimates, a measure of total heterogeneity using Rucker's Q statistic, the individual contribution to overall heterogeneity of each variant, and a data frame for use in constructing the radial plot.
egger_radial(r_input, alpha, weights, summary)
egger_radial(r_input, alpha, weights, summary)
r_input |
A formatted data frame using the |
alpha |
A value specifying the statistical significance threshold for identifying outliers ( |
weights |
A value specifying the inverse variance weights used to calculate the MR-Egger estimate and Rucker's Q statistic. By default modified second order weights are used, but one can choose to select first order ( |
summary |
A logical argument ( |
An object of class "egger"
containing the following components:
coef
A matrix giving the intercept and slope coefficient, corresponding standard errors, t-statistics, and (two-sided) p-values.
qstatistic
Rucker's Q statistic for overall heterogeneity.
df
Degrees of freedom. This is equal to the number of variants -2 when fitting the radial MR-Egger model.
outliers
A data frame containing variants identified as outliers, with respective Q statistics, chi-squared tests and SNP identification.
data
A data frame containing containing SNP IDs, inverse variance weights, the product of the inverse variance weight and ratio estimate for each variant, contribution to overall heterogeneity with corresponding p-value, and a factor indicator showing outlier status.
confint
A vector giving lower and upper confidence limits for the radial MR-Egger effect estimate.
Wes Spiller; Jack Bowden; Tom Palmer.
Bowden, J., et al., Improving the visualization, interpretation and analysis of two-sample summary data Mendelian randomization via the Radial plot and Radial regression. International Journal of Epidemiology, 2018. 47(4): p. 1264-1278.
# Example using format_radial data ldl.dat <- data_radial[data_radial[,10]<5e-8,] ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9], ldl.dat[,15], ldl.dat[,21], ldl.dat[,1]) egger_radial(ldl.fdat, 0.05, 1, TRUE) # Example using TwoSampleMR format data ## Not run: if (require("TwoSampleMR", quietly = TRUE)) { # Example with one exposure-outcome pair bmi_exp_dat <- TwoSampleMR::extract_instruments(outcomes = 'ieu-a-2') chd_out_dat <- TwoSampleMR::extract_outcome_data( snps = bmi_exp_dat$SNP, outcomes = 'ieu-a-7') tsmrdat <- TwoSampleMR::harmonise_data(exposure_dat = bmi_exp_dat, outcome_dat = chd_out_dat) egger_radial(r_input = tsmrdat, alpha = 0.05, weights = 1, summary = TRUE) } ## End(Not run) # Example using MendelianRandomization format data if (require("MendelianRandomization", quietly = TRUE)) { dat <- data_radial[data_radial[,10] < 5e-8,] mrdat <- MendelianRandomization::mr_input(bx = dat$ldlcbeta, bxse = dat$ldlcse, by = dat$chdbeta, byse = dat$chdse, snps = dat$rsid) egger_radial(r_input = mrdat, alpha = 0.05, weights = 1, summary = TRUE) }
# Example using format_radial data ldl.dat <- data_radial[data_radial[,10]<5e-8,] ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9], ldl.dat[,15], ldl.dat[,21], ldl.dat[,1]) egger_radial(ldl.fdat, 0.05, 1, TRUE) # Example using TwoSampleMR format data ## Not run: if (require("TwoSampleMR", quietly = TRUE)) { # Example with one exposure-outcome pair bmi_exp_dat <- TwoSampleMR::extract_instruments(outcomes = 'ieu-a-2') chd_out_dat <- TwoSampleMR::extract_outcome_data( snps = bmi_exp_dat$SNP, outcomes = 'ieu-a-7') tsmrdat <- TwoSampleMR::harmonise_data(exposure_dat = bmi_exp_dat, outcome_dat = chd_out_dat) egger_radial(r_input = tsmrdat, alpha = 0.05, weights = 1, summary = TRUE) } ## End(Not run) # Example using MendelianRandomization format data if (require("MendelianRandomization", quietly = TRUE)) { dat <- data_radial[data_radial[,10] < 5e-8,] mrdat <- MendelianRandomization::mr_input(bx = dat$ldlcbeta, bxse = dat$ldlcse, by = dat$chdbeta, byse = dat$chdse, snps = dat$rsid) egger_radial(r_input = mrdat, alpha = 0.05, weights = 1, summary = TRUE) }
A function which restructures summary GWAS data for downstream two-sample Mendelian randomization analyses. Where variant identification numbers are not provided, an index vector is generated corresponding to the ordering of variants provided.
format_radial(BXG, BYG, seBXG, seBYG, RSID)
format_radial(BXG, BYG, seBXG, seBYG, RSID)
BXG |
A numeric vector of beta-coefficient values for genetic associations with the first variable (exposure). |
BYG |
A numeric vector of beta-coefficient values for genetic associations with the second variable (outcome). |
seBXG |
The standard errors corresponding to the beta-coefficients |
seBYG |
The 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 ( |
The function provides a data frame containing the following columns:
SNP
The identification number for each variant
beta.exposure
The association estimate for the genetic variant with respect to the exposure
beta.outcome
The association estimate for the genetic variant with respect to the outcome
se.exposure
The standard error for the variant-exposure association beta.exposure
se.outcome
The standard error for the variant-outcome association beta.outcome
Wes Spiller; Jack Bowden; Tom Palmer.
Bowden, J., et al., Improving the visualization, interpretation and analysis of two-sample summary data Mendelian randomization via the Radial plot and Radial regression. International Journal of Epidemiology, 2018. 47(4): p. 1264-1278.
ldl.dat <- data_radial[data_radial[,10]<5e-8,] ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9], ldl.dat[,15], ldl.dat[,21], ldl.dat[,1]) head(ldl.fdat) class(ldl.fdat)
ldl.dat <- data_radial[data_radial[,10]<5e-8,] ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9], ldl.dat[,15], ldl.dat[,21], ldl.dat[,1]) head(ldl.fdat) class(ldl.fdat)
Fits a radial inverse variance weighted (IVW) model using a range of weighting specifications. Outliers are determined with respect to their contribution to global heterogeneity, quantified by Cochran's Q-statistic, using a significance threshold specified by the user. The ivw_radial
function returns an object of class "IVW"
, containing effect estimates, total estimated heterogeneity using Cochran's Q-statistic, the individual contribution to overall heterogeneity of each variant, and a data frame for used in the downstream plotting functions plot_radial
and plotly_radial
.
ivw_radial(r_input, alpha, weights, tol, summary)
ivw_radial(r_input, alpha, weights, tol, summary)
r_input |
A formatted data frame using the |
alpha |
A value specifying the statistical significance threshold for identifying outliers ( |
weights |
A value specifying the inverse variance weights used to calculate IVW estimate and Cochran's Q statistic. By default modified second order weights are used, but one can choose to select first order ( |
tol |
A value indicating the tolerance threshold for performing the iterative IVW approach. The value represents the minimum difference between the coefficients of the previous and current iterations required for a further iteration to be performed (default= |
summary |
A logical argument ( |
An object of class "IVW"
containing the following components:
coef
The estimated coefficient, its standard error, t-statistic and corresponding (two-sided) p-value.
qstatistic
Cochran's Q statistic for overall heterogeneity.
df
Degrees of freedom. This is equal to the number of variants -1 when fitting the radial IVW model.
outliers
A data frame containing variants identified as outliers, with respective Q statistics, chi-squared tests and SNP identification.
data
A data frame containing containing SNP IDs, inverse variance weights, the product of the inverse variance weight and ratio estimate for each variant, contribution to overall heterogeneity with corresponding p-value, and a factor indicator showing outlier status.
confint
A vector giving lower and upper confidence limits for the radial IVW effect estimate.
it.coef
The estimated iterative coefficient, its standard error, t-statistic and corresponding (two-sided) p-value.
it.confint
A vector giving lower and upper confidence limits for the iterative radial IVW effect estimate.
fe.coef
The estimated fixed effect exact coefficient, its standard error, t-statistic and corresponding (two-sided) p-value.
fe.confint
A vector giving lower and upper confidence limits for the fixed effect exact radial IVW effect estimate.
re.coef
The estimated random effect exact coefficient, its standard error, t-statistic and corresponding (two-sided) p-value.
re.confint
A vector giving lower and upper confidence limits for the random effect exact radial IVW effect estimate.
mf
The mean F statistic for the set of genetic variants, indicative of instrument strength.
Wes Spiller; Jack Bowden; Tom Palmer.
Bowden, J., et al., Improving the visualization, interpretation and analysis of two-sample summary data Mendelian randomization via the Radial plot and Radial regression. International Journal of Epidemiology, 2018. 47(4): p. 1264-1278.
# Example using format_radial data ldl.dat <- data_radial[data_radial[,10]<5e-8,] ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9], ldl.dat[,15], ldl.dat[,21], ldl.dat[,1]) ivw_radial(ldl.fdat, 0.05, 1, 0.0001, TRUE) # Example using TwoSampleMR format data ## Not run: if (require("TwoSampleMR", quietly = TRUE)) { # Example with one exposure-outcome pair bmi_exp_dat <- TwoSampleMR::extract_instruments(outcomes = 'ieu-a-2') chd_out_dat <- TwoSampleMR::extract_outcome_data( snps = bmi_exp_dat$SNP, outcomes = 'ieu-a-7') tsmrdat <- TwoSampleMR::harmonise_data(exposure_dat = bmi_exp_dat, outcome_dat = chd_out_dat) ivw_radial(r_input = tsmrdat, alpha = 0.05, weights = 1, tol = 0.0001, summary = TRUE) } ## End(Not run) # Example using MendelianRandomization format data if (require("MendelianRandomization", quietly = TRUE)) { dat <- data_radial[data_radial[,10] < 5e-8,] mrdat <- MendelianRandomization::mr_input(bx = dat$ldlcbeta, bxse = dat$ldlcse, by = dat$chdbeta, byse = dat$chdse, snps = dat$rsid) ivw_radial(r_input = mrdat, alpha = 0.05, weights = 1, tol = 0.0001, summary = TRUE) }
# Example using format_radial data ldl.dat <- data_radial[data_radial[,10]<5e-8,] ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9], ldl.dat[,15], ldl.dat[,21], ldl.dat[,1]) ivw_radial(ldl.fdat, 0.05, 1, 0.0001, TRUE) # Example using TwoSampleMR format data ## Not run: if (require("TwoSampleMR", quietly = TRUE)) { # Example with one exposure-outcome pair bmi_exp_dat <- TwoSampleMR::extract_instruments(outcomes = 'ieu-a-2') chd_out_dat <- TwoSampleMR::extract_outcome_data( snps = bmi_exp_dat$SNP, outcomes = 'ieu-a-7') tsmrdat <- TwoSampleMR::harmonise_data(exposure_dat = bmi_exp_dat, outcome_dat = chd_out_dat) ivw_radial(r_input = tsmrdat, alpha = 0.05, weights = 1, tol = 0.0001, summary = TRUE) } ## End(Not run) # Example using MendelianRandomization format data if (require("MendelianRandomization", quietly = TRUE)) { dat <- data_radial[data_radial[,10] < 5e-8,] mrdat <- MendelianRandomization::mr_input(bx = dat$ldlcbeta, bxse = dat$ldlcse, by = dat$chdbeta, byse = dat$chdse, snps = dat$rsid) ivw_radial(r_input = mrdat, alpha = 0.05, weights = 1, tol = 0.0001, summary = TRUE) }
Creates a data.frame with class rmr_format
from an object of class MRInput
generated by MendelianRandomization::mr_input
.
mrinput_to_rmr_format(dat)
mrinput_to_rmr_format(dat)
dat |
Object from |
Object of class rmr_format
, the RadialMR format
if (require("MendelianRandomization", quietly = TRUE)) { dat <- data_radial[data_radial[,10] < 5e-8,] dat <- MendelianRandomization::mr_input(bx = dat$ldlcbeta, bxse = dat$ldlcse, by = dat$chdbeta, byse = dat$chdse, snps = dat$rsid) dat <- mrinput_to_rmr_format(dat) head(dat) class(dat) }
if (require("MendelianRandomization", quietly = TRUE)) { dat <- data_radial[data_radial[,10] < 5e-8,] dat <- MendelianRandomization::mr_input(bx = dat$ldlcbeta, bxse = dat$ldlcse, by = dat$chdbeta, byse = dat$chdse, snps = dat$rsid) dat <- mrinput_to_rmr_format(dat) head(dat) class(dat) }
A function for producing radial IVW and MR-Egger plots either individually or simultaneously. The function allows for a variety of aesthetic and scaling options, utilising the output from the IVW_radial
and egger_radial
functions.
plot_radial(r_object, radial_scale, show_outliers, scale_match)
plot_radial(r_object, radial_scale, show_outliers, scale_match)
r_object |
An object of class |
radial_scale |
Indicates whether to produce a plot including a full radial scale ( |
show_outliers |
Indicates whether display only the set of variants identified as outliers ( |
scale_match |
Indicates whether x and y axes should have the same range( |
A ggplot object containing a radial plot of either the IVW, MR-Egger, or both estimates simultaneously.
Wes Spiller; Jack Bowden; Tom Palmer.
Bowden, J., et al., Improving the visualization, interpretation and analysis of two-sample summary data Mendelian randomization via the Radial plot and Radial regression. International Journal of Epidemiology, 2018. 47(4): p. 1264-1278.
ldl.dat <- data_radial[data_radial[,10]<5e-8,] ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9], ldl.dat[,15], ldl.dat[,21], ldl.dat[,1]) ivw.object <- ivw_radial(ldl.fdat, 0.05, 1, 0.0001, TRUE) plot_radial(ivw.object)
ldl.dat <- data_radial[data_radial[,10]<5e-8,] ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9], ldl.dat[,15], ldl.dat[,21], ldl.dat[,1]) ivw.object <- ivw_radial(ldl.fdat, 0.05, 1, 0.0001, TRUE) plot_radial(ivw.object)
A function for producing interactive radial IVW and MR-Egger plots individually.The function utilises the output from the IVW_radial
and egger_radial
functions.
plotly_radial(r_object, TEST)
plotly_radial(r_object, TEST)
r_object |
An object of class |
TEST |
Logical; indicating whether testing the function |
A plotly object containing a radial plot of either the IVW or MR-Egger estimates. Hovering the mouse over individual datapoints will highlight the corresponding SNP identification number for that observation.
Wes Spiller; Jack Bowden; Tom Palmer.
Bowden, J., et al., Improving the visualization, interpretation and analysis of two-sample summary data Mendelian randomization via the Radial plot and Radial regression. International Journal of Epidemiology, 2018. 47(4): p. 1264-1278.
ldl.dat <- data_radial[data_radial[,10]<5e-8,] ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9], ldl.dat[,15], ldl.dat[,21], ldl.dat[,1]) ivw.object <- ivw_radial(ldl.fdat, 0.05, 1, 0.0001, TRUE) plotly_radial(ivw.object)
ldl.dat <- data_radial[data_radial[,10]<5e-8,] ldl.fdat <- format_radial(ldl.dat[,6], ldl.dat[,9], ldl.dat[,15], ldl.dat[,21], ldl.dat[,1]) ivw.object <- ivw_radial(ldl.fdat, 0.05, 1, 0.0001, TRUE) plotly_radial(ivw.object)
Creates an object of RadialMR format, i.e. of class rmr_format
, for a single exposure - outcome pair.
tsmr_to_rmr_format(dat)
tsmr_to_rmr_format(dat)
dat |
Output for a single exposure-outcome pair from |
Only the rows where the column mr_keep
are TRUE
are kept.
Object of class rmr_format
, the RadialMR format
## Not run: if (require("TwoSampleMR", quietly = TRUE)) { # Example with one exposure-outcome pair bmi_exp_dat <- TwoSampleMR::extract_instruments(outcomes = 'ieu-a-2') chd_out_dat <- TwoSampleMR::extract_outcome_data( snps = bmi_exp_dat$SNP, outcomes = 'ieu-a-7' ) dat <- TwoSampleMR::harmonise_data(exposure_dat = bmi_exp_dat, outcome_dat = chd_out_dat) dat <- tsmr_to_rmr_format(dat) class(dat) head(dat) } ## End(Not run)
## Not run: if (require("TwoSampleMR", quietly = TRUE)) { # Example with one exposure-outcome pair bmi_exp_dat <- TwoSampleMR::extract_instruments(outcomes = 'ieu-a-2') chd_out_dat <- TwoSampleMR::extract_outcome_data( snps = bmi_exp_dat$SNP, outcomes = 'ieu-a-7' ) dat <- TwoSampleMR::harmonise_data(exposure_dat = bmi_exp_dat, outcome_dat = chd_out_dat) dat <- tsmr_to_rmr_format(dat) class(dat) head(dat) } ## End(Not run)