| Title: | Robust Mendelian Randomization method to account for Idiosyncratic and Correlated Pleiotropy |
|---|---|
| Description: | Robust Mendelian Randomization method to account for Idiosyncratic and Correlated Pleiotropy. |
| Authors: | Qing Cheng [aut, cre] (ORCID: <https://orcid.org/0000-0001-5144-4515>) |
| Maintainer: | Qing Cheng <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0 |
| Built: | 2026-05-15 09:41:13 UTC |
| Source: | https://github.com/remlapmot/RMR.ICP |
Implements a robust Mendelian Randomization method (RMR-ICP) that accounts for both idiosyncratic and correlated pleiotropy using a Gibbs sampler.
Qing Cheng [email protected]
Simulated GWAS summary statistics and LD reference data for demonstrating the RMR-ICP method.
gamma1_Indep, gamma1_LD: SNP-exposure effect estimates
(independent and LD-structured scenarios, respectively).
Gamma2_Indep, Gamma2_LD: SNP-outcome effect estimates
(independent and LD-structured scenarios, respectively).
se1_Indep, se1_LD: Standard errors for the exposure
effect estimates.
se2_Indep, se2_LD: Standard errors for the outcome
effect estimates.
R: LD correlation matrix (2000 x 2000) for the LD scenario.
block_inf1: Block boundary matrix (200 x 2) giving the start
and end indices of each LD block (0-indexed).
data(gamma1_Indep) data(gamma1_LD) data(Gamma2_Indep) data(Gamma2_LD) data(se1_Indep) data(se1_LD) data(se2_Indep) data(se2_LD) data(R) data(block_inf1)data(gamma1_Indep) data(gamma1_LD) data(Gamma2_Indep) data(Gamma2_LD) data(se1_Indep) data(se1_LD) data(se2_Indep) data(se2_LD) data(R) data(block_inf1)
Numeric matrices. The _Indep datasets have 100 rows (SNPs);
the _LD datasets have 2000 rows. R is a 2000 x 2000 matrix.
block_inf1 is a 200 x 2 integer matrix of block boundaries.
data(gamma1_Indep) data(Gamma2_Indep) data(se1_Indep) data(se2_Indep) res <- RMRICPindep(gamma1_Indep, Gamma2_Indep, se1_Indep, se2_Indep)data(gamma1_Indep) data(Gamma2_Indep) data(se1_Indep) data(se2_Indep) res <- RMRICPindep(gamma1_Indep, Gamma2_Indep, se1_Indep, se2_Indep)
genRawGeno simulates a genotype matrix with a block correlation structure.
genSumStat takes a genotype matrix and generates GWAS summary statistics
under a specified causal and pleiotropic model.
traceplot plots the Gibbs sampler trace of the causal effect estimate.
genRawGeno(maf, L, M, rho, n) genSumStat(x12, n1, n2, M, L, b1, Alrate, sigma2g, dfA, delta, h2a, h2g) traceplot(bhatpoint)genRawGeno(maf, L, M, rho, n) genSumStat(x12, n1, n2, M, L, b1, Alrate, sigma2g, dfA, delta, h2a, h2g) traceplot(bhatpoint)
maf |
Numeric vector of minor allele frequencies (length |
L |
Number of LD blocks. |
M |
Number of SNPs per block. |
rho |
Within-block LD correlation parameter (AR(1) structure). |
n |
Total sample size. |
x12 |
Genotype matrix ( |
n1 |
Sample size for exposure GWAS. |
n2 |
Sample size for outcome GWAS. |
b1 |
True causal effect of exposure on outcome. |
Alrate |
Proportion of blocks with correlated pleiotropic effects. |
sigma2g |
Variance of genetic effects. |
dfA |
Degrees of freedom for the t-distributed correlated pleiotropy. |
delta |
Scaling factor for correlated pleiotropy. |
h2a |
Heritability explained by pleiotropic effects. |
h2g |
Heritability of the exposure explained by genetics. |
bhatpoint |
Numeric vector of posterior samples of the causal effect. |
genRawGeno returns a numeric genotype matrix with n rows and
L*M columns.
genSumStat returns a list with components gammah, se1,
se2, Gammah, and CHPindex.
traceplot returns a ggplot object.
These four functions are created when
RcppArmadillo.package.skeleton() is invoked to create a
skeleton packages.
rcpparma_hello_world() rcpparma_outerproduct(x) rcpparma_innerproduct(x) rcpparma_bothproducts(x)rcpparma_hello_world() rcpparma_outerproduct(x) rcpparma_innerproduct(x) rcpparma_bothproducts(x)
x |
a numeric vector |
These are example functions which should be largely self-explanatory. Their main benefit is to demonstrate how to write a function using the Armadillo C++ classes, and to have to such a function accessible from R.
rcpparma_hello_world() does not return a value, but displays a
message to the console.
rcpparma_outerproduct() returns a numeric matrix computed as the
outer (vector) product of x.
rcpparma_innerproduct() returns a double computer as the inner
(vector) product of x.
rcpparma_bothproducts() returns a list with both the outer and
inner products.
Dirk Eddelbuettel
See the documentation for Armadillo, and RcppArmadillo, for more details.
x <- sqrt(1:4) rcpparma_innerproduct(x) rcpparma_outerproduct(x)x <- sqrt(1:4) rcpparma_innerproduct(x) rcpparma_outerproduct(x)
ReadSummaryStat reads GWAS summary statistics for the exposure and outcome,
performs quality control (MHC region removal, allele filtering), aligns to a
reference panel, and organises data into LD blocks ready for RMRICP.
EstRho estimates the correlation between exposure and outcome GWAS using
null SNPs via a truncated Gibbs sampler.
ReadSummaryStat(fileexp, fileout, filepan, snpinfo, pva_cutoff, lambad) EstRho(fileexp, fileout, filepan, snpinfo, ld_r2_thresh, lambad, pth)ReadSummaryStat(fileexp, fileout, filepan, snpinfo, pva_cutoff, lambad) EstRho(fileexp, fileout, filepan, snpinfo, ld_r2_thresh, lambad, pth)
fileexp |
Path to the exposure GWAS summary statistics file. |
fileout |
Path to the outcome GWAS summary statistics file. |
filepan |
Named list (by chromosome) of paths to LD panel RDS files. |
snpinfo |
Path to reference SNP information RDS file. |
pva_cutoff |
p-value threshold for selecting instruments from the exposure GWAS. |
lambad |
Shrinkage factor applied to off-diagonal LD correlations. |
ld_r2_thresh |
LD r-squared threshold for clumping (used in |
pth |
Numeric vector of z-score thresholds used to define null SNPs for rho estimation. |
ReadSummaryStat returns a list of LD-block-structured summary statistics
suitable for passing to RMRICP.
EstRho returns a list with components rhohat, pvalue,
pres, and Rhores.
Perform robust Mendelian Randomization using a Gibbs sampler that accounts for
both idiosyncratic and correlated horizontal pleiotropy.
RMRICP handles the general case with LD structure;
RMRICPindep assumes independent instruments;
RMRICPSim works with a pre-specified LD matrix and block structure.
RMRICP(F4gammah, F4Gammah, F4se1, F4se2, F4Rblock, opts = NULL) RMRICPindep(gammah, Gammah, se1, se2, opts = NULL) RMRICPSim(gammah, Gammah, se1, se2, R, block_inf, opts = NULL)RMRICP(F4gammah, F4Gammah, F4se1, F4se2, F4Rblock, opts = NULL) RMRICPindep(gammah, Gammah, se1, se2, opts = NULL) RMRICPSim(gammah, Gammah, se1, se2, R, block_inf, opts = NULL)
F4gammah |
List of numeric vectors of SNP-exposure effect estimates per LD block. |
F4Gammah |
List of numeric vectors of SNP-outcome effect estimates per LD block. |
F4se1 |
List of numeric vectors of standard errors for |
F4se2 |
List of numeric vectors of standard errors for |
F4Rblock |
List of LD correlation matrices per block. |
gammah |
Numeric vector of SNP-exposure effect estimates. |
Gammah |
Numeric vector of SNP-outcome effect estimates. |
se1 |
Numeric vector of standard errors for |
se2 |
Numeric vector of standard errors for |
R |
LD correlation matrix. |
block_inf |
Matrix of block boundary indices. |
opts |
Optional list of MCMC options (e.g., iterations, burn-in, thinning). |
A list containing posterior samples and summary estimates of the causal effect.
data(gamma1_Indep) data(Gamma2_Indep) data(se1_Indep) data(se2_Indep) res <- RMRICPindep(gamma1_Indep, Gamma2_Indep, se1_Indep, se2_Indep)data(gamma1_Indep) data(Gamma2_Indep) data(se1_Indep) data(se2_Indep) res <- RMRICPindep(gamma1_Indep, Gamma2_Indep, se1_Indep, se2_Indep)