-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
122 lines (85 loc) · 3.06 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "60%"
)
```
# ggGWAS
<!-- badges: start -->
[![Travis build status](https://travis-ci.org/sinarueeger/ggGWAS.svg?branch=master)](https://travis-ci.org/sinarueeger/ggGWAS)
[![Codecov test coverage](https://codecov.io/gh/sinarueeger/ggGWAS/branch/master/graph/badge.svg)](https://codecov.io/gh/sinarueeger/ggGWAS?branch=master)
<!-- badges: end -->
An R-Package (*work-in-progress*) that contains ggplot2-extensions of data visualisations used with GWAS data.
Mainly, these are Q-Q plot and Manhattan plot that both use P-values from GWASs as input.
An inspiration for ggGWAS has been the R-package [qqman](http://www.gettinggeneticsdone.com/2014/05/qqman-r-package-for-qq-and-manhattan-plots-for-gwas-results.html), except that ggGWAS aims to have the look and functionality of `ggplot2`.
## Installation
You can install the development version from [GitHub](https://github.com/) with:
```r
# install.packages("remotes")
remotes::install_github("sinarueeger/ggGWAS")
```
Install the `dev`b ranch:
```r
remotes::install_github("sinarueeger/ggGWAS", ref = "dev")
```
Install including vignettes:
```r
remotes::install_github("sinarueeger/ggGWAS", build = TRUE, build_opts = c("--no-resave-data", "--no-manual"))
vignette("gggwas-reasoning")
vignette("gggwas-internals")
```
## Basic usage
```{r data}
library(ggGWAS)
library(ggplot2)
theme_set(theme_bw())
## Generate some random data
n <- 1000
n_chr <- 4
df <-
data.frame(
POS = rep(1:(n/n_chr), n_chr),
CHR = rep(1:n_chr, rep(n/n_chr, n_chr)),
SNP = paste0("rs", 1:n),
P = runif(n),
GWAS = sample(c("a", "b"), n, replace = TRUE)
)
```
### Q-Q plot
Lightweight Q-Q plot (with hex tiles)
```{r qqplot-hex, fig.width = 6, fig.height = 6}
library(ggGWAS)
ggplot(data = df) +
stat_gwas_qq_hex(aes(y = P)) +
geom_abline(intercept = 0, slope = 1, linetype = 3)
?stat_gwas_qq_hex ## for more examples
```
Conventional Q-Q plot
```{r qqplot, fig.width = 6, fig.height = 6}
ggplot(data = df) +
stat_gwas_qq(aes(y = P)) +
geom_abline(intercept = 0, slope = 1, linetype = 3)
?stat_gwas_qq ## for more examples
```
### Manhattan plot
Currently working on `stat_gwas_manhattan()` that should at one point look like this:
```
ggplot(data = df) + stat_gwas_manhattan(aes(pos = POS, y = -log10(P), chr = CHR))
```
Till then, use the `ggman::ggmanhattan` function:
```{r manhattanplot, message=FALSE, warning=FALSE, fig.width = 6, fig.height = 4}
library(dplyr)
library(ggman)
ggman::ggmanhattan(data = df, SNP = "SNP", chr = "CHR", bp = "POS", P = "P", sparsify = FALSE, theme_base = theme_bw(), build = 'hg18', highlight = df %>% slice(which.min(P)) %>% pull(SNP)) +
labs(title = "MHTPLOT" )
```
##Contributing
lease note that the 'ggGWAS' project is released with a
[Contributor Code of Conduct](CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.