Title: | MrDAG: Mendelian randomization (MR) with Bayesian Directed Acyclic (DAG) Graphs exploration and causal effects estimation |
---|---|
Description: | This package performs Mendelian randomization for multiple exposures and outcomes with Bayesian Directed Acyclic Graphs exploration and causal effects estimation. |
Authors: | Leonardo Bottolo [aut, cre], Verena Zuber [aut, ctb] |
Maintainer: | Leonardo Bottolo <[email protected]> |
License: | GPL-2 | file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-05 12:30:05 UTC |
Source: | https://github.com/lb664/MrDAG |
Estimation of the (average) causal effect under intervention on a trait (target) and measured on another one
(response) based on the Directed Acyclic Graphs (DAGs) explored by MrDAG
algorithm
get_causaleffect(output, response, target, BMA = TRUE, CI = 0.95)
get_causaleffect(output, response, target, BMA = TRUE, CI = 0.95)
output |
Output produced by |
response |
Trait (response) where the effect of the intervention on another trait (target) is measured |
target |
Trait (target) under intervention |
BMA |
If |
CI |
Level ( |
The value returned is a list object list(causaleffect, causaleffect_LL, causaleffect_UL, group, BMA, CI)
causaleffect
Estimate of the (average) causal effect under intervention on an trait (target) on another
one (response) based on the DAGs explored by MrDAG
algorithm. Feedback loop causal effect of the same trait is not
allowed (NA)
causaleffect_LL
Lower limit of the CI
of the (average) causal effect. It is calculated as the
(1-CIboot
)/2 % quantile of the (average) causal effect across all explored DAGs
causaleffect_UL
Upper limit of the CI
of the (average) causal effect. It is calculated as the
1-[(1-CIboot
)/2] % quantile of the (average) causal effect across all explored DAGs
group
If MrDAGcheck
in MrDAG
algorithm contains the indices of the traits in data
that
define the outcomes and the exposures, group
coincides with this list
BMA
Logical option
CI
Level of the credible interval option
Andersson SA, Madigan D, Perlman MD (1997).
“A characterization of Markov equivalence classes for acyclic digraphs.”
Annals of Statistics, 25(2), 505–541.
doi:10.1214/aos/1031833662.
Chickering DM (2002).
“Learning equivalence classes of bayesian-network structures.”
Journal of Machine Learning Research, 2, 445–498.
http://www.ai.mit.edu/projects/jmlr/papers/volume2/chickering02a/chickering02a.pdf.
# Example: Estimation of the (average) causal effects under intervention on lifestyle and # behavioural exposures, and measured on mental health phenotypes. 708 independent Instrumental # Variables (IVs) were selected to be associated at genome-wide significance with six lifestyle # and behavioural traits after pruning or clumping which are considered exposures of the risk # of seven mental health outcome phenotypes # After loading the data set data(LBT2MD_data) # the indices of the traits that define the outcomes and exposures are provided in a list object MrDAGcheck <- NULL MrDAGcheck$Y_idx <- 1 : 7 # Mental health phenotypes MrDAGcheck$X_idx <- 8 : 13 # Lifestyle and behavioural traits # MrDAG algorithm is run to generate 1,000 posterior samples of all unknowns output <- MrDAG(data = LBT2MD_data, niter = 5000, burnin = 2500, thin = 5, tempmax = 20, w = 0.01, MrDAGcheck = MrDAGcheck, filename = NULL) # Finally, the (average) causal effects and credible intervals (CI) of the intervention on ALC # and measured on SCZ are estimated causaleffects <- get_causaleffect(output, 7, 8) # Intervention on ALC and measured on SCZ
# Example: Estimation of the (average) causal effects under intervention on lifestyle and # behavioural exposures, and measured on mental health phenotypes. 708 independent Instrumental # Variables (IVs) were selected to be associated at genome-wide significance with six lifestyle # and behavioural traits after pruning or clumping which are considered exposures of the risk # of seven mental health outcome phenotypes # After loading the data set data(LBT2MD_data) # the indices of the traits that define the outcomes and exposures are provided in a list object MrDAGcheck <- NULL MrDAGcheck$Y_idx <- 1 : 7 # Mental health phenotypes MrDAGcheck$X_idx <- 8 : 13 # Lifestyle and behavioural traits # MrDAG algorithm is run to generate 1,000 posterior samples of all unknowns output <- MrDAG(data = LBT2MD_data, niter = 5000, burnin = 2500, thin = 5, tempmax = 20, w = 0.01, MrDAGcheck = MrDAGcheck, filename = NULL) # Finally, the (average) causal effects and credible intervals (CI) of the intervention on ALC # and measured on SCZ are estimated causaleffects <- get_causaleffect(output, 7, 8) # Intervention on ALC and measured on SCZ
Estimation of the (average) causal effects under intervention on the exposures (targets) and measured on the outcomes
(responses) based on the Directed Acyclic Graphs (DAGs) explored by MrDAG
algorithm
get_causaleffects( output, ord = NULL, BMA = TRUE, CI = 0.95, progress = FALSE, plot = FALSE )
get_causaleffects( output, ord = NULL, BMA = TRUE, CI = 0.95, progress = FALSE, plot = FALSE )
output |
Output produced by |
ord |
Indices of the traits in |
BMA |
If |
CI |
Level ( |
progress |
Logical value set as |
plot |
Logical value (default |
The value returned is a list object list(causaleffects, causaleffects_LL, causaleffects_UL, group, ord, BMA, CI)
causaleffects
Estimate of the (average) causal effects under intervention on the exposures based on the DAGs
explored by MrDAG
algorithm. Feedback loop causal effect of the same outcome is not allowed (NA)
causaleffects_LL
Lower limit of the CI
of the (average) causal effects. It is calculated as the
(1-CIboot
)/2 % quantile of the (average) causal effect across all explored DAGs
causaleffects_UL
Upper limit of the CI
of the (average) causal effects. It is calculated as the
1-[(1-CIboot
)/2] % quantile of the (average) causal effect across all explored DAGs
group
If MrDAGcheck
in MrDAG
algorithm contains the indices of the traits in data
that
define the outcomes and the exposures, group
coincides with this list
ord
Indices of the traits in data
that specify the outcomes and the exposures. It might differ from
group
if ord
has been specified and it is different from MrDAGcheck
BMA
Logical option
CI
Level of the credible interval option
Andersson SA, Madigan D, Perlman MD (1997).
“A characterization of Markov equivalence classes for acyclic digraphs.”
Annals of Statistics, 25(2), 505–541.
doi:10.1214/aos/1031833662.
Chickering DM (2002).
“Learning equivalence classes of bayesian-network structures.”
Journal of Machine Learning Research, 2, 445–498.
http://www.ai.mit.edu/projects/jmlr/papers/volume2/chickering02a/chickering02a.pdf.
# Example: Estimation of the (average) causal effects under intervention on lifestyle and # behavioural exposures, and measured on mental health phenotypes. 708 independent Instrumental # Variables (IVs) were selected to be associated at genome-wide significance with six lifestyle # and behavioural traits after pruning or clumping which are considered exposures of the risk # of seven mental health outcome phenotypes # After loading the data set data(LBT2MD_data) # the indices of the traits that define the outcomes and exposures are provided in a list object MrDAGcheck <- NULL MrDAGcheck$Y_idx <- 1 : 7 # Mental health phenotypes MrDAGcheck$X_idx <- 8 : 13 # Lifestyle and behavioural traits # MrDAG algorithm is run to generate 1,000 posterior samples of all unknowns output <- MrDAG(data = LBT2MD_data, niter = 5000, burnin = 2500, thin = 5, tempmax = 20, w = 0.01, MrDAGcheck = MrDAGcheck, filename = NULL) # Finally, the (average) causal effects and 90% credible intervals are estimated causaleffects <- get_causaleffects(output, CI = 0.90, progress = TRUE)
# Example: Estimation of the (average) causal effects under intervention on lifestyle and # behavioural exposures, and measured on mental health phenotypes. 708 independent Instrumental # Variables (IVs) were selected to be associated at genome-wide significance with six lifestyle # and behavioural traits after pruning or clumping which are considered exposures of the risk # of seven mental health outcome phenotypes # After loading the data set data(LBT2MD_data) # the indices of the traits that define the outcomes and exposures are provided in a list object MrDAGcheck <- NULL MrDAGcheck$Y_idx <- 1 : 7 # Mental health phenotypes MrDAGcheck$X_idx <- 8 : 13 # Lifestyle and behavioural traits # MrDAG algorithm is run to generate 1,000 posterior samples of all unknowns output <- MrDAG(data = LBT2MD_data, niter = 5000, burnin = 2500, thin = 5, tempmax = 20, w = 0.01, MrDAGcheck = MrDAGcheck, filename = NULL) # Finally, the (average) causal effects and 90% credible intervals are estimated causaleffects <- get_causaleffects(output, CI = 0.90, progress = TRUE)
Estimation of the Posterior Probability of Edge Inclusion (PPEI) based on the Directed Acyclic Graphs (DAGs) explored
by MrDAG
algorithm
get_edgeprob(output, ord = NULL)
get_edgeprob(output, ord = NULL)
output |
Output produced by |
ord |
Indices of the traits in |
The value returned is a list object list(edgeprob, group, ord)
effect
Estimate of the PPEI between each trait. Feedback loop of the same trait is not allowed (NA). If a
partition of the traits between outcomes and exposures is specified, the PPEIs between outcomes and exposures are not
considered (NA)
group
If MrDAGcheck
in MrDAG
algorithm contains the indices of the traits in data
that
define the outcomes and the exposures, group
coincides with this list
ord
Indices of the traits in data
that specify the outcomes and the exposures. It might differ from
group
if ord
has been specified and it is different from MrDAGcheck
# Example: Estimation of the Posterior Probabilities of Edge Inclusion (PPEIs) of lifestyle and # behavioural traits, and mental health phenotypes. 708 independent Instrumental Variables # (IVs) were selected to be associated at genome-wide significance with six lifestyle and # behavioural traits after pruning or clumping which are considered exposures of the risk of # seven mental health outcome phenotypes # After loading the data set data(LBT2MD_data) # the indices of the traits that define the outcomes and exposures are provided in a list object MrDAGcheck <- NULL MrDAGcheck$Y_idx <- 1 : 7 # Mental health phenotypes MrDAGcheck$X_idx <- 8 : 13 # Lifestyle and behavioural traits # MrDAG algorithm is run to generate 1,000 posterior samples of all unknowns output <- MrDAG(data = LBT2MD_data, niter = 5000, burnin = 2500, thin = 5, tempmax = 20, w = 0.01, MrDAGcheck = MrDAGcheck, filename = NULL) # Finally, PPEIs are calculated and presented with lifestyle and behavioural traits first, # followed by mental health phenotypes ord <- c(8 : 13, 1 : 7) PPEI <- get_edgeprob(output, ord = ord)
# Example: Estimation of the Posterior Probabilities of Edge Inclusion (PPEIs) of lifestyle and # behavioural traits, and mental health phenotypes. 708 independent Instrumental Variables # (IVs) were selected to be associated at genome-wide significance with six lifestyle and # behavioural traits after pruning or clumping which are considered exposures of the risk of # seven mental health outcome phenotypes # After loading the data set data(LBT2MD_data) # the indices of the traits that define the outcomes and exposures are provided in a list object MrDAGcheck <- NULL MrDAGcheck$Y_idx <- 1 : 7 # Mental health phenotypes MrDAGcheck$X_idx <- 8 : 13 # Lifestyle and behavioural traits # MrDAG algorithm is run to generate 1,000 posterior samples of all unknowns output <- MrDAG(data = LBT2MD_data, niter = 5000, burnin = 2500, thin = 5, tempmax = 20, w = 0.01, MrDAGcheck = MrDAGcheck, filename = NULL) # Finally, PPEIs are calculated and presented with lifestyle and behavioural traits first, # followed by mental health phenotypes ord <- c(8 : 13, 1 : 7) PPEI <- get_edgeprob(output, ord = ord)
The data set contains lifestyle and behavioural traits that are considered exposures of the risk of mental health phenotypes. As outcomes, seven mental health phenotypes are considered, including (in alphabetic order) attention deficit hyperactivity disorder (ADHD), anorexia nervosa (AN), autism spectrum disorder (ASD), bipolar disorder (BD), cognition (COG), major depressive disorder (MDD) and schizophrenia (SCZ). As exposures, six lifestyle and behavioural traits that have previously been investigated for their protective/risk effects on mental health are considered, including (in alphabetic order) alcohol consumption (ALC), education (in years) (EDU), leisure screen time (LST), physical activity (PA), lifetime smoking index (SM) and sleep duration (SP)
LBT2MD_data
LBT2MD_data
A data frame consisting of 708 independent Instrumental Variables (IVs) selected to be associated at genome-wide significance with the exposures after pruning or clumping. For details, see Zuber et al. (2024)
Zuber V, Cronjé T, Cai N, Gill D, Bottolo L (2024). “Mendelian randomization for multiple exposures and outcomes with Bayesian Directed Acyclic Graphs exploration and causal effects estimation.” Submitted.
# Example: data(LBT2MD_data) head(LBT2MD_data)
# Example: data(LBT2MD_data) head(LBT2MD_data)
The data set contains mental health phenotypes that are considered exposures of the risk of lifestyle and behavioural traits. As outcomes, six lifestyle and behavioural traits are considered, including (in alphabetic order) alcohol consumption (ALC), education (in years) (EDU), leisure screen time (LST), physical activity (PA), lifetime smoking index (SM) and sleep duration (SP). As exposures, seven mental health phenotypes are considered, including (in alphabetic order) attention deficit hyperactivity disorder (ADHD), anorexia nervosa (AN), autism spectrum disorder (ASD), bipolar disorder (BD), cognition (COG), major depressive disorder (MDD) and schizophrenia (SCZ)
MD2LBT_data
MD2LBT_data
A data frame consisting of 470 independent Instrumental Variables (IVs) selected to be associated at genome-wide significance with the exposures after pruning or clumping. For details, see Zuber et al. (2024)
Zuber V, Cronjé T, Cai N, Gill D, Bottolo L (2024). “Mendelian randomization for multiple exposures and outcomes with Bayesian Directed Acyclic Graphs exploration and causal effects estimation.” Submitted.
# Example: data(MD2LBT_data) head(MD2LBT_data)
# Example: data(MD2LBT_data) head(MD2LBT_data)
Markov chain Monte Carlo (MCMC) implementation of Bayesian multivariable, multi-response Mendelian randomization (MR) model for summary-level data with Directed Acyclic Graphs (DAGs) exploration and causal effects estimation
MrDAG( data, niter, burnin, thin, w = 0.05, a = NULL, U = NULL, tempmax = 10, MrDAGcheck = NULL, filename = "MrDAG_object", filepath = NULL, fastMCMC = TRUE, savememory = FALSE, seed = 31122021 )
MrDAG( data, niter, burnin, thin, w = 0.05, a = NULL, U = NULL, tempmax = 10, MrDAGcheck = NULL, filename = "MrDAG_object", filepath = NULL, fastMCMC = TRUE, savememory = FALSE, seed = 31122021 )
data |
Number of observations (IVs in a summary-level MR design) times the number of traits (both outcomes and exposures).
There is a restriction in the order of appearance of the traits in the |
niter |
Number of MCMC iterations (excluding burn-in) |
burnin |
Number of MCMC iterations to be performed during burn-in |
thin |
Parameter that defines how often the MCMC output should be stored, i.e., at every thin-th iteration |
w |
Prior probability of edge inclusion ( |
a |
Degrees of freedom of the Wishart prior distribution on the precision matrix, i.e., the inverse of the covariance matrix
between the traits ( |
U |
(Proportional to the) expected value of the Wishart prior distribution on the precision matrix, i.e., the inverse of the
covariance matrix between the traits. Specifically, proportional to an m-dimensional diagonal matrix as default, where |
tempmax |
Annealing parameter |
MrDAGcheck |
List object that contains the indices of the traits in |
filename |
Name of the file for |
filepath |
Directory where |
fastMCMC |
If logical |
savememory |
If logical |
seed |
Seed to be used in the initialisation of the MCMC algorithm ( |
For details regarding the model and the algorithm, see Zuber et al. (2024)
The value returned is a list object list(graphs, L,D, logmarglik, validpropMrDAG, acceptpropDAG, timeMrDAG,
hyperpar, samplerpar, opt)
graphs
Explored DAGs that belong to learned Completed Partially DAGs (CPDAGs)
(Chickering (2002)) or Essential Graphs (EGs) (Andersson et al. (1997)). The
class of graphs
depends on the savememory
option. The number of explored DAGs corresponds to the number of
thinned (thin
) MCMC iterations (excluding burn-in)
L
Posterior samples of the lower triangular matrix of the modified Cholesky decomposition (L,D)
(Zuber et al. (2024) and Castelletti and Consonni (2021))
D
Posterior samples of the diagonal matrix of the modified Cholesky decomposition (L,D)
(Zuber et al. (2024) and Castelletti and Consonni (2021))
logmarglik
Log-marginal likelihood of explored DAGs which belong to the Markov Equivalent Classes whose unique
representative chain graphs are the EGs learned during MCMC iterations (including burn-in) without thinning
validpropMrDAG
If MrDAGcheck
is different from NULL
, the proportion of proposed DAGs that comply
with the partial ordering (Perković et al. (2017) implied by the partition of the traits between
exposures and outcomes with directed causal effects only from the former to the latter
acceptpropDAG
Proportion of proposed DAGs that are accepted by the Metropolis-Hastings ratio after
burn-in
timeMrDAG
Time in minutes employed by MrDAG
algorithm to analyse the data. Considerable gains are obtained
by specifying fastMCMC = TRUE
option
hyperpar
List of the hyper-parameters list(w, a, U, tempmax)
and, if specified, MrDAGcheck
list
samplerpar
List of parameters used in the MCMC algorithm list(niter, burnin, thin)
opt
List of options used in MrDAG
algorithm list(fastMCMC, savememory, seed)
Andersson SA, Madigan D, Perlman MD (1997).
“A characterization of Markov equivalence classes for acyclic digraphs.”
Annals of Statistics, 25(2), 505–541.
doi:10.1214/aos/1031833662.
Castelletti F, Consonni G (2021).
“Bayesian inference of causal effects from observational data in Gaussian graphical models.”
Biometrics, 77, 136–149.
doi:10.1111/biom.13281.
Chickering DM (2002).
“Learning equivalence classes of bayesian-network structures.”
Journal of Machine Learning Research, 2, 445–498.
http://www.ai.mit.edu/projects/jmlr/papers/volume2/chickering02a/chickering02a.pdf.
Perković E, Kalisch M, Maathuis MH (2017).
“Interpreting and using CPDAGs with background knowledge.”
In Proceedings UAI.
http://auai.org/uai2017/proceedings/papers/120.pdf.
Zuber V, Cronjé T, Cai N, Gill D, Bottolo L (2024).
“Mendelian randomization for multiple exposures and outcomes with Bayesian Directed Acyclic Graphs exploration and causal effects estimation.”
Submitted.
# Example: Analysis of lifestyle and behavioural exposures that might impact mental health # phenotypes. 708 independent Instrumental Variables (IVs) were selected to be associated at # genome-wide significance with six lifestyle and behavioural traits after pruning or clumping, # which are considered exposures of the risk of seven mental health outcome phenotypes # After loading the data set data(LBT2MD_data) # the indices of the traits that define the outcomes and exposures are provided in a list object MrDAGcheck <- NULL MrDAGcheck$Y_idx <- 1 : 7 # Mental health phenotypes MrDAGcheck$X_idx <- 8 : 13 # Lifestyle and behavioural traits # MrDAG algorithm is run to generate 1,000 posterior samples of all unknowns output <- MrDAG(data = LBT2MD_data, niter = 5000, burnin = 2500, thin = 5, tempmax = 20, w = 0.01, MrDAGcheck = MrDAGcheck, filename = NULL)
# Example: Analysis of lifestyle and behavioural exposures that might impact mental health # phenotypes. 708 independent Instrumental Variables (IVs) were selected to be associated at # genome-wide significance with six lifestyle and behavioural traits after pruning or clumping, # which are considered exposures of the risk of seven mental health outcome phenotypes # After loading the data set data(LBT2MD_data) # the indices of the traits that define the outcomes and exposures are provided in a list object MrDAGcheck <- NULL MrDAGcheck$Y_idx <- 1 : 7 # Mental health phenotypes MrDAGcheck$X_idx <- 8 : 13 # Lifestyle and behavioural traits # MrDAG algorithm is run to generate 1,000 posterior samples of all unknowns output <- MrDAG(data = LBT2MD_data, niter = 5000, burnin = 2500, thin = 5, tempmax = 20, w = 0.01, MrDAGcheck = MrDAGcheck, filename = NULL)