| Title: | MR.Corr2 |
|---|---|
| Description: | More details about what the package does. See <http://cran.r-project.org/doc/manuals/r-release/R-exts.html#The-DESCRIPTION-file> for details on how to write this part. |
| Authors: | Your Name |
| Maintainer: | Your Name <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0 |
| Built: | 2026-06-03 06:34:44 UTC |
| Source: | https://github.com/remlapmot/MR.Corr2 |
MR.Corr2 implements a Bayesian two-sample Mendelian randomization method that simultaneously accounts for linkage disequilibrium (LD) among instrumental variants and correlated horizontal pleiotropy. Inference is performed via a block-parallel Gibbs sampler implemented in C++ using RcppArmadillo.
Main analysis functions:
MRcorrMR analysis assuming independent SNPs (no LD).
MRCorr2SimMR analysis with LD using a pre-computed LD matrix (e.g. from simulated data).
MRCorr2RealMR analysis with LD computed on-the-fly from a reference panel (for real GWAS data).
Data preparation functions:
matchscreenMatch and p-value screen SNPs across exposure, outcome, and reference panel files.
summaryQCQC filters: remove MHC region SNPs and SNPs with extreme chi-square statistics.
ReadSNPinfoRead SNP annotation from reference panel.
Read_summarystatRead GWAS summary statistics.
matchsnpMatch SNPs between files.
getLineNumCount lines in a file.
LD computation functions:
Cal_blockRCompute block LD matrices from a reference panel (returns field of matrices).
Cal_block_RmatrixCompute block LD as a single full matrix from a reference panel.
Cal_blockinfDetermine block structure for a set of SNPs.
Cal_block_SimRCompute block LD from simulated genotypes.
LDclumpLD-based clumping within a block.
load_block_fileLoad LD block definitions from file.
test_blocksCheck block assignments for SNPs.
Simulation and visualisation:
genRawGenoGenerate simulated genotype data with AR1 LD structure.
traceplotTrace plot of Gibbs sampler output.
fastSigLmFast simple linear regression for SNP screening.
Qing Cheng [email protected]
Cheng, Q., Qiu, T., Chai, X., Sun, B., Xia, Y., Shi, X., and Liu, J. (2021). MR-Corr2: a two-sample Mendelian randomization method that accounts for correlated horizontal pleiotropy using correlated instrumental variants. Bioinformatics. doi:10.1093/bioinformatics/btab646.
The package vignette provides worked examples for both simulation and real
data analyses: vignette("MR.Corr2").
Similar to Cal_blockR, but returns the block LD matrices
assembled into a single full sparse-block LD matrix rather than an Armadillo
field. Useful when the full matrix representation is needed.
Cal_block_Rmatrix(bp, chr, avbIndex, idx4panel, block_file, stringname3, ld_r2_thresh, coreNum, lam)Cal_block_Rmatrix(bp, chr, avbIndex, idx4panel, block_file, stringname3, ld_r2_thresh, coreNum, lam)
bp |
Integer vector of base pair positions for the analysis SNPs. |
chr |
Integer vector of chromosome numbers for the analysis SNPs. |
avbIndex |
Integer vector of 0-based indices of the analysis SNPs within the reference panel. |
idx4panel |
Integer vector of 0-based indices of reference panel SNPs used for LD estimation. |
block_file |
Character string giving the path to the LD block definition file. |
stringname3 |
Character string giving the path prefix for PLINK binary
reference panel files ( |
ld_r2_thresh |
Numeric |
coreNum |
Integer number of CPU cores for parallel computation. |
lam |
Numeric regularisation parameter for positive-definite correction of LD matrices. |
A named list containing:
Numeric matrix of full block-diagonal LD correlations (p x p).
Integer matrix of 0-based block start/end indices.
Integer number of LD blocks.
Integer vector of SNP indices retained after LD clumping.
Cal_blockR, Cal_block_SimR,
MRCorr2Sim
Computes a block-diagonal LD correlation matrix from a simulated genotype matrix. Each block's correlation matrix is regularised to ensure positive definiteness.
Cal_block_SimR(block_inf, X, lam)Cal_block_SimR(block_inf, X, lam)
block_inf |
Integer matrix defining LD blocks. Each row gives the
0-based start and end column indices of one block within |
X |
Integer matrix of simulated genotypes (individuals x SNPs), with
values 0, 1, or 2. Can be generated using |
lam |
Numeric regularisation parameter. Values above 0.5 apply linear
shrinkage towards the identity; values at or below 0.5 use the
|
A numeric matrix of block-diagonal LD correlations (p x p), where p is the number of SNPs. Off-diagonal entries between different blocks are zero.
genRawGeno, Cal_blockinf,
MRCorr2Sim
Given chromosomal positions of SNPs and a block definition file, determines
which LD block each SNP belongs to and returns a matrix of block start/end
indices into the SNP vectors. This block structure is used by
MRCorr2Sim and Cal_block_SimR.
Cal_blockinf(bp, chr, block_file)Cal_blockinf(bp, chr, block_file)
bp |
Integer vector of base pair positions for each SNP. |
chr |
Integer vector of chromosome numbers for each SNP. |
block_file |
Character string giving the path to the LD block
definition file. See |
An integer matrix with one row per non-empty LD block. Each row contains the 0-based start and end indices of the SNPs in that block within the input vectors.
load_block_file, Cal_blockR,
Cal_block_SimR, MRCorr2Sim
Reads genotype data from a reference panel (PLINK binary format) and computes regularised LD correlation matrices for each LD block. The result includes block LD matrices, block boundary information, and a clumped set of independent SNP indices.
Cal_blockR(bp, chr, avbIndex, idx4panel, block_file, stringname3, ld_r2_thresh, coreNum, lam)Cal_blockR(bp, chr, avbIndex, idx4panel, block_file, stringname3, ld_r2_thresh, coreNum, lam)
bp |
Integer vector of base pair positions for the analysis SNPs. |
chr |
Integer vector of chromosome numbers for the analysis SNPs. |
avbIndex |
Integer vector of 0-based indices of the analysis SNPs within the reference panel. |
idx4panel |
Integer vector of 0-based indices of reference panel SNPs used for LD estimation. |
block_file |
Character string giving the path to the LD block definition file. |
stringname3 |
Character string giving the path prefix for PLINK binary
reference panel files ( |
ld_r2_thresh |
Numeric |
coreNum |
Integer number of CPU cores for parallel computation. |
lam |
Numeric regularisation parameter for positive-definite correction
of LD matrices. Values above 0.5 use linear shrinkage; values at or below
0.5 use the |
A named list containing:
An Armadillo field of block LD matrices, one per block.
Integer matrix of 0-based block start/end indices.
Integer number of LD blocks.
Integer vector of SNP indices retained after LD clumping.
Cal_block_Rmatrix, Cal_blockinf,
LDclump, MRCorr2Real
Performs simple linear regression of a response vector y on each
column of a matrix X separately, returning coefficient estimates
and their standard errors. This is a vectorised implementation intended
for rapid screening of SNP-trait associations.
fastSigLm(y, X)fastSigLm(y, X)
y |
Numeric vector of the response variable (n observations). |
X |
Numeric matrix of predictors (n observations x p SNPs). Each
column is regressed against |
A named list with:
Numeric vector of slope estimates (one per column of X).
Numeric vector of standard errors for the slope estimates.
Generates a simulated genotype matrix for n individuals at
L * M SNPs arranged in L independent blocks each containing
M SNPs. Within each block, SNPs are correlated according to a
first-order autoregressive (AR1) correlation structure with parameter
rho. Genotypes (0, 1, 2) are generated by thresholding a
multivariate normal distribution according to the specified minor allele
frequencies.
genRawGeno(maf, L, M, rho, n)genRawGeno(maf, L, M, rho, n)
maf |
Numeric vector of minor allele frequencies, one per SNP
(length |
L |
Integer number of independent LD blocks. |
M |
Integer number of SNPs per block. |
rho |
Numeric AR1 correlation parameter controlling LD within each
block. Must be in |
n |
Integer number of individuals (sample size). |
Requires the mvtnorm package for multivariate normal sampling
(rmvnorm).
An integer matrix of dimensions n x L * M with genotype
values 0, 1, or 2.
Cal_block_SimR, fastSigLm,
MRCorr2Sim
## Not run: library(mvtnorm) set.seed(1) L <- 10; M <- 5; n <- 500 maf <- runif(L * M, 0.1, 0.5) X <- genRawGeno(maf, L, M, rho = 0.5, n = n) dim(X) # 500 x 50 ## End(Not run)## Not run: library(mvtnorm) set.seed(1) L <- 10; M <- 5; n <- 500 maf <- runif(L * M, 0.1, 0.5) X <- genRawGeno(maf, L, M, rho = 0.5, n = n) dim(X) # 500 x 50 ## End(Not run)
Returns the number of lines in a text file. Used to determine the number
of SNPs or samples before allocating vectors for
ReadSNPinfo or Read_summarystat.
getLineNum(filename)getLineNum(filename)
filename |
Character string giving the path to the file. |
An integer giving the number of lines in the file.
A placeholder function that prints a greeting. Not used in analyses.
hello(txt = "world")hello(txt = "world")
txt |
Character string to print. Default is |
Called for its side effect of printing to the console. Returns NULL
invisibly.
hello() hello("MR.Corr2")hello() hello("MR.Corr2")
Performs LD-based clumping to select a set of approximately independent
SNPs from a block LD correlation matrix. Starting from the top SNP in each
block, removes SNPs with above the threshold with any retained SNP.
LDclump(R, ld_r2_thresh)LDclump(R, ld_r2_thresh)
R |
Numeric matrix of LD correlations (p x p) for SNPs within a block. |
ld_r2_thresh |
Numeric |
An integer vector of 0-based indices of the retained SNPs after clumping.
Reads an LD block definition file (e.g., the EUR block file from Berisa and Pickrell 2016) into memory as a matrix of chromosomal start and end positions for each block.
load_block_file(block_file)load_block_file(block_file)
block_file |
Character string giving the path to the LD block file. The file should have columns for chromosome, start position, and end position. |
A matrix with one row per LD block and columns for chromosome number, start base pair position, and end base pair position.
Berisa, T. and Pickrell, J.K. (2016). Approximately independent linkage disequilibrium blocks in human populations. Bioinformatics, 32(2), 283–285.
Cal_blockinf, test_blocks,
Cal_blockR
Matches SNPs from two GWAS summary statistics files and a reference panel, and then screens them by p-value using a separate screening summary statistics file. Only SNPs that pass the p-value threshold and are present in all three files are retained.
matchscreen(screenname, stringname1, stringname2, stringname3, pva_cutoff, matchExp = FALSE)matchscreen(screenname, stringname1, stringname2, stringname3, pva_cutoff, matchExp = FALSE)
screenname |
Character string giving the path to the GWAS summary statistics file used for screening (typically the exposure GWAS used to select instrumental variables). |
stringname1 |
Character string giving the path to the first GWAS summary statistics file (exposure). |
stringname2 |
Character string giving the path to the second GWAS summary statistics file (outcome). |
stringname3 |
Character string giving the path prefix for the reference panel genotype files (PLINK binary format). |
pva_cutoff |
Numeric p-value threshold for selecting instrumental
variables from |
matchExp |
Logical. If |
A named list containing:
Numeric vector of SNP-exposure effect estimates for matched SNPs.
Numeric vector of SNP-outcome effect estimates for matched SNPs.
Numeric vector of standard errors for bh1.
Numeric vector of standard errors for bh2.
Integer vector of base pair positions.
Integer vector of chromosome numbers.
Character vector of rs IDs.
Integer vector of 0-based SNP indices in the reference panel.
Integer vector of 0-based indices for the reference panel LD calculation subset.
matchsnp, summaryQC,
MRCorr2Real
Matches SNPs present in two GWAS summary statistics files against a reference panel, identifying the common set of SNPs available for Mendelian randomization analysis.
matchsnp(stringname1, stringname2, stringname3, matchExp)matchsnp(stringname1, stringname2, stringname3, matchExp)
stringname1 |
Character string giving the path to the first GWAS summary statistics file (typically the exposure GWAS). |
stringname2 |
Character string giving the path to the second GWAS summary statistics file (typically the outcome GWAS). |
stringname3 |
Character string giving the path prefix for the reference panel genotype files (PLINK binary format). |
matchExp |
Logical. If |
A named list containing integer vectors of indices identifying the matched SNPs in the reference panel and each summary statistics file.
matchscreen, ReadSNPinfo,
Read_summarystat
Performs two-sample Mendelian randomization using a Bayesian Gibbs sampling
approach that accounts for correlated horizontal pleiotropy. This function
assumes independent instrumental variants (no LD between SNPs). For analyses
with correlated SNPs, see MRCorr2Sim and MRCorr2Real.
MRcorr(gammah, Gammah, se1, se2, opts = NULL)MRcorr(gammah, Gammah, se1, se2, opts = NULL)
gammah |
Numeric vector of SNP-exposure effect estimates (GWAS summary statistics for the exposure trait). |
Gammah |
Numeric vector of SNP-outcome effect estimates (GWAS summary
statistics for the outcome trait). Must be the same length as |
se1 |
Numeric vector of standard errors for the SNP-exposure effects.
Must be the same length as |
se2 |
Numeric vector of standard errors for the SNP-outcome effects.
Must be the same length as |
opts |
Optional named list of Gibbs sampler hyperparameters and MCMC
settings. If |
The model assumes that each SNP either acts as a valid instrument
() or exhibits horizontal pleiotropy ().
The causal effect is estimated from valid instruments, while
captures the pleiotropic contribution.
The opts list may contain the following named elements:
Shape hyperparameter for the inverse-gamma prior on instrument
effect variance . Default: 1.
Scale hyperparameter for the inverse-gamma prior on
. Default: 0.1.
Shape hyperparameter for the inverse-gamma prior on pleiotropic
effect variance . Default: 1.
Scale hyperparameter for the inverse-gamma prior on
. Default: 0.1.
First shape parameter for the Beta prior on the mixture weight
. Default: 1.
Second shape parameter for the Beta prior on .
Default: 1.
Number of Gibbs sampling iterations after burn-in. Default: 10000.
Thinning interval for saving Gibbs samples. Default: 1.
Number of burn-in iterations discarded before saving. Default: 2000.
A named list containing the following components:
Integer vector of final indicator values for each SNP (1 = valid instrument, 0 = pleiotropic).
Numeric vector of saved posterior proportion of valid instruments across MCMC iterations.
Integer matrix (SNPs x iterations) of saved indicator values across all MCMC iterations.
Numeric vector of saved posterior samples of the causal
effect .
Numeric vector of saved posterior samples of the
pleiotropic effect .
Numeric vector of saved posterior samples of instrument
effect variance .
Numeric vector of saved posterior samples of pleiotropic
effect variance .
Cheng, Q., Qiu, T., Chai, X., Sun, B., Xia, Y., Shi, X., and Liu, J. (2021). MR-Corr2: a two-sample Mendelian randomization method that accounts for correlated horizontal pleiotropy using correlated instrumental variants. Bioinformatics. doi:10.1093/bioinformatics/btab646.
MRCorr2Sim, MRCorr2Real, traceplot
## Not run: # Simulated example with independent SNPs p <- 100 gammah <- rnorm(p, mean = 0.1, sd = 0.05) Gammah <- 0.3 * gammah + rnorm(p, sd = 0.05) se1 <- rep(0.05, p) se2 <- rep(0.05, p) result <- MRcorr(gammah, Gammah, se1, se2) # Posterior mean of causal effect mean(result$Beta0res) # Trace plot of causal effect traceplot(result$Beta0res) ## End(Not run)## Not run: # Simulated example with independent SNPs p <- 100 gammah <- rnorm(p, mean = 0.1, sd = 0.05) Gammah <- 0.3 * gammah + rnorm(p, sd = 0.05) se1 <- rep(0.05, p) se2 <- rep(0.05, p) result <- MRcorr(gammah, Gammah, se1, se2) # Posterior mean of causal effect mean(result$Beta0res) # Trace plot of causal effect traceplot(result$Beta0res) ## End(Not run)
Performs two-sample Mendelian randomization using a block-parallel Bayesian
Gibbs sampling approach that accounts for both linkage disequilibrium (LD)
and correlated horizontal pleiotropy. This function is intended for real
GWAS summary statistics, computing LD matrices on-the-fly from a reference
panel. For pre-computed LD matrices (e.g. simulation studies), see
MRCorr2Sim.
MRCorr2Real(bp, chr, avbIndex, idx4panel, block_file, stringname3, ld_r2_thresh, bh1, bh2, se1, se2, lam, coreNum, opts = NULL)MRCorr2Real(bp, chr, avbIndex, idx4panel, block_file, stringname3, ld_r2_thresh, bh1, bh2, se1, se2, lam, coreNum, opts = NULL)
bp |
Integer vector of base pair positions for each SNP. |
chr |
Integer vector of chromosome numbers for each SNP. |
avbIndex |
Integer vector of 0-based indices identifying the SNPs available for the analysis within the reference panel. |
idx4panel |
Integer vector of 0-based indices of SNPs in the reference panel used for LD calculation. |
block_file |
Character string giving the path to a file defining LD blocks (e.g., the EUR LD block file from Berisa and Pickrell 2016). |
stringname3 |
Character string giving the path prefix for the reference panel genotype files (PLINK binary format: .bed/.bim/.fam). |
ld_r2_thresh |
Numeric threshold for LD |
bh1 |
Numeric vector of SNP-exposure effect estimates ( |
bh2 |
Numeric vector of SNP-outcome effect estimates ( |
se1 |
Numeric vector of standard errors for |
se2 |
Numeric vector of standard errors for |
lam |
Numeric regularisation parameter for positive-definite correction
of block LD matrices. Values above 0.5 use linear shrinkage; values at or
below 0.5 use the |
coreNum |
Integer number of CPU cores for parallel computation. |
opts |
Optional named list of Gibbs sampler settings. See
|
A named list containing:
Integer number of LD blocks used in the analysis.
Integer vector of SNP indices after clumping, indicating which SNPs were retained.
Integer vector of final block-level indicator values (1 = valid instrument block, 0 = pleiotropic block).
Numeric vector of saved posterior proportion of valid instrument blocks across MCMC iterations.
Numeric vector of saved posterior samples of the causal
effect .
Numeric vector of saved posterior samples of the
pleiotropic effect .
Numeric vector of saved posterior samples of instrument
effect variance .
Numeric vector of saved posterior samples of pleiotropic
effect variance .
Cheng, Q., Qiu, T., Chai, X., Sun, B., Xia, Y., Shi, X., and Liu, J. (2021). MR-Corr2: a two-sample Mendelian randomization method that accounts for correlated horizontal pleiotropy using correlated instrumental variants. Bioinformatics. doi:10.1093/bioinformatics/btab646.
Berisa, T. and Pickrell, J.K. (2016). Approximately independent linkage disequilibrium blocks in human populations. Bioinformatics, 32(2), 283–285.
MRcorr, MRCorr2Sim,
matchscreen, summaryQC,
traceplot
## Not run: # See the package vignette for a complete real data example. # vignette("MR.Corr2") ## End(Not run)## Not run: # See the package vignette for a complete real data example. # vignette("MR.Corr2") ## End(Not run)
Performs two-sample Mendelian randomization using a block-parallel Bayesian
Gibbs sampling approach that accounts for both linkage disequilibrium (LD)
among instrumental variants and correlated horizontal pleiotropy. This
function is intended for use with simulated data where the full LD matrix
R is available. For real GWAS data, see MRCorr2Real.
MRCorr2Sim(gammah, Gammah, se1, se2, R, block_inf, coreNum, opts = NULL)MRCorr2Sim(gammah, Gammah, se1, se2, R, block_inf, coreNum, opts = NULL)
gammah |
Numeric vector of SNP-exposure effect estimates. |
Gammah |
Numeric vector of SNP-outcome effect estimates. Must be the
same length as |
se1 |
Numeric vector of standard errors for SNP-exposure effects. |
se2 |
Numeric vector of standard errors for SNP-outcome effects. |
R |
Numeric matrix of pairwise LD correlations among SNPs (p x p).
Can be computed using |
block_inf |
Integer matrix defining LD blocks. Each row gives the
0-based start and end indices (columns) of one block within |
coreNum |
Integer specifying the number of CPU cores for parallel computation. |
opts |
Optional named list of Gibbs sampler settings. See
|
This function partitions SNPs into LD blocks and performs block-parallel Gibbs sampling. Parallelism is applied across blocks within each iteration, enabling efficient computation for large numbers of SNPs.
The LD matrix R and block structure block_inf are typically
computed from reference panel genotypes using Cal_block_SimR
and Cal_blockinf.
A named list containing:
Integer vector of final block-level indicator values (1 = valid instrument block, 0 = pleiotropic block).
Numeric vector of saved posterior proportion of valid instrument blocks across MCMC iterations.
Numeric vector of saved posterior samples of the causal
effect .
Numeric vector of saved posterior samples of the
pleiotropic effect .
Cheng, Q., Qiu, T., Chai, X., Sun, B., Xia, Y., Shi, X., and Liu, J. (2021). MR-Corr2: a two-sample Mendelian randomization method that accounts for correlated horizontal pleiotropy using correlated instrumental variants. Bioinformatics. doi:10.1093/bioinformatics/btab646.
MRcorr, MRCorr2Real,
Cal_block_SimR, Cal_blockinf,
traceplot
## Not run: # See the package vignette for a complete simulation example. # vignette("MR.Corr2") ## End(Not run)## Not run: # See the package vignette for a complete simulation example. # vignette("MR.Corr2") ## End(Not run)
Reads GWAS summary statistics from a text file and populates pre-allocated vectors with allele codes, rs IDs, effect estimates, standard errors, p-values, chromosomal positions, and sample sizes.
Read_summarystat(stringname, SA1, SA2, rsname, betah, s2, pvalue, chr, bp, N)Read_summarystat(stringname, SA1, SA2, rsname, betah, s2, pvalue, chr, bp, N)
stringname |
Character string giving the path to the summary statistics file. |
SA1 |
Character vector to be filled with effect allele codes. |
SA2 |
Character vector to be filled with other allele codes. |
rsname |
Character vector to be filled with rs IDs. |
betah |
Numeric vector to be filled with effect estimates. |
s2 |
Numeric vector to be filled with standard errors. |
pvalue |
Numeric vector to be filled with p-values. |
chr |
Integer vector to be filled with chromosome numbers. |
bp |
Integer vector to be filled with base pair positions. |
N |
Integer specifying the number of SNPs to read. |
Called for its side effect of populating the supplied vectors. Returns
NULL invisibly.
ReadSNPinfo, matchsnp,
matchscreen, getLineNum
Reads SNP annotation information from a reference panel file (typically a
PLINK .bim file or similar format) and populates pre-allocated
vectors with allele codes, rs IDs, chromosomes, base pair positions,
genetic distances, and sample sizes.
ReadSNPinfo(stringname, A1, A2, rsname, chr, bp, morgan, N)ReadSNPinfo(stringname, A1, A2, rsname, chr, bp, morgan, N)
stringname |
Character string giving the path to the SNP information file. |
A1 |
Character vector to be filled with effect allele codes. |
A2 |
Character vector to be filled with other allele codes. |
rsname |
Character vector to be filled with rs IDs. |
chr |
Integer vector to be filled with chromosome numbers. |
bp |
Integer vector to be filled with base pair positions. |
morgan |
Numeric vector to be filled with genetic distances (cM). |
N |
Integer specifying the number of SNPs to read. |
A named list with the populated vectors:
Character vector of effect alleles.
Character vector of other alleles.
Character vector of rs IDs.
Integer vector of chromosome numbers.
Integer vector of base pair positions.
Numeric vector of genetic distances.
Read_summarystat, matchsnp,
matchscreen, getLineNum
Returns the elements of a vector at specified indices. A thin C++ wrapper around element selection, provided for use in Rcpp-based workflows.
select(vec_, idx_)select(vec_, idx_)
vec_ |
A numeric or integer vector. |
idx_ |
An integer vector of 0-based indices specifying which elements to extract. |
A vector containing the elements of vec_ at positions idx_.
Returns the elements of integer vector x that are not present in
integer vector y. Implemented via C++ std::set_difference
for efficiency.
std_setdiff(x, y)std_setdiff(x, y)
x |
Integer vector. |
y |
Integer vector. Elements in |
An integer vector of elements in x but not in y, in sorted
order.
Applies quality control filters to GWAS summary statistics prior to Mendelian randomization analysis. Removes SNPs located in the MHC region (chromosome 6, positions 28,477,797–33,448,354) and SNPs whose chi-square statistics exceed specified bounds for either the exposure or outcome GWAS.
summaryQC(mhcstart = 28477797, mhcend = 33448354, bh1, bh2, s12, s22, bp, chr, rsname, avbIndex, idx4panel, xbound, ybound)summaryQC(mhcstart = 28477797, mhcend = 33448354, bh1, bh2, s12, s22, bp, chr, rsname, avbIndex, idx4panel, xbound, ybound)
mhcstart |
Integer giving the start base pair position of the MHC region to exclude (default 28,477,797). |
mhcend |
Integer giving the end base pair position of the MHC region to exclude (default 33,448,354). |
bh1 |
Numeric vector of SNP-exposure effect estimates. |
bh2 |
Numeric vector of SNP-outcome effect estimates. |
s12 |
Numeric vector of standard errors for |
s22 |
Numeric vector of standard errors for |
bp |
Integer vector of base pair positions. |
chr |
Integer vector of chromosome numbers. |
rsname |
Character vector of rs IDs. |
avbIndex |
Integer vector of SNP indices in the reference panel. |
idx4panel |
Integer vector of LD panel SNP indices. |
xbound |
Numeric upper chi-square bound for the exposure GWAS. SNPs
with |
ybound |
Numeric upper chi-square bound for the outcome GWAS. SNPs
with |
A named list containing the QC-filtered data:
Filtered exposure effect estimates.
Filtered outcome effect estimates.
Filtered exposure standard errors.
Filtered outcome standard errors.
Filtered base pair positions.
Filtered chromosome numbers.
Filtered rs IDs.
Filtered reference panel indices.
Filtered LD panel indices.
Integer number of SNPs removed due to MHC region.
Integer number of SNPs removed due to exposure chi-square bound.
Integer number of SNPs removed due to outcome chi-square bound.
## Not run: qc <- summaryQC(mhcstart = 28477797, mhcend = 33448354, bh1 = bh1, bh2 = bh2, s12 = se1, s22 = se2, bp = bp, chr = chr, rsname = rsname, avbIndex = avbIndex, idx4panel = idx4panel, xbound = 80, ybound = 80) ## End(Not run)## Not run: qc <- summaryQC(mhcstart = 28477797, mhcend = 33448354, bh1 = bh1, bh2 = bh2, s12 = se1, s22 = se2, bp = bp, chr = chr, rsname = rsname, avbIndex = avbIndex, idx4panel = idx4panel, xbound = 80, ybound = 80) ## End(Not run)
Given SNP positions and a block definition file, returns the block index assigned to each SNP. Useful for verifying that SNPs are correctly assigned to LD blocks before running the main analysis.
test_blocks(bp, chr, block_file)test_blocks(bp, chr, block_file)
bp |
Integer vector of base pair positions for each SNP. |
chr |
Integer vector of chromosome numbers for each SNP. |
block_file |
Character string giving the path to the LD block definition file. |
An integer vector of block indices (1-based) for each SNP. SNPs that do
not fall within any defined block are assigned NA or 0.
Produces a trace plot of posterior samples from the Gibbs sampler, typically
used to assess convergence of the causal effect estimate .
Returns a ggplot2 plot object.
traceplot(bhatpoint)traceplot(bhatpoint)
bhatpoint |
Numeric vector of posterior samples, e.g. the
|
Requires the ggplot2 package.
A ggplot object displaying the sample index on the x-axis and the
parameter value on the y-axis.
MRcorr, MRCorr2Sim, MRCorr2Real
## Not run: result <- MRcorr(gammah, Gammah, se1, se2) p <- traceplot(result$Beta0res) print(p) ## End(Not run)## Not run: result <- MRcorr(gammah, Gammah, se1, se2) p <- traceplot(result$Beta0res) print(p) ## End(Not run)