Last updated: 2024-04-30
Checks: 7 0
Knit directory: XMAP-tutorial/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20230213)
was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version b982352. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for
the analysis have been committed to Git prior to generating the results
(you can use wflow_publish
or
wflow_git_commit
). workflowr only checks the R Markdown
file, but you know if there are other scripts or data files that it
depends on. Below is the status of the Git repository when the results
were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: data/.DS_Store
Unstaged changes:
Modified: analysis/LDL.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were
made to the R Markdown (analysis/confounding.Rmd
) and HTML
(docs/confounding.html
) files. If you’ve configured a
remote Git repository (see ?wflow_git_remote
), click on the
hyperlinks in the table below to view the files as they were in that
past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
html | 243ff3b | mxcai | 2024-04-30 | add LD construction |
html | 36aec62 | mxcai | 2024-04-30 | commit |
Rmd | 64b7578 | mxcai | 2024-04-29 | Add toggle |
html | 64b7578 | mxcai | 2024-04-29 | Add toggle |
Here, we provide an example of using XMAP for correcting confounding bias in cross-population GWAS data. We simulated GWAS data with confounding effects. For demonstration, we assume that we have estimated the inflation constants \(c_1=1.636171\) and \(c_2=1.791455\), and the polygenic parameters \(\Omega\) using bi-variate LDSC (See next section for details in estimating these parameters in real GWAS data).
We first fit XMAP without correcting confounding bias by setting \(c_1=c_2=1\):
library(susieR)
library(XMAP)
data("example_data_confound")
c1 <- 1.636171
c2 <- 1.791455
fit_xmapI <- XMAP(simplify2array(list(R1,R2)), cbind(zs1,zs2),
n=c(15000,20000), K = 5,
Omega = OmegaHat,
Sig_E = c(1,1),
tol = 1e-6,
maxIter = 200, estimate_residual_variance = F, estimate_prior_variance = T,
estimate_background_variance = F)
# Get credible set based on R1
cs1 <- get_CS(fit_xmapI, Xcorr = R1, coverage = 0.95, min_abs_corr = 0.1)
# Get credible set based on R2
cs2 <- get_CS(fit_xmapI, Xcorr = R2, coverage = 0.95, min_abs_corr = 0.1)
# Get joint credible set
cs <- cs1$cs[intersect(names(cs1$cs), names(cs2$cs))]
pip <- get_pip(fit_xmapI$gamma)
plot_CS(pip, cs, Beta_true[,1], main = "XMAP (C=I)")
Version | Author | Date |
---|---|---|
64b7578 | mxcai | 2024-04-29 |
In the above figure, the red dot is the only causal SNP, level-95% credible sets are colored circles. Without correcting for confounding bias, some null SNPs on the left region of the locus can have high PIP. These are false positives.
Now, we use the estimated LDSC intercepts to correct the confounding bias in XMAP:
c1 <- 1.636171
c2 <- 1.791455
fit_xmap <- XMAP(simplify2array(list(R1,R2)), cbind(zs1,zs2),
n=c(15000,20000), K = 5,
Omega = OmegaHat,
Sig_E = c(c1,c2),
tol = 1e-6,
maxIter = 200, estimate_residual_variance = F, estimate_prior_variance = T,
estimate_background_variance = F)
# Get credible set based on R1
cs1 <- get_CS(fit_xmap, Xcorr = R1, coverage = 0.95, min_abs_corr = 0.1)
# Get credible set based on R2
cs2 <- get_CS(fit_xmap, Xcorr = R2, coverage = 0.95, min_abs_corr = 0.1)
# Get joint credible set
cs <- cs1$cs[intersect(names(cs1$cs), names(cs2$cs))]
pip <- get_pip(fit_xmap$gamma)
plot_CS(pip, cs, Beta_true[,1], main = "XMAP")
Version | Author | Date |
---|---|---|
64b7578 | mxcai | 2024-04-29 |
As we can observe, XMAP effectively reduces the PIP of spurious signals and correctly excludes them from the level-95% credible sets.
sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 13.6.3
Matrix products: default
BLAS: /opt/homebrew/Cellar/openblas/0.3.19/lib/libopenblasp-r0.3.19.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] XMAP_1.0 susieR_0.12.35
loaded via a namespace (and not attached):
[1] tidyselect_1.2.0 xfun_0.32 bslib_0.4.0 lattice_0.20-45
[5] colorspace_2.0-2 vctrs_0.6.3 generics_0.1.1 htmltools_0.5.4
[9] yaml_2.3.5 utf8_1.2.2 rlang_1.1.1 mixsqp_0.3-43
[13] jquerylib_0.1.4 later_1.3.0 pillar_1.9.0 glue_1.6.2
[17] RcppZiggurat_0.1.6 matrixStats_0.61.0 lifecycle_1.0.3 plyr_1.8.6
[21] stringr_1.4.1 munsell_0.5.0 gtable_0.3.0 workflowr_1.7.0
[25] evaluate_0.16 knitr_1.40 fastmap_1.1.0 httpuv_1.6.5
[29] parallel_4.1.2 irlba_2.3.5 fansi_0.5.0 highr_0.9
[33] Rfast_2.0.6 Rcpp_1.0.10 promises_1.2.0.1 scales_1.1.1
[37] cachem_1.0.6 jsonlite_1.8.0 fs_1.5.2 ggplot2_3.3.5
[41] digest_0.6.29 stringi_1.7.8 dplyr_1.1.2 rprojroot_2.0.2
[45] grid_4.1.2 cli_3.6.1 tools_4.1.2 magrittr_2.0.3
[49] sass_0.4.2 tibble_3.2.1 crayon_1.5.1 whisker_0.4
[53] pkgconfig_2.0.3 Matrix_1.5-4.1 rmarkdown_2.16 reshape_0.8.8
[57] rstudioapi_0.13 R6_2.5.1 git2r_0.31.0 compiler_4.1.2