| Title: | RadialMR |
|---|---|
| Description: | A package for implementing radial inverse variance weighted and MR-Egger methods. |
| Authors: | Wes Spiller [aut] (ORCID: <https://orcid.org/0000-0002-8169-5531>), Jack Bowden [aut] (ORCID: <https://orcid.org/0000-0003-2628-3304>), Tom Palmer [aut, cre] (ORCID: <https://orcid.org/0000-0003-4655-4511>) |
| Maintainer: | Tom Palmer <[email protected]> |
| License: | GPL-3 |
| Version: | 1.2.3 |
| Built: | 2026-05-14 19:41:26 UTC |
| Source: | https://github.com/WSpiller/RadialMR |
A dataset containing summary 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_radialdata_radial
A data frame with 185 rows and 21 variables. Specifically this includes the following information:
rsidThe identification number for each variant
a1The reference allele for each variant
a2The other allele for each variant
chrThe chromosome number in which each variant is located
posThe genomic position for the genetic variant relative to chromosome number
ldlcbetaThe association estimate for the genetic variant obtained by regressing LDL-C upon the genetic variant
hdlcbetaThe association estimate obtained by regressing HDL-C upon the genetic variant
tgbetaThe association estimate obtained by regressing triglycerides upon the genetic variant
chdbetaThe association estimate for CHD obtained by regressing CHD upon the genetic variant
ldlcp2The p-value corresponding to association estimate ldlcbeta
hdlcp2The p-value corresponding to association estimate hdlcbeta
tgp2The p-value corresponding to association estimate tgbeta
chdp2The p-value corresponding to association estimate chdbeta
ldlczThe z-score corresponding to association estimate ldlcbeta
ldlcseThe standard error corresponding to association estimate ldlcbeta
hdlczThe z-score corresponding to association estimate hdlcbeta
hdlcseThe standard error corresponding to association estimate hdlcbeta
tgzThe z-score corresponding to association estimate tgbeta
tgseThe standard error corresponding to association estimate tgbeta
chdzThe z-score corresponding to association estimate chdbeta
chdseThe 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:
coefA matrix giving the intercept and slope coefficient, corresponding standard errors, t-statistics, and (two-sided) p-values.
qstatisticRucker's Q statistic for overall heterogeneity.
dfDegrees of freedom. This is equal to the number of variants -2 when fitting the radial MR-Egger model.
outliersA data frame containing variants identified as outliers, with respective Q statistics, chi-squared tests and SNP identification.
dataA data frame 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.
confintA 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:
SNPThe identification number for each variant
beta.exposureThe association estimate for the genetic variant with respect to the exposure
beta.outcomeThe association estimate for the genetic variant with respect to the outcome
se.exposureThe standard error for the variant-exposure association beta.exposure
se.outcomeThe 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:
coefThe estimated coefficient, its standard error, t-statistic and corresponding (two-sided) p-value.
qstatisticCochran's Q statistic for overall heterogeneity.
dfDegrees of freedom. This is equal to the number of variants -1 when fitting the radial IVW model.
outliersA data frame containing variants identified as outliers, with respective Q statistics, chi-squared tests and SNP identification.
dataA data frame 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.
confintA vector giving lower and upper confidence limits for the radial IVW effect estimate.
it.coefThe estimated iterative coefficient, its standard error, t-statistic and corresponding (two-sided) p-value.
it.confintA vector giving lower and upper confidence limits for the iterative radial IVW effect estimate.
fe.coefThe estimated fixed effect exact coefficient, its standard error, t-statistic and corresponding (two-sided) p-value.
fe.confintA vector giving lower and upper confidence limits for the fixed effect exact radial IVW effect estimate.
re.coefThe estimated random effect exact coefficient, its standard error, t-statistic and corresponding (two-sided) p-value.
re.confintA vector giving lower and upper confidence limits for the random effect exact radial IVW effect estimate.
mfThe 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 to 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) egg.object <- egger_radial(ldl.fdat, 0.05, 1, TRUE) plot_radial(egg.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) egg.object <- egger_radial(ldl.fdat, 0.05, 1, TRUE) plot_radial(egg.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)