Package 'RadialMR'

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

Help Index


Two Sample Summary GWAS data published in Do et al (2014).

Description

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.

Usage

data_radial

Format

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

Details

data_radial

Author(s)

Wes Spiller; Jack Bowden; Tom Palmer.

Source

Examples

head(data_radial)

egger_radial

Description

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.

Usage

egger_radial(r_input, alpha, weights, summary)

Arguments

r_input

A formatted data frame using the format_radial function, or an object of class MRInput generated by MendelianRandomization::mr_input or a data.frame for a single exposure-outcome pair generated by TwoSampleMR::harmonise_data.

alpha

A value specifying the statistical significance threshold for identifying outliers (0.05 specifies a p-value threshold of 0.05).

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 (1), second order (2) or modified second order weights (3).

summary

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

Value

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.

Author(s)

Wes Spiller; Jack Bowden; Tom Palmer.

References

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.

Examples

# 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)
}

format_radial

Description

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.

Usage

format_radial(BXG, BYG, seBXG, seBYG, RSID)

Arguments

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 BXG.

seBYG

The 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

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

Author(s)

Wes Spiller; Jack Bowden; Tom Palmer.

References

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.

Examples

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)

ivw_radial

Description

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.

Usage

ivw_radial(r_input, alpha, weights, tol, summary)

Arguments

r_input

A formatted data frame using the format_radial function, or an object of class MRInput generated by MendelianRandomization::mr_input or a data.frame for a single exposure-outcome pair generated by TwoSampleMR::harmonise_data.

alpha

A value specifying the statistical significance threshold for identifying outliers (0.05 specifies a p-value threshold of 0.05).

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 (1), second order (2) or modified second order weights (3).

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= 0.0001).

summary

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

Value

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.

Author(s)

Wes Spiller; Jack Bowden; Tom Palmer.

References

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.

Examples

# 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)
}

Convert an object of class MRInput from the MendelianRandomization package to the RadialMR rmr_format class

Description

Creates a data.frame with class rmr_format from an object of class MRInput generated by MendelianRandomization::mr_input.

Usage

mrinput_to_rmr_format(dat)

Arguments

dat

Object from MendelianRandomization::mr_input.

Value

Object of class rmr_format, the RadialMR format

Examples

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)
}

plot_radial

Description

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.

Usage

plot_radial(r_object, radial_scale, show_outliers, scale_match)

Arguments

r_object

An object of class "IVW" or "egger". For visualising both estimates simultaneously, both objects should be included as a vector c(A,B), where A and B denote the "IVW" and "egger" objects respectively.

radial_scale

Indicates whether to produce a plot including a full radial scale (TRUE), or a scatterplot showing only the effect estimates (FALSE).

show_outliers

Indicates whether display only the set of variants identified as outliers (TRUE) or the complete set of variants (FALSE). Note that when (show_outliers=TRUE), non-outlying variants further from the origin than the furthest outlier will cause an error message that one or more points have been omitted. These are non-outlying variants beyond the scale. If no outliers are present, a plot will be produced using the full set of variants, with an accompanying message indicating the absence of outliers.

scale_match

Indicates whether x and y axes should have the same range(TRUE), or different ranges (FALSE) This improves the interpretation of the radial scale, and is set to FALSE when the radial scale is omitted from the plot.

Value

A ggplot object containing a radial plot of either the IVW, MR-Egger, or both estimates simultaneously.

Author(s)

Wes Spiller; Jack Bowden; Tom Palmer.

References

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.

Examples

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)

plotly_radial

Description

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.

Usage

plotly_radial(r_object, TEST)

Arguments

r_object

An object of class "IVW" or "egger".

TEST

Logical; indicating whether testing the function

Value

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.

Author(s)

Wes Spiller; Jack Bowden; Tom Palmer.

References

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.

Examples

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)

Convert a data.frame containing a single exposure - outcome pair generated by TwoSampleMR::harmonise_data() to the RadialMR rmr_format class

Description

Creates an object of RadialMR format, i.e. of class rmr_format, for a single exposure - outcome pair.

Usage

tsmr_to_rmr_format(dat)

Arguments

dat

Output for a single exposure-outcome pair from TwoSampleMR::harmonise_data.

Details

Only the rows where the column mr_keep are TRUE are kept.

Value

Object of class rmr_format, the RadialMR format

Examples

## 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)