Package 'BESIDEMR'

Title: BayEsian Set IDEntification Mendelian randomization
Description: The R package to perform BayEsian Set IDEntification Mendelian randomization (BESIDE-MR).
Authors: Chin Yang Shapland [aut, cre] , Qingyuan Zhao [aut], Jack Bowden [aut]
Maintainer: Chin Yang Shapland <[email protected]>
License: GPL v3
Version: 1.2
Built: 2024-09-20 08:19:44 UTC
Source: https://github.com/CYShapland/BESIDEMR

Help Index


Effect of HDL choesterol on age-related macular degeneration (AMD)

Description

We performed three-sample MR, where we selected instruments from The Metabolic Syndrome in Men (METSIM) GWAS, then extracted their summary data from MRChallenge2019, where:

  1. SNP-HDL:Kettunen et al. Available from: http://europepmc.org/articles/PMC4814583

  2. SNP-AMD:International AMD Genomics Consortium (IAMDGC) Available from: http://europepmc.org/articles/PMC4745342

Usage

data(AMD_HDL)

Format

A data.frame with 27 rows and 4 variables.


BESIDE-MR fitting function

Description

Fits BESIDE-MR model. NOTE: β\beta is the estimated causal effect and τ\tau is the heterogeneity variance modelled as precision (i.e. 1/τ1/ \tau)

Usage

BMA_MRanalysis(
  tau_estimate,
  N_Beta,
  BetaXG,
  BetaYG,
  seBetaXG,
  seBetaYG,
  N_Ins,
  N_Iter,
  Prior,
  tuning_para,
  gen_inits
)

Arguments

tau_estimate

Use DL estimate (="DL_approx") or Full Bayesian (="Full_Bayes") approach to analyse data.

N_Beta

one-parameter (=1) or two-parameter (=2) model.

BetaXG

Effect size for X-G association

BetaYG

Effect size for Y-G association

seBetaXG

Standard error for X-G association

seBetaYG

Standard error for Y-G association

N_Ins

Number of genetic instruments

N_Iter

Number of iterations

Prior

A list of hyper parameter for the prior distribution;

$hyper_Beta_mean,$hyper_Beta_sd

ONE PARAMETER MODEL: to specify mean (_mean) and standard deviation (_sd) respectively for the normally distributed β\beta.

$hyper_Prec_shape, $hyper_Prec_rate

ONE PARAMETER MODEL with "Full_Bayes": to specify shape (_shape) and rate (_rate) for the gamma distribution of precision.

$Ins_prob

ONE PARAMETER MODEL: assign prior inclusion probability for each instrument.

$hyper_Beta1_mean,$hyper_Beta1_sd,$hyper_Beta2_mean,$hyper_Beta2_sd

ONE PARAMETER MODEL: to specify mean and standard deviation for the normally distributed β1\beta_1 and β2\beta_2 respectively.

$hyper_Prec1_shape, $hyper_Prec1_rate, $hyper_Prec2_shape, $hyper_Prec2_rate

TWO PARAMETER MODEL with "Full_Bayes": to specify shape and rate for the gamma distribution of precision.

$Ins1_prob, $Ins2_prob

TWO PARAMETER MODEL: assign prior inclusion probability for each instrument in set 1 or set 2 repectively.

tuning_para

Tuning parameter to ensure sufficient acceptance rate (recommended between 0.25 - 0.45);

$Beta

ONE PARAMETER MODEL: for β\beta.

$Prec_LL, $Prec_UL, $Prec_gap

ONE PARAMETER MODEL with "Full_Bayes": for the upper (_UL), lower (_LL) and gap (_gap) of the precision, this ensures symmetry between the new and the old value.

$Beta1, $Beta2

TWO PARAMETER MODEL: for β1\beta_1 and β2\beta_2 respectively.

$Prec1_LL, $Prec1_UL, $Prec1_gap, $Prec2_LL, $Prec2_UL, $Prec2_gap

TWO PARAMETER MODEL with "Full_Bayes": for the upper, lower and gap of the precision1 and precision2 respectively, this ensures symmetry between the new and the old value.

gen_inits

Initial values to start the iterations;

$Beta

ONE PARAMETER MODEL: for β\beta.

$UBPrec, $LBPrec

ONE PARAMETER MODEL with "Full_Bayes": for upper and lower limit of initial value of precision respectively.

$Ins_L

ONE PARAMETER MODEL: use randomS.initial.LI() to generate random initial model space.

$Beta1, $Beta2

TWO PARAMETER MODEL: for β1\beta_1 and β2\beta_2 respectively.

$UBPrec1, $LBPrec1, $UBPrec2, $LBPrec2

TWO PARAMETER MODEL with "Full_Bayes": or upper and lower limit of initial value of precision1 and precision2 respectively.

$Ins1_L, $Ins2_L

TWO PARAMETER MODEL: use randomS.initial.LI() generate random initial model space.

Value

An object of class "beside" containing the following components:

S

A matrix giving the results. ONE PARAMETER MODEL: columns gives sampled values of β,τ2,I1,...,IL\beta, \tau^2, I_1,...,I_L for all iterations (rows). TWO PARAMETER MODEL: columns gives sampled values of β1,β2,τ12,τ22,I11,...,I1L,I21,...,I2L\beta_1, \beta_2, \tau_1^2, \tau_2^2, I_{11},...,I_{1L}, I_{21},...,I_{2L} for all iterations (rows).

accept_rate

acceptance rate for each of the parameter from S.

Author(s)

Chin Yang Shapland; Jack Bowden.

References

Shapland, C.Y., et al., Profile-likelihood Bayesian model averaging for two-sample summary data Mendelian randomization in the presence of horizontal pleiotropy.

Examples

# load data
data(AMD_HDL)

# Prior choice for beta, tau and inclusion of instruments
L<-nrow(AMD_HDL)
Ins_prior<-rep(0.5, L)
Prior_DL<-list(hyper_Beta_mean=0, hyper_Beta_sd=1, Ins_prob=Ins_prior)
Prior_gamma<-list(hyper_Beta_mean=0, hyper_Beta_sd=1, hyper_Prec_shape=2, hyper_Prec_rate=0.00005, Ins_prob=Ins_prior)

# Tuning parameter for beta
H_DL<-list(Beta=0.05)
H_gamma<-list(Beta=0.05, Prec_LL=0, Prec_UL=1000000, Prec_gap=150000)

# Generate initial values
gen_inits_DL<-list(Beta=rnorm(1,0,10), Ins_L=randomS.initial.LI(L,Ins_prior))
gen_inits_gamma<-list(Beta=rnorm(1,0,10), UBPrec=1000000, LBPrec=0, Ins_L=randomS.initial.LI(L,Ins_prior))

# One-parameter model
nIter<-50000
#res_DL<-BMA_MRanalysis("DL_approx", 1, AMD_HDL$BetaXG, AMD_HDL$BetaYG, AMD_HDL$seBetaXG, AMD_HDL$seBetaYG, L, nIter, Prior_DL, H_DL, gen_inits_DL)
#res_gamma<-BMA_MRanalysis("Full_Bayes", 1, AMD_HDL$BetaXG, AMD_HDL$BetaYG, AMD_HDL$seBetaXG, AMD_HDL$seBetaYG, L, nIter, Prior_gamma, H_gamma, gen_inits_gamma)

BESIDE-MR fitting function with penalization term

Description

Sensitivity analysis that fits BESIDE-MR model with penalisation term (η\eta) for number of instruments.

Usage

BMA_MRanalysis_InsPen(
  tau_estimate,
  N_Beta,
  BetaXG,
  BetaYG,
  seBetaXG,
  seBetaYG,
  N_Ins,
  N_Iter,
  Prior,
  tuning_para,
  gen_inits,
  Penal_NoInst
)

Arguments

tau_estimate

Use DL estimate (="DL_approx") or Full Bayesian (="Full_Bayes") approach to analyse data.

N_Beta

one-parameter (=1) or two-parameter (=2) model.

BetaXG

Effect size for X-G association

BetaYG

Effect size for Y-G association

seBetaXG

Standard error for X-G association

seBetaYG

Standard error for Y-G association

N_Ins

Number of genetic instruments

N_Iter

Number of iterations

Prior

A list of hyper parameter for the prior distribution;

$hyper_Beta_mean,$hyper_Beta_sd

ONE PARAMETER MODEL: to specify mean (_mean) and standard deviation (_sd) respectively for the normally distributed β\beta.

$hyper_Prec_shape, $hyper_Prec_rate

ONE PARAMETER MODEL with "Full_Bayes": to specify shape (_shape) and rate (_rate) for the gamma distribution of precision.

$Ins_prob

ONE PARAMETER MODEL: assign prior inclusion probability for each instrument.

$hyper_Beta1_mean,$hyper_Beta1_sd,$hyper_Beta2_mean,$hyper_Beta2_sd

ONE PARAMETER MODEL: to specify mean and standard deviation for the normally distributed β1\beta_1 and β2\beta_2 respectively.

$hyper_Prec1_shape, $hyper_Prec1_rate, $hyper_Prec2_shape, $hyper_Prec2_rate

TWO PARAMETER MODEL with "Full_Bayes": to specify shape and rate for the gamma distribution of precision.

$Ins1_prob, $Ins2_prob

TWO PARAMETER MODEL: assign prior inclusion probability for each instrument in set 1 or set 2 repectively.

tuning_para

Tuning parameter to ensure sufficient acceptance rate (recommended between 0.25 - 0.45);

$Beta

ONE PARAMETER MODEL: for β\beta.

$Prec_LL, $Prec_UL, $Prec_gap

ONE PARAMETER MODEL with "Full_Bayes": for the upper (_UL), lower (_LL) and gap (_gap) of the precision, this ensures symmetry between the new and the old value.

$Beta1, $Beta2

TWO PARAMETER MODEL: for β1\beta_1 and β2\beta_2 respectively.

$Prec1_LL, $Prec1_UL, $Prec1_gap, $Prec2_LL, $Prec2_UL, $Prec2_gap

TWO PARAMETER MODEL with "Full_Bayes": for the upper, lower and gap of the precision1 and precision2 respectively, this ensures symmetry between the new and the old value.

gen_inits

Initial values to start the iterations;

$Beta

ONE PARAMETER MODEL: for β\beta.

$UBPrec, $LBPrec

ONE PARAMETER MODEL with "Full_Bayes": for upper and lower limit of initial value of precision respectively.

$Ins_L

ONE PARAMETER MODEL: use randomS.initial.LI() to generate random initial model space.

$Beta1, $Beta2

TWO PARAMETER MODEL: for β1\beta_1 and β2\beta_2 respectively.

$UBPrec1, $LBPrec1, $UBPrec2, $LBPrec2

TWO PARAMETER MODEL with "Full_Bayes": or upper and lower limit of initial value of precision1 and precision2 respectively.

$Ins1_L, $Ins2_L

TWO PARAMETER MODEL: use randomS.initial.LI() generate random initial model space.

Penal_NoInst

Penalisation term for number of instruments, positive and negative value favours models with many and few instruments respectively. Two values must be specified for the two-parameter model.

Value

An object of class "beside" containing the following components:

S

A matrix giving the results. ONE PARAMETER MODEL: columns gives sampled values of β,τ2,I1,...,IL\beta, \tau^2, I_1,...,I_L for all iterations (rows). TWO PARAMETER MODEL: columns gives sampled values of β1,β2,τ12,τ22,I11,...,I1L,I21,...,I2L\beta_1, \beta_2, \tau_1^2, \tau_2^2, I_{11},...,I_{1L}, I_{21},...,I_{2L} for all iterations (rows).

accept_rate

acceptance rate for each of the parameter from S.

Author(s)

Chin Yang Shapland; Jack Bowden.

References

Shapland, C.Y., et al., Profile-likelihood Bayesian model averaging for two-sample summary data Mendelian randomization in the presence of horizontal pleiotropy.

Examples

# load data
data(AMD_HDL)

# Prior choice for beta, tau and inclusion of instruments
L<-nrow(AMD_HDL)
Ins_prior<-rep(0.5, L)
Prior_DL<-list(hyper_Beta_mean=0, hyper_Beta_sd=1, Ins_prob=Ins_prior)
Prior_gamma<-list(hyper_Beta_mean=0, hyper_Beta_sd=1, hyper_Prec_shape=2, hyper_Prec_rate=0.00005, Ins_prob=Ins_prior)

# Tuning parameter for beta
H_DL<-list(Beta=0.05)
H_gamma<-list(Beta=0.05, Prec_LL=0, Prec_UL=1000000, Prec_gap=150000)

# Generate initial values
gen_inits_DL<-list(Beta=rnorm(1,0,10), Ins_L=randomS.initial.LI(L,Ins_prior))
gen_inits_gamma<-list(Beta=rnorm(1,0,10), UBPrec=1000000, LBPrec=0, Ins_L=randomS.initial.LI(L,Ins_prior))

# One-parameter model with penalisation parameter
eta_sense<-5 # penalisation value which favours models with many instruments
nIter<-50000
#res_DL<-BMA_MRanalysis_InsPen("DL_approx",1, AMD_HDL$beta_XL.HDL.C, AMD_HDL$beta_amd, AMD_HDL$se_XL.HDL.C, AMD_HDL$se_amd, L, nIter, Prior_DL, H_DL, gen_inits_DL, eta_sense)
#res_gamma<-BMA_MRanalysis_InsPen("Full_Bayes",1, AMD_HDL$beta_XL.HDL.C, AMD_HDL$beta_amd, AMD_HDL$se_XL.HDL.C, AMD_HDL$se_amd, L, nIter, Prior_gamma, H_gamma, gen_inits_gamma, eta_sense)

Generate initial model space function

Description

Generate random initial model space that doesn't produce empty and 1 variable model space.

Usage

randomS.initial.LI(L, ins_prior)

Arguments

L

Number of instruments.

ins_prior

prior for inclusion probability for each instrument.

Value

numeric sequence of L length as the indicator variable to initialise in BMA_MRanalysis().

Examples

#load data
data(AMD_HDL)

#Prior choice for beta, tau and inclusion of instruments
L<-nrow(AMD_HDL)
Ins_prior<-rep(0.5, L)
randomS.initial.LI(L,Ins_prior)