-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
272 lines (212 loc) · 8.44 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
---
title: gwaspr R Package
output: github_document
always_allow_html: true
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = T, message = F, warning = F)
```
`gwaspr`: an `R` package for plotting GWAS results from the `GAPIT` package
# Installation
```{r eval = F}
devtools::install_github("derekmichaelwright/gwaspr")
```
```{r eval = T}
library(gwaspr)
```
![](man/figures/logo_gwaspr.png)
# GWAS Tutorial
https://derekmichaelwright.github.io/dblogr/academic/gwas_tutorial
# Usage
For best practice, output from GAPIT should be in its own folder. In this case, they are located in a folder called `GWAS_Results/`. For this example we will plot GWAS results from 3 traits in a lentil diversity panel:
- **Testa_Pattern**: a *qualitative* trait describing the presence or absence of seed coat pigmentation.
- **DTF_Nepal_2017**: a *quantitative* trait describing days from sowing to flowering in a 2017 Nepal field trial.
- **DTF_Sask_2017**: a *quantitative* trait describing days from sowing to flowering in a 2017 Saskatchewan field trial.
- **DTF_Sask_2017_b**: same as above but run with the *b* coefficient from a photothermal model (see [Wright *et al*. 2020](https://doi.org/10.1002/ppp3.10158)) used as a covariate.
Note: for more info check out this [GWAS tutorial](https://derekmichaelwright.github.io/dblogr/academic/gwaspr_tutorial).
## List Traits
```{r eval = T}
myTraits <- list_Traits(folder = "GWAS_Results/")
myTraits
```
## List Results Files
```{r eval = T}
myFiles <- list_Result_Files(folder = "GWAS_Results/")
myFiles
```
## List Significant Markers
```{r eval = F}
# first reorder the result files if they are not already arranged by P.value
order_GWAS_Results(folder = "GWAS_Results/", files = myFiles)
```
```{r eval = T}
myResults <- table_GWAS_Results(folder = "GWAS_Results/", files = myFiles,
threshold = 6.7, sug.threshold = 6)
myResults[1:10,]
```
```{r eval = T}
list_Top_Markers(trait = "DTF_Nepal_2017", model = "MLMM",
folder = "GWAS_Results/",
threshold = 6.7, chroms = c(2,5), n = 1)
```
```{r}
myMarkers <- c("Lcu.2RBY.Chr2p42543877","Lcu.2RBY.Chr5p1069654",
"Lcu.2RBY.Chr6p2528817", "Lcu.2RBY.Chr6p12212845")
```
```{r eval = T}
list_Top_Markers(trait = "Testa_Pattern", model = "MLM",
folder = "GWAS_Results/",
threshold = 6.7, chroms = 6, n = 1)
```
```{r eval = T}
table_Results_Summary("GWAS_Results/", isOrdered = F)
table_Results_Summary("GWAS_Results/", isOrdered = T)
```
---
## Manhattan Plots
### Multi Manhattan Plots
```{r eval = F}
for(i in myTraits) {
mp <- gg_Manhattan(folder = "GWAS_Results/",
trait = i,
title = paste("LDP -", i),
threshold = 7.3,
sug.threshold = 6.7,
vlines = myMarkers,
vline.colors = c("red","red","darkgreen","blue"),
vline.types = c(1,1,1,1),
vline.legend = T,
facet = F,
addQQ = T,
pmax = 12,
models = c("MLM", "MLMM", "FarmCPU", "BLINK"),
model.colors = c("darkgreen", "darkred", "darkorange3", "steelblue"),
legend.rows = 2)
ggsave(paste0("man/figures/Multi_", i, ".png"),
mp, width = 12, height = 4, bg = "white")
}
```
![](man/figures/Multi_DTF_Nepal_2017.png)
![](man/figures/Multi_DTF_Sask_2017.png)
![](man/figures/Multi_DTF_Sask_2017_CV_b.png)
![](man/figures/Multi_Testa_Pattern.png)
---
### Facetted Manhattan Plots
```{r eval = F}
for(i in myTraits) {
mp <- gg_Manhattan(folder = "GWAS_Results/",
trait = i,
title = paste("LDP -", i),
threshold = 7.3,
sug.threshold = 6.7,
vlines = myMarkers,
vline.colors = c("red","red","darkgreen","blue"),
vline.types = c(1,1,1,1),
vline.legend = T,
facet = T,
addQQ = T,
pmax = 12,
models = c("MLM", "MLMM", "FarmCPU", "BLINK"),
chrom.colors = rep(c("darkgreen", "darkgoldenrod2"), 4),
legend.rows = 1)
ggsave(paste0("man/figures/Facet_", i, ".png"),
mp, width = 12, height = 8, bg = "white")
}
```
![](man/figures/Facet_DTF_Nepal_2017.png)
![](man/figures/Facet_DTF_Sask_2017.png)
![](man/figures/Facet_DTF_Sask_2017_CV_b.png)
![](man/figures/Facet_Testa_Pattern.png)
---
## Summary Plot
```{r eval = F}
mp <- gg_GWAS_Summary(folder = "GWAS_Results/",
traits = myTraits,
models = c("MLM", "MLMM", "FarmCPU", "BLINK"),
colors = c("darkgreen", "darkred", "darkorange3", "steelblue"),
threshold = 6.7, sug.threshold = 6,
hlines = c(1.5,3.5), legend.rows = 2,
vlines = myMarkers,
vline.colors = c("red", "red", "green", "blue"),
vline.types = c(1,1,1,1),
title = "Summary of Significant GWAS Results")
ggsave("man/figures/GWAS_Summary.png", mp, width = 12, height = 4)
```
![](man/figures/GWAS_Summary.png)
```{r eval = F, echo = F}
gg_GWAS_plotly(mp, filename = "man/figures/GWAS_Summary.html")
plotly::ggplotly(mp)
```
---
## GWAS Hits Plot
```{r eval = F}
# Prep
myG <- read.csv("myG_hmp.csv", header = T)
# Plot
mp <- gg_GWAS_Hits(xx = myResults,
xG = myG,
myTs = list_Traits("GWAS_Results/"),
myR = 2000000,
myTitle = "",
sigMin = 0,
myCV = NULL,
models = c("MLM", "MLMM", "FarmCPU", "BLINK", "GLM"),
model.colors = c("darkgreen", "darkred", "darkorange3", "steelblue", "darkorchid4"),
model.shapes = c(21,24:25,22,23),
vlines = myMarkers,
vline.colors = c("red", "red", "green", "blue"),
vline.types = rep(1, length(vlines)),
legend.rows = 1)
ggsave("man/figures/GWAS_Hits_01.png", mp, width = 10, height = 4)
```
![](man/figures/GWAS_Hits_01.png)
---
![](man/figures/GWAS_Hits_02.png)
```{r eval = F}
mp <- gg_GWAS_Hits(xx = myResults,
xG = myG,
myTs = list_Traits("GWAS_Results/"),
myR = 2000000,
myTitle = "",
sigMin = 0,
myCV = NULL,
models = c("MLM", "MLMM", "FarmCPU", "BLINK"),
model.colors = c("darkgreen", "darkred", "darkorange3", "steelblue"),
model.shapes = c(21,24:25,22),
vlines = myMarkers,
vline.colors = c("red", "red", "green", "blue"),
vline.types = rep(1, length(vlines)),
legend.rows = 2)
ggsave("man/figures/GWAS_Hits_02.png", mp, width = 10, height = 4)
```
```{r eval = F echo = F}
p <- gg_Manhattan_Traits(folder = "GWAS_Results/",
traits = paste0("Ro17_Plot.Height.d0", c("24","32","40","54","61","67","74","80","89","95")),
model = "MLM",
title = "GWAS",
threshold = 6,
sug.threshold = 4,
markers = myMarkers,
labels = markers,
vlines = markers,
vline.colors = rep("red", length(vlines)),
vline.types = rep(1, length(vlines)),
vline.legend = T,
addQQ = T,
facet = F,
pmax = NULL,
chrom.unit = "100 Mbp",
myColors = c("darkgreen", "darkred", "darkorange3", "steelblue", "darkorchid4",
"darkslategray", "burlywood4", "darkgoldenrod2", "red", "maroon3",
"blue2", "cyan3", "deeppink3"),
legend.rows = 4)
ggsave("Additional/Additional_Figure_15.png", mp, width = 12, height = 5, bg = "white")
```
---
# GAPIT
`GAPIT`: and `R` package for performing Genome Wide Association Studies (GWAS)
https://github.com/jiabowang/GAPIT3
# Dependancies
`tidyverse`, `ggpubr`, `ggbeeswarm`, `ggrepel`, `ggtext`, `plotly`, `htmlwidgets`
---
© Derek Michael Wright