Package 'MRBEE'

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-09-24 14:13:17 UTC
Source: https://github.com/noahlorinczcomi/MRBEE

Help Index


Estimate Error Covariance Matrix Using GWAS Insignificant Effects

Description

This function estimates the error covariance matrix by subsampling a proportion of insignificant GWAS effects and calculating their correlation coefficients.

Usage

errorCov(
  ZMatrix,
  Zscore.cutoff = 2,
  subsampling.ratio = 0.1,
  subsampling.time = 1000
)

Arguments

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.

Value

A matrix representing the estimated error covariance.


Filter and Align GWAS Data to a Reference Panel

Description

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.

Usage

filter_align(gwas_data_list, ref_panel, allele_match = TRUE)

Arguments

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 TRUE.

Details

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.

Value

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.

Examples

## Not run: 
# Assuming GWAS_List and ref_panel are already defined:
GWAS_List <- filter_align(GWAS_List, ref_panel)

## End(Not run)

HapMap3 and UKBB Genotype SNP Data

Description

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.

Usage

data(hapmap3)

Format

A data frame with 1,664,852 rows and 3 variables:

SNP

SNP identifier.

A1

Effect allele.

A2

Reference allele.

Source

1000 Genomes Project Phase 3 and UK Biobank genotype data.


Perform Joint Test on GWAS Summary Data

Description

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.

Usage

Joint.test(bZ, RZ)

Arguments

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.

Value

A data frame with two columns: 'Chi2', containing the Chi-squared values for each genetic variant, and 'P', containing the corresponding P-values.

Examples

## 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)

Estimate Causal Effect with MRBEE

Description

This function estimates the causal effect using a bias-correction estimating equation, considering potential pleiotropy and measurement errors.

Usage

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
)

Arguments

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.

Value

A list containing the estimated causal effect, its covariance, and pleiotropy


Estimate Causal Effect with MRBEE

Description

This function estimates the causal effect using a bias-correction estimating equation with an intercept, considering potential pleiotropy and measurement errors.

Usage

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
)

Arguments

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.

Value

A list containing the estimated causal effect, its covariance, and pleiotropy


Univariable MR Estimation using MRBEE Method

Description

This function performs univariable Mendelian Randomization (MR) analysis using the MRBEE method.

Usage

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"
)

Arguments

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".

Value

A list containing the estimated causal effect, its covariance, and pleiotropy