| Title: | Bayesian Weighted Mendelian Randomization (BWMR) |
|---|---|
| Description: | Inference the causality based on BWMR method. |
| Authors: | Jia Zhao [aut, cre] (ORCID: <https://orcid.org/0000-0002-9107-8852>) |
| Maintainer: | Jia Zhao <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.1 |
| Built: | 2026-05-31 07:23:27 UTC |
| Source: | https://github.com/remlapmot/BWMR |
Performs variational EM inference for the BWMR model, estimating the causal effect of an exposure on an outcome using summary-level GWAS data.
BWMR(gammahat, Gammahat, sigmaX, sigmaY, alpha = 100, sqsigma0 = (1e+06)^2)BWMR(gammahat, Gammahat, sigmaX, sigmaY, alpha = 100, sqsigma0 = (1e+06)^2)
gammahat |
Numeric vector of SNP-exposure effect estimates. |
Gammahat |
Numeric vector of SNP-outcome effect estimates. |
sigmaX |
Numeric vector of standard errors for the SNP-exposure effects. |
sigmaY |
Numeric vector of standard errors for the SNP-outcome effects. |
alpha |
Numeric scalar; concentration parameter for the Beta prior on
the proportion of valid instruments. Default is |
sqsigma0 |
Numeric scalar; prior variance for beta. Default is
|
A list containing:
beta |
Causal effect estimate. |
se_beta |
Standard error of the causal effect estimate. |
P_value |
P-value from a chi-squared test (1 df). |
weights |
Posterior mean weights for each SNP. |
tau |
Estimate of the pleiotropy noise parameter. |
sigma |
Estimate of the instrument strength parameter. |
mu_pi |
Posterior mean of the proportion of valid instruments. |
plot1 |
Scatter plot of SNP effects with error bars (ggplot2). |
plot2 |
ELBO convergence plot (ggplot2). |
plot3 |
Bar chart of posterior mean weights per SNP (ggplot2). |
plot4 |
Weighted scatter plot with regression line (ggplot2). |
data(ExampleData) result <- BWMR( gammahat = ExampleData$beta.exposure, Gammahat = ExampleData$beta.outcome, sigmaX = ExampleData$se.exposure, sigmaY = ExampleData$se.outcome ) result$beta result$P_valuedata(ExampleData) result <- BWMR( gammahat = ExampleData$beta.exposure, Gammahat = ExampleData$beta.outcome, sigmaX = ExampleData$se.exposure, sigmaY = ExampleData$se.outcome ) result$beta result$P_value
A faster version of BWMR() that omits diagnostic plots. Suitable for
simulation studies or large-scale analyses where plotting is unnecessary.
BWMR_quick( gammahat, Gammahat, sigmaX, sigmaY, alpha = 100, sqsigma0 = (1e+06)^2 )BWMR_quick( gammahat, Gammahat, sigmaX, sigmaY, alpha = 100, sqsigma0 = (1e+06)^2 )
gammahat |
Numeric vector of SNP-exposure effect estimates. |
Gammahat |
Numeric vector of SNP-outcome effect estimates. |
sigmaX |
Numeric vector of standard errors for the SNP-exposure effects. |
sigmaY |
Numeric vector of standard errors for the SNP-outcome effects. |
alpha |
Numeric scalar; concentration parameter for the Beta prior on
the proportion of valid instruments. Default is |
sqsigma0 |
Numeric scalar; prior variance for beta. Default is
|
A list containing:
beta |
Causal effect estimate. |
se_beta |
Standard error of the causal effect estimate. |
P_value |
P-value from a chi-squared test (1 df). |
tau |
Estimate of the pleiotropy noise parameter. |
sigma |
Estimate of the instrument strength parameter. |
mu_pi |
Posterior mean of the proportion of valid instruments. |
data(ExampleData) result <- BWMR_quick( gammahat = ExampleData$beta.exposure, Gammahat = ExampleData$beta.outcome, sigmaX = ExampleData$se.exposure, sigmaY = ExampleData$se.outcome ) result$beta result$P_valuedata(ExampleData) result <- BWMR_quick( gammahat = ExampleData$beta.exposure, Gammahat = ExampleData$beta.outcome, sigmaX = ExampleData$se.exposure, sigmaY = ExampleData$se.outcome ) result$beta result$P_value
An example Mendelian randomization dataset.
ExampleDataExampleData
ExampleDataA data frame with 76 rows and 5 columns:
SNP genotype
SNP-exposure estimates
SNP-outcome estimates
Standard errors of the SNP-exposure estimates
Standard errors of the SNP-outcome estimates