Title: | Mendelian Randomization using Bias-Corrected Estimating Equation and Iterative Pleiotropy Testing |
---|---|
Description: | This package performs multivariate Mendelian randomization. It is characterized by the removal of measurement error bias caused by the estimation error of GWAS effect size estimates using an unbiased estimating function in measurement error analysis. It also utilizes a pleiotropy test to dynamically detect and remove potential pleiotropy, making the causal effect robust to pleiotropy. |
Authors: | Noah Lorincz-Comi [aut, cre] , Yihe Yang [aut] |
Maintainer: | Noah Lorincz-Comi <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-12-23 05:30:55 UTC |
Source: | https://github.com/noahlorinczcomi/MRBEE |
This function estimates the error covariance matrix by subsampling a proportion of insignificant GWAS effects and calculating their correlation coefficients.
errorCov( ZMatrix, Zscore.cutoff = 2, subsampling.ratio = 0.1, subsampling.time = 1000 )
errorCov( ZMatrix, Zscore.cutoff = 2, subsampling.ratio = 0.1, subsampling.time = 1000 )
ZMatrix |
A matrix of Z-scores for exposure and outcome, with the outcome GWAS in the last column. |
Zscore.cutoff |
The cutoff for significance. Defaults to 2. |
subsampling.ratio |
The proportion of effects to subsample for each iteration. Defaults to 0.1. |
subsampling.time |
The number of subsampling iterations. Defaults to 1000. |
A matrix representing the estimated error covariance.
The filter_align
function processes a list of GWAS summary statistics data frames, harmonizes alleles according to a reference panel, removes duplicates, and aligns data to common SNPs. It's used to prepare data for further analysis such as LDSC.
filter_align(gwas_data_list, ref_panel, allele_match = TRUE)
filter_align(gwas_data_list, ref_panel, allele_match = TRUE)
gwas_data_list |
A list of data.frames where each data.frame contains GWAS summary statistics for a trait. Each data.frame should include columns for SNP identifiers, Z-scores of effect size estimates, sample sizes (N), effect allele (A1), and reference allele (A2). |
ref_panel |
A data.frame containing the reference panel data. It must include columns for SNP, A1, and A2. |
allele_match |
Logical. Whether to match alleles. Default |
The function performs several key steps: adjusting alleles according to a reference panel, removing duplicate SNPs, and aligning all GWAS data frames to a set of common SNPs. This is often a necessary preprocessing step before performing genetic correlation and heritability analyses.
A list of data.frames, each corresponding to an input GWAS summary statistics data frame, but filtered, harmonized, and aligned to the common SNPs found across all data frames.
## Not run: # Assuming GWAS_List and ref_panel are already defined: GWAS_List <- filter_align(GWAS_List, ref_panel) ## End(Not run)
## Not run: # Assuming GWAS_List and ref_panel are already defined: GWAS_List <- filter_align(GWAS_List, ref_panel) ## End(Not run)
A data frame containing combined SNP data from 1000 Genomes Project Phase 3 and UK Biobank (UKBB) genotypes. It includes a total of 1,664,852 SNPs.
data(hapmap3)
data(hapmap3)
A data frame with 1,664,852 rows and 3 variables:
SNP identifier.
Effect allele.
Reference allele.
1000 Genomes Project Phase 3 and UK Biobank genotype data.
This function conducts a joint test on GWAS summary data, calculating Chi-squared values and corresponding P-values based on allele-aligned Z-scores and the correlation matrix of estimation errors for these Z-scores.
Joint.test(bZ, RZ)
Joint.test(bZ, RZ)
bZ |
A matrix of allele-aligned Z-scores from GWAS summary data, where each row represents a different genetic variant and each column represents a different trait or study. The matrix dimensions are n x p, with n being the number of variants and p being the number of traits or studies. |
RZ |
The correlation matrix of estimation errors for the Z-scores in 'bZ'. This matrix should be p x p, where p is the number of traits or studies. |
A data frame with two columns: 'Chi2', containing the Chi-squared values for each genetic variant, and 'P', containing the corresponding P-values.
## Not run: # Example usage: # Assuming bZ is your matrix of allele-aligned Z-scores and RZ is the correlation matrix result <- Joint.test(bZ, RZ) ## End(Not run)
## Not run: # Example usage: # Assuming bZ is your matrix of allele-aligned Z-scores and RZ is the correlation matrix result <- Joint.test(bZ, RZ) ## End(Not run)
This function estimates the causal effect using a bias-correction estimating equation, considering potential pleiotropy and measurement errors.
MRBEE.IMRP( by, bX, byse, bXse, Rxy, max.iter = 30, max.eps = 1e-04, pv.thres = 0.05, var.est = "robust", FDR = T, adjust.method = "Sidak", maxdiff = 3 )
MRBEE.IMRP( by, bX, byse, bXse, Rxy, max.iter = 30, max.eps = 1e-04, pv.thres = 0.05, var.est = "robust", FDR = T, adjust.method = "Sidak", maxdiff = 3 )
by |
A vector (n x 1) of the GWAS effect size of outcome. |
bX |
A matrix (n x p) of the GWAS effect sizes of p exposures. |
byse |
A vector (n x 1) of the GWAS effect size SE of outcome. |
bXse |
A matrix (n x p) of the GWAS effect size SEs of p exposures. |
Rxy |
A matrix (p+1 x p+1) of the correlation matrix of the p exposures and outcome. The last one should be the outcome. |
max.iter |
Maximum number of iterations for causal effect estimation. Defaults to 30. |
max.eps |
Tolerance for stopping criteria. Defaults to 1e-4. |
pv.thres |
P-value threshold in pleiotropy detection. Defaults to 0.05. |
var.est |
Method for estimating the variance of residual in pleiotropy test. Can be "robust", "variance", or "ordinal". Defaults is robust that estimates the variance of residual using median absolute deviation (MAD). |
FDR |
Logical. Whether to apply the FDR to convert the p-value to q-value. Defaults to TRUE. |
adjust.method |
Method for estimating q-value. Defaults to "Sidak". |
maxdiff |
The maximum difference between the MRBEE causal estimate and the initial estimator. Defaults to 3. |
A list containing the estimated causal effect, its covariance, and pleiotropy
This function estimates the causal effect using a bias-correction estimating equation with an intercept, considering potential pleiotropy and measurement errors.
MRBEE.IMRP.Egger( by, bX, byse, bXse, Rxy, max.iter = 30, max.eps = 1e-04, pv.thres = 0.05, var.est = "robust", FDR = T, adjust.method = "Sidak", maxdiff = 3 )
MRBEE.IMRP.Egger( by, bX, byse, bXse, Rxy, max.iter = 30, max.eps = 1e-04, pv.thres = 0.05, var.est = "robust", FDR = T, adjust.method = "Sidak", maxdiff = 3 )
by |
A vector (n x 1) of the GWAS effect size of outcome. |
bX |
A matrix (n x p) of the GWAS effect sizes of p exposures. |
byse |
A vector (n x 1) of the GWAS effect size SE of outcome. |
bXse |
A matrix (n x p) of the GWAS effect size SEs of p exposures. |
Rxy |
A matrix (p+1 x p+1) of the correlation matrix of the p exposures and outcome. The last one should be the outcome. |
max.iter |
Maximum number of iterations for causal effect estimation. Defaults to 30. |
max.eps |
Tolerance for stopping criteria. Defaults to 1e-4. |
pv.thres |
P-value threshold in pleiotropy detection. Defaults to 0.05. |
var.est |
Method for estimating the variance of residual in pleiotropy test. Can be "robust", "variance", or "ordinal". Defaults is robust that estimates the variance of residual using median absolute deviation (MAD). |
FDR |
Logical. Whether to apply the FDR to convert the p-value to q-value. Defaults to TRUE. |
adjust.method |
Method for estimating q-value. Defaults to "Sidak". |
maxdiff |
The maximum difference between the MRBEE causal estimate and the initial estimator. Defaults to 3. |
A list containing the estimated causal effect, its covariance, and pleiotropy
This function performs univariable Mendelian Randomization (MR) analysis using the MRBEE method.
MRBEE.IMRP.UV( by, bx, byse, bxse, Rxy, max.iter = 30, max.eps = 1e-04, pv.thres = 0.05, var.est = "robust", FDR = T, adjust.method = "Sidak" )
MRBEE.IMRP.UV( by, bx, byse, bxse, Rxy, max.iter = 30, max.eps = 1e-04, pv.thres = 0.05, var.est = "robust", FDR = T, adjust.method = "Sidak" )
by |
Vector of GWAS effect sizes for the outcome (n x 1). |
bx |
Vector of GWAS effect sizes for the exposure (n x 1). |
byse |
Vector of standard errors (SE) for the GWAS effect sizes of the outcome (n x 1). |
bxse |
Vector of SE for the GWAS effect sizes of the exposure (n x 1). |
Rxy |
Correlation matrix (p+1 x p+1) of the exposures and outcome, with the outcome being the last. |
max.iter |
Maximum number of iterations for the estimation process. Defaults to 30. |
max.eps |
Tolerance level for convergence. Defaults to 1e-4. |
pv.thres |
P-value threshold for pleiotropy detection. Defaults to 0.05. |
var.est |
Method for estimating the standard error in the pleiotropy test. Can be "robust", "variance", or "ordinal". |
FDR |
Logical indicating whether to apply False Discovery Rate (FDR) correction. Defaults to TRUE. |
adjust.method |
Method for estimating q-values, defaults to "Sidak". |
A list containing the estimated causal effect, its covariance, and pleiotropy