knitr::opts_chunk$set( collapse = TRUE, comment = "#>", # NA dev = "png", dev.args = list(type = "cairo"), dpi = 92, fig.path = "figures/", fig.width = 4, fig.height = 4, results = 'markup', tidy = F, message = T, warning = T, echo = T )
finemapr
finemapr
is an R package that provides an interface to fine-mapping tools:
By using finemapr
, your input files are automatically prepared for each tool, the analysis workflow is tool-independent; and exploration of fine-mapping results is powered by R in printing/plotting/data export.
# set up options(finemapr_<tool> = "<path to fine-mapping tool>") # read input files my_zscores <- read_zscores("<my_scores.tab>") my_ld <- read_ld("<my_ld.tab>") # run analysis out <- run_<tool>(my_zscores, my_ld, args = "<custom arguments>") # explore results print(out) head(out$snp) # main table of results plot(out) # export results write.table(out$snp, "<my_results.tab>")
The user needs to download and install a fine-mapping tool before the analysis.
An example of installation commands used in finemapr
by default is given here.
After installing, for example, the FINEMAP tool, the user specify for finemapr
where the tool is located:
options(finemapr_finemap = "~/apps/finemap/finemap")
We load packages for the analysis conducted in this document.
library(devtools) load_all("~/git/variani/finemapr") library(magrittr) library(dplyr) library(ggplot2) theme_set(theme_linedraw())
We load example data copied from the FINEMAP website (http://www.christianbenner.com/).
This simulated dataset has two causal variants rs15
and rs47
.
file1_z <- system.file("extdata/region1.z", package = "finemapr") file1_ld <- system.file("extdata/region1.ld", package = "finemapr") z1 <- read_zscore(file1_z) ld1 <- read_ld(file1_ld, snps = z1$snp) n1 <- 5363
Top 5 z-scores:
z1 %>% arrange(-abs(zscore)) %>% head(5) %>% kable(digits = 1)
ggplot(z1, aes(zscore)) + geom_histogram()
mutate(z1, pval = pchisq(zscore^2, df = 1, lower.tail = FALSE)) %>% ggplot(aes(pval)) + geom_histogram()
options(finemapr_finemap = "~/apps/finemap/finemap") out_finemap <- run_finemap(z1, ld1, n1, args = "--n-causal-max 3")
print(out_finemap)
plot(out_finemap, label_size = 3, grid_ncol = 1)
options(finemapr_caviar = "~/apps/caviar/CAVIAR") out_caviar <- run_caviar(z1, ld1, args = "-c 3")
print(out_caviar)
plot(out_caviar, label_size = 3)
options(finemapr_paintor = "~/apps/paintor/PAINTOR") out_paintor <- run_paintor(z1, ld1, n1, args = "-enumerate 3")
print(out_paintor)
plot(out_paintor, label_size = 3)
All three fine-mapping tools estimated the poterior causal probabilities of the two variants, rs15
and rs47
, very close to 1.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.