CaPri is an R package for Bayesian Mendelian randomization with potentially pleiotropic genetic instruments.
Mendelian randomization uses genetic variants as instrumental variables to estimate the causal effect of an exposure on an outcome. However, genetic instruments may violate the exclusion restriction if they affect the outcome through pathways other than the exposure. CaPri is designed to model this situation by jointly estimating the causal effect and the direct pleiotropic effects of genetic instruments.
CaPri is fitted using GWAS summary statistics.
CaPri estimates:
q_delta: posterior probability of a causal effect;hat_gamma: estimated causal effect;pip_c: posterior probability that each instrument is pleiotropic;mu_betaY: estimated magnitude of the pleiotropic effect.The package provides the main function:
fit_capri_sumstats()
which fits CaPri using summary statistics.
You can install the development version of CaPri from GitHub with:
install.packages("remotes")
remotes::install_github("OuRen0104/CaPri")
Then load the package:
library(CaPri)
This example demonstrates how to apply CaPri to real GWAS summary statistics. We investigate the causal relationship between serum urate and gout using genetic instruments.
CaPri estimates the causal effect and pleiotropic effect of genetic instruments.
The Urate_Gout dataset contains harmonized GWAS summary statistics for serum urate (exposure) and gout (outcome).
library(CaPri)
# Load data
data("Urate_Gout")
# Keep SNPs passing harmonization filters
dat <- subset(
Urate_Gout,
mr_keep
)
# Inspect the summary statistics
head(
dat[, c(
"SNP",
"effect_allele.exposure",
"other_allele.exposure",
"effect_allele.outcome",
"other_allele.outcome",
"beta.exposure",
"beta.outcome",
"eaf.outcome"
)]
)
The main variables used by CaPri are:
beta.exposure: SNP-exposure association estimates for serum urate.beta.outcome: SNP-outcome association estimates for gout.eaf.outcome: effect allele frequency used for allele orientation.n: effective sample size of the outcome GWAS (see below).CaPri requires SNP-exposure association estimates (betaX), SNP-outcome association estimates (muY), and the outcome GWAS sample size (n). Since gout is a binary outcome, we use the effective sample size 4 * n_case * n_control / (n_case + n_control), with 2,115 cases and 67,259 controls.
# SNP-exposure association estimates
betaX <- as.numeric(
dat$beta.exposure
)
# SNP-outcome association estimates
muY <- as.numeric(
dat$beta.outcome
)
# Effect allele frequency
eaf <- as.numeric(
dat$eaf.outcome
)
# Effective sample size of the outcome GWAS (binary outcome)
n_case <- 2115
n_control <- 67259
n <- 4 * n_case * n_control / (n_case + n_control)
n
CaPri allows users to specify whether summary statistics should be used as supplied or converted to the minor allele direction.
By default, CaPri uses the supplied effect estimates without modification:
allele_mode = "as_is"
Alternatively, users can set:
allele_mode = "minor"
When using allele_mode = "minor", effect allele frequencies (eaf) are required. CaPri automatically flips the signs of SNP effects when the supplied effect allele corresponds to the major allele.
For this real-data example, we use the minor allele orientation:
fit <- fit_capri_sumstats(
muY = muY,
betaX = betaX,
n = n,
allele_mode = "minor",
eaf = eaf,
sigma_Y = 1.0,
verbose = FALSE
)
A fitted CaPri object contains posterior estimates of the causal effect and horizontal pleiotropic effects.
fit$q_delta
q_delta represents the posterior probability that a causal effect exists between serum urate and gout.
A value close to 1 indicates strong posterior evidence supporting a causal relationship.
fit$hat_gamma
hat_gamma is the estimated causal effect of serum urate on gout after accounting for potential horizontal pleiotropic effects.
fit$pip_c
pip_c gives the posterior probability that each genetic instrument has a direct pleiotropic effect on the outcome.
Genetic instruments with high pip_c values are more likely to violate the exclusion restriction assumption and may affect gout through pathways other than serum urate.
fit$mu_betaY
mu_betaY is the estimated pleiotropic effect of genetic instruments on gout.