a b/TcellAnalysis/notebooks/COVID19_DE_viz-Updated.Rmd
1
---
2
title: "COVID19: DGE visualisation"
3
output: html_notebook
4
---
5
6
This is to visualise the output from DE testing run on each T cell subset, either comparing across linear and quadratic trends.
7
8
```{r, warning=FALSE, message=FALSE}
9
library(ggplot2)
10
library(ggthemes)
11
library(ggsci)
12
library(scales)
13
library(enrichR)
14
library(ggrepel)
15
library(cowplot)
16
library(RColorBrewer)
17
```
18
19
20
# DGE testing across COVID19 severity - linear trends
21
22
Testing for a linear trend across disease severity, from healthy through to critical.
23
24
```{r}
25
dge.files <- list.files("~/Dropbox/COVID19/Data/Updated/DEResults.dir/", pattern="\\.L\\.csv")
26
linear.dge.list <- list()
27
28
for(x in seq_along(dge.files)){
29
    x.csv <- read.csv(paste0("~/Dropbox/COVID19/Data/Updated/DEResults.dir/", dge.files[x]),
30
                      header=TRUE, stringsAsFactors=FALSE)
31
    x.annot <- gsub(dge.files[x], pattern="DE_(\\S*)_Severity\\.L\\.csv", replacement="\\1")
32
    x.csv$Sub.Annotation <- x.annot
33
    linear.dge.list[[dge.files[x]]] <- x.csv
34
}
35
36
linear.dge.df <- do.call(rbind.data.frame, linear.dge.list)
37
linear.dge.df$Diff <- sign(linear.dge.df$logFC)
38
linear.dge.df$Diff[linear.dge.df$FDR >= 0.01] <- 0
39
40
table(linear.dge.df$Diff, linear.dge.df$Sub.Annotation)
41
```
42
43
There are variable numbers of gene DE across categories, but generally quite a small number. 
44
45
```{r}
46
# collect all de genes for plotting
47
de.genes.all <- unique(linear.dge.df$X[linear.dge.df$FDR < 0.01])
48
49
write.table(de.genes.all,
50
            file="~/Dropbox/COVID19/Data/Updated/DEResults.dir/ALL_linear_DEgenes.tsv",
51
            quote=FALSE, row.names=FALSE, sep="\t")
52
```
53
54
55
## CD4.CM
56
57
```{r}
58
enrich.dbs <- c("Transcription_Factor_PPIs", "MSigDB_Computational", "MSigDB_Hallmark_2020", 
59
                "KEGG_2019_Human", "GO_Biological_Process_2018")
60
```
61
62
63
```{r, fig.height=3.95, fig.width=4.95}
64
cd4.cm.labels <- linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.CM"), ]$X
65
cd4.cm.labels[linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.CM"), ]$FDR > 1e-3] <- ""
66
67
ggplot(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.CM"), ],
68
       aes(x=logFC, y=-log10(FDR))) +
69
    geom_point() +
70
    theme_cowplot() +
71
    geom_text_repel(aes(label=cd4.cm.labels)) +
72
    ggsave("~/Dropbox/COVID19/Updated_plots/CD4.CM-linear_volcano.pdf",
73
           height=3.95, width=4.95, useDingbats=FALSE) +
74
    NULL
75
```
76
77
What are the enriched pathways amongst these genes?
78
79
```{r}
80
cd4.cm.enriched.up <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.CM") &
81
                                                linear.dge.df$FDR < 0.01 &
82
                                                linear.dge.df$logFC > 0, ]$X,
83
                              enrich.dbs)
84
85
cd4.cm.enriched.down <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.CM") &
86
                                                linear.dge.df$FDR < 0.01 &
87
                                                linear.dge.df$logFC < 0, ]$X,
88
                              enrich.dbs)
89
```
90
91
92
## MSigDB 2020 enrichments
93
94
```{r, fig.height=4.15, fig.width=4.15}
95
cd4.msigdb.up <- cd4.cm.enriched.up[["MSigDB_Hallmark_2020"]]
96
cd4.msigdb.up$Dir <- "Up"
97
98
cd4.msigdb.down <- cd4.cm.enriched.down[["MSigDB_Hallmark_2020"]]
99
cd4.msigdb.down$Dir <- "Down"
100
101
cd4.msigdb <- do.call(rbind.data.frame, list(cd4.msigdb.up, cd4.msigdb.down))
102
cd4.msigdb$logP <- -log10(cd4.msigdb$P.value)
103
cd4.msigdb$logP[cd4.msigdb$Dir %in% c("Down")] <- -1 * cd4.msigdb$logP[cd4.msigdb$Dir %in% c("Down")]
104
105
ggplot(cd4.msigdb[cd4.msigdb$P.value < 0.01, ],
106
       aes(x=reorder(Term, logP), y=logP)) +
107
    geom_hline(yintercept=0, lty=2, colour='grey80') +
108
    geom_point() +
109
    coord_flip() +
110
    labs(x="Pathway", y="Odds Rato") +
111
    ggsave("~/Dropbox/COVID19/Updated_plots/CD4.CM-linear_MSigDB_enriched.pdf",
112
           height=4.15, width=4.15, useDingbats=FALSE) +
113
    theme_cowplot()
114
```
115
116
117
```{r, fig.height=4.15, fig.width=4.15}
118
cd4.tfppi.up <- cd4.cm.enriched.up[["Transcription_Factor_PPIs"]]
119
cd4.tfppi.up$Dir <- "Up"
120
121
cd4.tfppi.down <- cd4.cm.enriched.down[["Transcription_Factor_PPIs"]]
122
cd4.tfppi.down$Dir <- "Down"
123
124
cd4.tfppi <- do.call(rbind.data.frame, list(cd4.tfppi.up, cd4.tfppi.down))
125
cd4.tfppi$logP <- -log10(cd4.tfppi$P.value)
126
cd4.tfppi$logP[cd4.tfppi$Dir %in% c("Down")] <- -1 * cd4.tfppi$logP[cd4.tfppi$Dir %in% c("Down")]
127
128
ggplot(cd4.tfppi[cd4.tfppi$P.value < 0.01, ],
129
       aes(x=reorder(Term, logP), y=logP)) +
130
    geom_hline(yintercept=0, lty=2, colour='grey80') +
131
    geom_point() +
132
    coord_flip() +
133
    labs(x="Pathway", y="Odds Rato") +
134
    
135
    theme_cowplot()
136
```
137
138
139
## CD4.Naive
140
141
```{r, fig.height=3.95, fig.width=4.95}
142
cd4.naive.labels <- linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.Naive"), ]$X
143
cd4.naive.labels[linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.Naive"), ]$FDR > 1e-3] <- ""
144
145
ggplot(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.Naive"), ],
146
       aes(x=logFC, y=-log10(FDR))) +
147
    geom_point() +
148
    theme_cowplot() +
149
    geom_text_repel(aes(label=cd4.naive.labels)) +
150
    ggsave("~/Dropbox/COVID19/Updated_plots/CD4.Naive-linear_volcano.pdf",
151
           height=3.95, width=4.95, useDingbats=FALSE) +
152
    NULL
153
```
154
155
What are the enriched pathways amongst these genes?
156
157
```{r}
158
cd4.naive.enriched.up <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.Naive") &
159
                                                linear.dge.df$FDR < 0.01 &
160
                                                linear.dge.df$logFC > 0, ]$X,
161
                              enrich.dbs)
162
163
cd4.naive.enriched.down <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.Naive") &
164
                                                linear.dge.df$FDR < 0.01 &
165
                                                linear.dge.df$logFC < 0, ]$X,
166
                              enrich.dbs)
167
```
168
169
170
## MSigDB 2020 enrichments
171
172
```{r, fig.height=4.15, fig.width=4.15}
173
cd4.naive.msigdb.up <- cd4.naive.enriched.up[["MSigDB_Hallmark_2020"]]
174
cd4.naive.msigdb.up$Dir <- "Up"
175
176
cd4.naive.msigdb.down <- cd4.naive.enriched.down[["MSigDB_Hallmark_2020"]]
177
cd4.naive.msigdb.down$Dir <- "Down"
178
179
cd4.naive.msigdb <- do.call(rbind.data.frame, list(cd4.naive.msigdb.up, cd4.naive.msigdb.down))
180
cd4.naive.msigdb$logP <- -log10(cd4.naive.msigdb$P.value)
181
cd4.naive.msigdb$logP[cd4.naive.msigdb$Dir %in% c("Down")] <- -1 * cd4.naive.msigdb$logP[cd4.naive.msigdb$Dir %in% c("Down")]
182
183
ggplot(cd4.naive.msigdb[cd4.naive.msigdb$P.value < 0.01, ],
184
       aes(x=reorder(Term, logP), y=logP)) +
185
    geom_hline(yintercept=0, lty=2, colour='grey80') +
186
    geom_point() +
187
    coord_flip() +
188
    labs(x="Pathway", y="Odds Rato") +
189
        ggsave("~/Dropbox/COVID19/Updated_plots/CD4.Naive-linear_MSigDB_enriched.pdf",
190
           height=4.15, width=4.15, useDingbats=FALSE) +
191
    theme_cowplot()
192
```
193
194
195
```{r, fig.height=4.15, fig.width=4.15}
196
cd4.naive.tfppi.up <- cd4.naive.enriched.up[["Transcription_Factor_PPIs"]]
197
cd4.naive.tfppi.up$Dir <- "Up"
198
199
cd4.naive.tfppi.down <- cd4.naive.enriched.down[["Transcription_Factor_PPIs"]]
200
cd4.naive.tfppi.down$Dir <- "Down"
201
202
cd4.naive.tfppi <- do.call(rbind.data.frame, list(cd4.naive.tfppi.up, cd4.naive.tfppi.down))
203
cd4.naive.tfppi$logP <- -log10(cd4.naive.tfppi$P.value)
204
cd4.naive.tfppi$logP[cd4.naive.tfppi$Dir %in% c("Down")] <- -1 * cd4.naive.tfppi$logP[cd4.naive.tfppi$Dir %in% c("Down")]
205
206
ggplot(cd4.naive.tfppi[cd4.naive.tfppi$P.value < 0.01, ],
207
       aes(x=reorder(Term, logP), y=logP)) +
208
    geom_hline(yintercept=0, lty=2, colour='grey80') +
209
    geom_point() +
210
    coord_flip() +
211
    labs(x="Pathway", y="Odds Rato") +
212
    theme_cowplot()
213
```
214
215
216
217
## CD8.Naive
218
219
```{r, fig.height=3.95, fig.width=4.95}
220
cd8.naive.labels <- linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.Naive"), ]$X
221
cd8.naive.labels[linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.Naive"), ]$FDR > 1e-3] <- ""
222
223
ggplot(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.Naive"), ],
224
       aes(x=logFC, y=-log10(FDR))) +
225
    geom_point() +
226
    theme_cowplot() +
227
    geom_text_repel(aes(label=cd8.naive.labels)) +
228
    ggsave("~/Dropbox/COVID19/Updated_plots/CD8.Naive-linear_volcano.pdf",
229
           height=3.95, width=4.95, useDingbats=FALSE) +
230
    NULL
231
```
232
233
What are the enriched pathways amongst these genes?
234
235
```{r}
236
cd8.naive.enriched.up <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.Naive") &
237
                                                linear.dge.df$FDR < 0.01 &
238
                                                linear.dge.df$logFC > 0, ]$X,
239
                              enrich.dbs)
240
241
cd8.naive.enriched.down <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.Naive") &
242
                                                linear.dge.df$FDR < 0.01 &
243
                                                linear.dge.df$logFC < 0, ]$X,
244
                              enrich.dbs)
245
```
246
247
248
## MSigDB 2020 enrichments
249
250
```{r, fig.height=4.15, fig.width=4.15}
251
cd8.naive.msigdb.up <- cd8.naive.enriched.up[["MSigDB_Hallmark_2020"]]
252
cd8.naive.msigdb.up$Dir <- "Up"
253
254
cd8.naive.msigdb.down <- cd8.naive.enriched.down[["MSigDB_Hallmark_2020"]]
255
cd8.naive.msigdb.down$Dir <- "Down"
256
257
cd8.naive.msigdb <- do.call(rbind.data.frame, list(cd8.naive.msigdb.up, cd8.naive.msigdb.down))
258
cd8.naive.msigdb$logP <- -log10(cd8.naive.msigdb$P.value)
259
cd8.naive.msigdb$logP[cd8.naive.msigdb$Dir %in% c("Down")] <- -1 * cd8.naive.msigdb$logP[cd8.naive.msigdb$Dir %in% c("Down")]
260
261
ggplot(cd8.naive.msigdb[cd8.naive.msigdb$P.value < 0.01, ],
262
       aes(x=reorder(Term, logP), y=logP)) +
263
    geom_hline(yintercept=0, lty=2, colour='grey80') +
264
    geom_point() +
265
    coord_flip() +
266
    labs(x="Pathway", y="Odds Rato") +
267
    theme_cowplot()
268
```
269
270
271
```{r, fig.height=4.15, fig.width=4.15}
272
cd8.naive.tfppi.up <- cd8.naive.enriched.up[["Transcription_Factor_PPIs"]]
273
cd8.naive.tfppi.up$Dir <- "Up"
274
275
cd8.naive.tfppi.down <- cd8.naive.enriched.down[["Transcription_Factor_PPIs"]]
276
cd8.naive.tfppi.down$Dir <- "Down"
277
278
cd8.naive.tfppi <- do.call(rbind.data.frame, list(cd8.naive.tfppi.up, cd8.naive.tfppi.down))
279
cd8.naive.tfppi$logP <- -log10(cd8.naive.tfppi$P.value)
280
cd8.naive.tfppi$logP[cd8.naive.tfppi$Dir %in% c("Down")] <- -1 * cd8.naive.tfppi$logP[cd8.naive.tfppi$Dir %in% c("Down")]
281
282
ggplot(cd8.naive.tfppi[cd8.naive.tfppi$P.value < 0.01, ],
283
       aes(x=reorder(Term, logP), y=logP)) +
284
    geom_hline(yintercept=0, lty=2, colour='grey80') +
285
    geom_point() +
286
    coord_flip() +
287
    labs(x="Pathway", y="Odds Rato") +
288
    theme_cowplot()
289
```
290
291
292
293
## CD8.EM
294
295
```{r, fig.height=3.95, fig.width=4.95}
296
cd8.em.labels <- linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.EM"), ]$X
297
cd8.em.labels[linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.EM"), ]$FDR > 1e-2] <- ""
298
299
ggplot(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.EM"), ],
300
       aes(x=logFC, y=-log10(FDR))) +
301
    geom_point() +
302
    theme_cowplot() +
303
    geom_text_repel(aes(label=cd8.em.labels)) +
304
    ggsave("~/Dropbox/COVID19/Updated_plots/CD8.EM-linear_volcano.pdf",
305
           height=3.95, width=4.95, useDingbats=FALSE) +
306
    NULL
307
```
308
309
What are the enriched pathways amongst these genes?
310
311
```{r}
312
cd8.em.enriched.up <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.EM") &
313
                                                linear.dge.df$FDR < 0.01 &
314
                                                linear.dge.df$logFC > 0, ]$X,
315
                              enrich.dbs)
316
317
cd8.em.enriched.down <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.EM") &
318
                                                linear.dge.df$FDR < 0.01 &
319
                                                linear.dge.df$logFC < 0, ]$X,
320
                              enrich.dbs)
321
```
322
323
324
## MSigDB 2020 enrichments
325
326
```{r, fig.height=4.15, fig.width=4.15}
327
cd8.em.msigdb.up <- cd8.em.enriched.up[["MSigDB_Hallmark_2020"]]
328
cd8.em.msigdb.up$Dir <- "Up"
329
330
cd8.em.msigdb.down <- cd8.em.enriched.down[["MSigDB_Hallmark_2020"]]
331
if(nrow(cd8.em.msigdb.down) > 0){
332
    cd8.em.msigdb.down$Dir <- "Down"
333
    cd8.em.msigdb <- do.call(rbind.data.frame, list(cd8.em.msigdb.up, cd8.em.msigdb.down))
334
} else{
335
    cd8.em.msigdb <- do.call(rbind.data.frame, list(cd8.em.msigdb.up))
336
}
337
    
338
cd8.em.msigdb$logP <- -log10(cd8.em.msigdb$P.value)
339
cd8.em.msigdb$logP[cd8.em.msigdb$Dir %in% c("Down")] <- -1 * cd8.em.msigdb$logP[cd8.em.msigdb$Dir %in% c("Down")]
340
341
ggplot(cd8.em.msigdb[cd8.em.msigdb$P.value < 0.01, ],
342
       aes(x=reorder(Term, logP), y=logP)) +
343
    geom_hline(yintercept=0, lty=2, colour='grey80') +
344
    geom_point() +
345
    coord_flip() +
346
    labs(x="Pathway", y="Odds Rato") +
347
    theme_cowplot()
348
```
349
350
351
```{r, fig.height=4.15, fig.width=4.15}
352
cd8.em.tfppi.up <- cd8.em.enriched.up[["Transcription_Factor_PPIs"]]
353
cd8.em.tfppi.up$Dir <- "Up"
354
355
cd8.em.tfppi.down <- cd8.em.enriched.down[["Transcription_Factor_PPIs"]]
356
if(nrow(cd8.em.tfppi.down) > 0){
357
    cd8.em.tfppi.down$Dir <- "Down"
358
    cd8.em.tfppi <- do.call(rbind.data.frame, list(cd8.em.tfppi.up, cd8.em.tfppi.down))
359
} else{
360
    cd8.em.tfppi <- do.call(rbind.data.frame, list(cd8.em.tfppi.up))
361
}
362
cd8.em.tfppi$logP <- -log10(cd8.em.tfppi$P.value)
363
cd8.em.tfppi$logP[cd8.em.tfppi$Dir %in% c("Down")] <- -1 * cd8.em.tfppi$logP[cd8.em.tfppi$Dir %in% c("Down")]
364
365
ggplot(cd8.em.tfppi[cd8.em.tfppi$P.value < 0.01, ],
366
       aes(x=reorder(Term, logP), y=logP)) +
367
    geom_hline(yintercept=0, lty=2, colour='grey80') +
368
    geom_point() +
369
    coord_flip() +
370
    labs(x="Pathway", y="Odds Rato") +
371
    theme_cowplot()
372
```
373
374
375
376
## CD8.TE
377
378
```{r, fig.height=3.95, fig.width=4.95}
379
cd8.te.labels <- linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.TE"), ]$X
380
cd8.te.labels[linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.TE"), ]$FDR > 1e-2] <- ""
381
382
ggplot(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.TE"), ],
383
       aes(x=logFC, y=-log10(FDR))) +
384
    geom_point() +
385
    theme_cowplot() +
386
    geom_text_repel(aes(label=cd8.te.labels)) +
387
    ggsave("~/Dropbox/COVID19/Updated_plots/CD8.TE-linear_volcano.pdf",
388
           height=3.95, width=4.95, useDingbats=FALSE) +
389
    NULL
390
```
391
392
393
What are the enriched pathways amongst these genes?
394
395
```{r}
396
cd8.te.enriched.up <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.TE") &
397
                                                linear.dge.df$FDR < 0.01 &
398
                                                linear.dge.df$logFC > 0, ]$X,
399
                              enrich.dbs)
400
401
cd8.te.enriched.down <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD8.TE") &
402
                                                linear.dge.df$FDR < 0.01 &
403
                                                linear.dge.df$logFC < 0, ]$X,
404
                              enrich.dbs)
405
```
406
407
408
## MSigDB 2020 enrichments
409
410
```{r, fig.height=4.15, fig.width=4.15}
411
cd8.te.msigdb.up <- cd8.te.enriched.up[["MSigDB_Hallmark_2020"]]
412
cd8.te.msigdb.up$Dir <- "Up"
413
414
cd8.te.msigdb.down <- cd8.te.enriched.down[["MSigDB_Hallmark_2020"]]
415
if(nrow(cd8.te.msigdb.down) > 0){
416
    cd8.te.msigdb.down$Dir <- "Down"
417
}
418
419
cd8.te.msigdb <- do.call(rbind.data.frame, list(cd8.te.msigdb.up, cd8.te.msigdb.down))
420
cd8.te.msigdb$logP <- -log10(cd8.te.msigdb$P.value)
421
cd8.te.msigdb$logP[cd8.te.msigdb$Dir %in% c("Down")] <- -1 * cd8.te.msigdb$logP[cd8.te.msigdb$Dir %in% c("Down")]
422
423
ggplot(cd8.te.msigdb[cd8.te.msigdb$P.value < 0.01, ],
424
       aes(x=reorder(Term, logP), y=logP)) +
425
    geom_hline(yintercept=0, lty=2, colour='grey80') +
426
    geom_point() +
427
    coord_flip() +
428
    labs(x="Pathway", y="Odds Rato") +
429
    theme_cowplot()
430
```
431
432
433
```{r, fig.height=4.15, fig.width=4.15}
434
cd8.te.tfppi.up <- cd8.te.enriched.up[["Transcription_Factor_PPIs"]]
435
if(nrow(cd8.te.tfppi.up) > 0){
436
    cd8.te.tfppi.up$Dir <- "Up"
437
}
438
439
cd8.te.tfppi.down <- cd8.te.enriched.down[["Transcription_Factor_PPIs"]]
440
if(nrow(cd8.te.tfppi.down) > 0){
441
    cd8.te.tfppi.down$Dir <- "Down"
442
}
443
444
cd8.te.tfppi <- do.call(rbind.data.frame, list(cd8.te.tfppi.up, cd8.te.tfppi.down))
445
cd8.te.tfppi$logP <- -log10(cd8.te.tfppi$P.value)
446
cd8.te.tfppi$logP[cd8.te.tfppi$Dir %in% c("Down")] <- -1 * cd8.te.tfppi$logP[cd8.te.tfppi$Dir %in% c("Down")]
447
cd8.te.tfppi$Sub
448
449
ggplot(cd8.te.tfppi[cd8.te.tfppi$P.value < 0.01, ],
450
       aes(x=reorder(Term, logP), y=logP)) +
451
    geom_hline(yintercept=0, lty=2, colour='grey80') +
452
    geom_point() +
453
    coord_flip() +
454
    labs(x="Pathway", y="Odds Rato") +
455
    theme_cowplot()
456
```
457
458
459
460
## CD4.Tfh
461
462
```{r, fig.height=3.95, fig.width=4.95}
463
tfh.labels <- linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.Tfh"), ]$X
464
tfh.labels[linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.Tfh"), ]$FDR > 1e-3] <- ""
465
466
ggplot(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.Tfh"), ],
467
       aes(x=logFC, y=-log10(FDR))) +
468
    geom_point() +
469
    theme_cowplot() +
470
    geom_text_repel(aes(label=tfh.labels)) +
471
    ggsave("~/Dropbox/COVID19/Updated_plots/CD4.Tfh-linear_volcano.pdf",
472
           height=3.95, width=4.95, useDingbats=FALSE) +
473
    NULL
474
```
475
476
What are the enriched pathways amongst these genes?
477
478
```{r}
479
tfh.enriched.up <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.Tfh") &
480
                                                linear.dge.df$FDR < 0.01 &
481
                                                linear.dge.df$logFC > 0, ]$X,
482
                              enrich.dbs)
483
484
tfh.enriched.down <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("CD4.Tfh") &
485
                                                linear.dge.df$FDR < 0.01 &
486
                                                linear.dge.df$logFC < 0, ]$X,
487
                              enrich.dbs)
488
```
489
490
491
## MSigDB 2020 enrichments
492
493
```{r, fig.height=4.15, fig.width=4.15}
494
tfh.msigdb.up <- tfh.enriched.up[["MSigDB_Hallmark_2020"]]
495
tfh.msigdb.up$Dir <- "Up"
496
497
tfh.msigdb.down <- tfh.enriched.down[["MSigDB_Hallmark_2020"]]
498
if(!is.null(tfh.msigdb.down)){
499
tfh.msigdb.down$Dir <- "Down"
500
501
tfh.msigdb <- do.call(rbind.data.frame, list(tfh.msigdb.up, tfh.msigdb.down))
502
} else{
503
    tfh.msigdb <- do.call(rbind.data.frame, list(tfh.msigdb.up))
504
}
505
tfh.msigdb$logP <- -log10(tfh.msigdb$P.value)
506
tfh.msigdb$logP[tfh.msigdb$Dir %in% c("Down")] <- -1 * tfh.msigdb$logP[tfh.msigdb$Dir %in% c("Down")]
507
508
ggplot(tfh.msigdb[tfh.msigdb$P.value < 0.01, ],
509
       aes(x=reorder(Term, logP), y=logP)) +
510
    geom_hline(yintercept=0, lty=2, colour='grey80') +
511
    geom_point() +
512
    coord_flip() +
513
    labs(x="Pathway", y="Odds Rato") +
514
    theme_cowplot()
515
```
516
517
518
```{r, fig.height=4.15, fig.width=4.15}
519
tfh.tfppi.up <- tfh.enriched.up[["Transcription_Factor_PPIs"]]
520
tfh.tfppi.up$Dir <- "Up"
521
522
tfh.tfppi.down <- tfh.enriched.down[["Transcription_Factor_PPIs"]]
523
if(!is.null(tfh.tfppi.down)){
524
    tfh.tfppi.down$Dir <- "Down"
525
    tfh.tfppi <- do.call(rbind.data.frame, list(tfh.tfppi.up, tfh.tfppi.down))
526
} else{
527
    tfh.tfppi <- do.call(rbind.data.frame, list(tfh.tfppi.up))
528
}
529
530
531
tfh.tfppi <- do.call(rbind.data.frame, list(tfh.tfppi.up, tfh.tfppi.down))
532
tfh.tfppi$logP <- -log10(tfh.tfppi$P.value)
533
tfh.tfppi$logP[tfh.tfppi$Dir %in% c("Down")] <- -1 * tfh.tfppi$logP[tfh.tfppi$Dir %in% c("Down")]
534
535
ggplot(tfh.tfppi[tfh.tfppi$P.value < 0.01, ],
536
       aes(x=reorder(Term, logP), y=logP)) +
537
    geom_hline(yintercept=0, lty=2, colour='grey80') +
538
    geom_point() +
539
    coord_flip() +
540
    labs(x="Pathway", y="Odds Rato") +
541
    theme_cowplot()
542
```
543
544
545
546
## gdT
547
548
```{r, fig.height=3.95, fig.width=4.95}
549
gdt.labels <- linear.dge.df[linear.dge.df$Sub.Annotation %in% c("gdT"), ]$X
550
gdt.labels[linear.dge.df[linear.dge.df$Sub.Annotation %in% c("gdT"), ]$FDR > 1e-3] <- ""
551
552
ggplot(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("gdT"), ],
553
       aes(x=logFC, y=-log10(FDR))) +
554
    geom_point() +
555
    theme_cowplot() +
556
    geom_text_repel(aes(label=gdt.labels)) +
557
    ggsave("~/Dropbox/COVID19/Updated_plots/gdT-linear_volcano.pdf",
558
           height=3.95, width=4.95, useDingbats=FALSE) +
559
    NULL
560
```
561
562
What are the enriched pathways amongst these genes?
563
564
```{r}
565
gdt.enriched.up <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("gdT") &
566
                                                linear.dge.df$FDR < 0.01 &
567
                                                linear.dge.df$logFC > 0, ]$X,
568
                              enrich.dbs)
569
570
gdt.enriched.down <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("gdT") &
571
                                                linear.dge.df$FDR < 0.01 &
572
                                                linear.dge.df$logFC < 0, ]$X,
573
                              enrich.dbs)
574
```
575
576
577
## MSigDB 2020 enrichments
578
579
```{r, fig.height=4.15, fig.width=4.15}
580
gdt.msigdb.up <- gdt.enriched.up[["MSigDB_Hallmark_2020"]]
581
if(!is.null(gdt.msigdb.up)){
582
    gdt.msigdb.up$Dir <- "Up"    
583
}
584
585
gdt.msigdb.down <- gdt.enriched.down[["MSigDB_Hallmark_2020"]]
586
if(!is.null(gdt.msigdb.down)){
587
    gdt.msigdb.down$Dir <- "Down"
588
}
589
590
if(!is.null(gdt.msigdb.up) & !is.null(gdt.msigdb.down)){
591
    gdt.msigdb <- do.call(rbind.data.frame, list(gdt.msigdb.up, gdt.msigdb.down))
592
    gdt.msigdb$logP <- -log10(gdt.msigdb$P.value)
593
    gdt.msigdb$logP[gdt.msigdb$Dir %in% c("Down")] <- -1 * gdt.msigdb$logP[gdt.msigdb$Dir %in% c("Down")]
594
} else if(!is.null(gdt.msigdb.up) & is.null(gdt.msigdb.down)){
595
    gdt.msigdb <- do.call(rbind.data.frame, list(gdt.msigdb.up))
596
    gdt.msigdb$logP <- -log10(gdt.msigdb$P.value)
597
    gdt.msigdb$logP[gdt.msigdb$Dir %in% c("Down")] <- -1 * gdt.msigdb$logP[gdt.msigdb$Dir %in% c("Down")]
598
} else if(is.null(gdt.msigdb.up) & !is.null(gdt.msigdb.down)){
599
    gdt.msigdb <- do.call(rbind.data.frame, list(gdt.msigdb.down))
600
    gdt.msigdb$logP <- -log10(gdt.msigdb$P.value)
601
    gdt.msigdb$logP[gdt.msigdb$Dir %in% c("Down")] <- -1 * gdt.msigdb$logP[gdt.msigdb$Dir %in% c("Down")]
602
} else{
603
    gdt.msigdb <- NULL
604
}
605
606
if(!is.null(gdt.msigdb)){
607
    ggplot(gdt.msigdb[gdt.msigdb$P.value < 0.01, ],
608
       aes(x=reorder(Term, logP), y=logP)) +
609
    geom_hline(yintercept=0, lty=2, colour='grey80') +
610
    geom_point() +
611
    coord_flip() +
612
    labs(x="Pathway", y="Odds Rato") +
613
    theme_cowplot()
614
}
615
```
616
617
618
```{r, fig.height=4.15, fig.width=4.15}
619
gdt.tfppi.up <- gdt.enriched.up[["Transcription_Factor_PPIs"]]
620
gdt.tfppi.up$Dir <- "Up"
621
622
gdt.tfppi.down <- gdt.enriched.down[["Transcription_Factor_PPIs"]]
623
if(!is.null(gdt.tfppi.down)){
624
    gdt.tfppi.down$Dir <- "Down"
625
    
626
    gdt.tfppi <- do.call(rbind.data.frame, list(gdt.tfppi.up, gdt.tfppi.down))
627
    gdt.tfppi$logP <- -log10(gdt.tfppi$P.value)
628
    gdt.tfppi$logP[gdt.tfppi$Dir %in% c("Down")] <- -1 * gdt.tfppi$logP[gdt.tfppi$Dir %in% c("Down")]
629
} else{
630
    gdt.tfppi <- do.call(rbind.data.frame, list(gdt.tfppi.up))
631
    gdt.tfppi$logP <- -log10(gdt.tfppi$P.value)
632
    gdt.tfppi$logP[gdt.tfppi$Dir %in% c("Down")] <- -1 * gdt.tfppi$logP[gdt.tfppi$Dir %in% c("Down")]
633
}
634
635
ggplot(gdt.tfppi[gdt.tfppi$P.value < 0.01, ],
636
       aes(x=reorder(Term, logP), y=logP)) +
637
    geom_hline(yintercept=0, lty=2, colour='grey80') +
638
    geom_point() +
639
    coord_flip() +
640
    labs(x="Pathway", y="Odds Rato") +
641
    theme_cowplot()
642
```
643
644
645
646
647
## MAIT
648
649
```{r, fig.height=3.95, fig.width=4.95}
650
mait.labels <- linear.dge.df[linear.dge.df$Sub.Annotation %in% c("MAIT"), ]$X
651
mait.labels[linear.dge.df[linear.dge.df$Sub.Annotation %in% c("MAIT"), ]$FDR > 1e-3] <- ""
652
653
ggplot(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("MAIT"), ],
654
       aes(x=logFC, y=-log10(FDR))) +
655
    geom_point() +
656
    theme_cowplot() +
657
    geom_text_repel(aes(label=mait.labels)) +
658
        ggsave("~/Dropbox/COVID19/Updated_plots/MAIT-linear_volcano.pdf",
659
           height=3.95, width=4.95, useDingbats=FALSE) +
660
    NULL
661
```
662
663
What are the enriched pathways amongst these genes?
664
665
```{r}
666
mait.enriched.up <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("MAIT") &
667
                                                linear.dge.df$FDR < 0.01 &
668
                                                linear.dge.df$logFC > 0, ]$X,
669
                              enrich.dbs)
670
671
mait.enriched.down <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("MAIT") &
672
                                                linear.dge.df$FDR < 0.01 &
673
                                                linear.dge.df$logFC < 0, ]$X,
674
                              enrich.dbs)
675
```
676
677
678
## MSigDB 2020 enrichments
679
680
```{r, fig.height=4.15, fig.width=4.15}
681
mait.msigdb.up <- mait.enriched.up[["MSigDB_Hallmark_2020"]]
682
if(!is.null(mait.msigdb.up)){
683
    mait.msigdb.up$Dir <- "Up"
684
}
685
686
mait.msigdb.down <- mait.enriched.down[["MSigDB_Hallmark_2020"]]
687
if(!is.null(mait.msigdb.down)){
688
    mait.msigdb.down$Dir <- "Down"
689
}
690
if(!is.null(mait.msigdb.down) & !is.null(mait.msigdb.up)){
691
    mait.msigdb <- do.call(rbind.data.frame, list(mait.msigdb.up, mait.msigdb.down))
692
} else if(is.null(mait.msigdb.down) & !is.null(mait.msigdb.up)){
693
    mait.msigdb <- do.call(rbind.data.frame, list(mait.msigdb.up))
694
} else if(!is.null(mait.msigdb.down) & is.null(mait.msigdb.up)){
695
    mait.msigdb <- do.call(rbind.data.frame, list(mait.msigdb.down))
696
}
697
698
mait.msigdb$logP <- -log10(mait.msigdb$P.value)
699
mait.msigdb$logP[mait.msigdb$Dir %in% c("Down")] <- -1 * mait.msigdb$logP[mait.msigdb$Dir %in% c("Down")]
700
701
ggplot(mait.msigdb[mait.msigdb$P.value < 0.01, ],
702
       aes(x=reorder(Term, logP), y=logP)) +
703
    geom_hline(yintercept=0, lty=2, colour='grey80') +
704
    geom_point() +
705
    coord_flip() +
706
    labs(x="Pathway", y="Odds Rato") +
707
    theme_cowplot()
708
```
709
710
711
```{r, fig.height=4.15, fig.width=4.15}
712
mait.tfppi.up <- mait.enriched.up[["Transcription_Factor_PPIs"]]
713
if(!is.null(mait.tfppi.up)){
714
    mait.tfppi.up$Dir <- "Up"
715
}
716
717
mait.tfppi.down <- mait.enriched.down[["Transcription_Factor_PPIs"]]
718
if(!is.null(mait.tfppi.down)){
719
    mait.tfppi.down$Dir <- "Down"
720
}
721
722
if(!is.null(mait.tfppi.up) & !is.null(mait.tfppi.down)){
723
    mait.tfppi <- do.call(rbind.data.frame, list(mait.tfppi.up, mait.tfppi.down))
724
} else if(!is.null(mait.tfppi.up) & is.null(mait.tfppi.down)){
725
    mait.tfppi <- do.call(rbind.data.frame, list(mait.tfppi.up))
726
} else if(is.null(mait.tfppi.up) & !is.null(mait.tfppi.down)){
727
    mait.tfppi <- do.call(rbind.data.frame, list(mait.tfppi.down))
728
}
729
730
mait.tfppi$logP <- -log10(mait.tfppi$P.value)
731
mait.tfppi$logP[mait.tfppi$Dir %in% c("Down")] <- -1 * mait.tfppi$logP[mait.tfppi$Dir %in% c("Down")]
732
733
ggplot(mait.tfppi[mait.tfppi$P.value < 0.01, ],
734
       aes(x=reorder(Term, logP), y=logP)) +
735
    geom_hline(yintercept=0, lty=2, colour='grey80') +
736
    geom_point() +
737
    coord_flip() +
738
    labs(x="Pathway", y="Odds Rato") +
739
    theme_cowplot()
740
```
741
742
743
744
## Treg
745
746
```{r, fig.height=3.95, fig.width=4.95}
747
treg.labels <- linear.dge.df[linear.dge.df$Sub.Annotation %in% c("Treg"), ]$X
748
treg.labels[linear.dge.df[linear.dge.df$Sub.Annotation %in% c("Treg"), ]$FDR > 1e-3] <- ""
749
750
ggplot(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("Treg"), ],
751
       aes(x=logFC, y=-log10(FDR))) +
752
    geom_point() +
753
    theme_cowplot() +
754
    geom_text_repel(aes(label=treg.labels)) +
755
        ggsave("~/Dropbox/COVID19/Updated_plots/Treg-linear_volcano.pdf",
756
           height=3.95, width=4.95, useDingbats=FALSE) +
757
    NULL
758
```
759
760
What are the enriched pathways amongst these genes?
761
762
```{r}
763
treg.enriched.up <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("Treg") &
764
                                                linear.dge.df$FDR < 0.01 &
765
                                                linear.dge.df$logFC > 0, ]$X,
766
                              enrich.dbs)
767
768
treg.enriched.down <- enrichr(linear.dge.df[linear.dge.df$Sub.Annotation %in% c("Treg") &
769
                                                linear.dge.df$FDR < 0.01 &
770
                                                linear.dge.df$logFC < 0, ]$X,
771
                              enrich.dbs)
772
```
773
774
775
## MSigDB 2020 enrichments
776
777
```{r, fig.height=4.15, fig.width=4.15}
778
treg.msigdb.up <- treg.enriched.up[["MSigDB_Hallmark_2020"]]
779
treg.msigdb.up$Dir <- "Up"
780
781
treg.msigdb.down <- treg.enriched.down[["MSigDB_Hallmark_2020"]]
782
if(!is.null(treg.msigdb.down)){
783
    treg.msigdb.down$Dir <- "Down"
784
}
785
786
treg.msigdb <- do.call(rbind.data.frame, list(treg.msigdb.up, treg.msigdb.down))
787
treg.msigdb$logP <- -log10(treg.msigdb$P.value)
788
treg.msigdb$logP[treg.msigdb$Dir %in% c("Down")] <- -1 * treg.msigdb$logP[treg.msigdb$Dir %in% c("Down")]
789
790
ggplot(treg.msigdb[treg.msigdb$P.value < 0.01, ],
791
       aes(x=reorder(Term, logP), y=logP)) +
792
    geom_hline(yintercept=0, lty=2, colour='grey80') +
793
    geom_point() +
794
    coord_flip() +
795
    labs(x="Pathway", y="Odds Rato") +
796
    theme_cowplot()
797
```
798
799
800
```{r, fig.height=4.15, fig.width=4.15}
801
treg.tfppi.up <- treg.enriched.up[["Transcription_Factor_PPIs"]]
802
treg.tfppi.up$Dir <- "Up"
803
804
treg.tfppi.down <- treg.enriched.down[["Transcription_Factor_PPIs"]]
805
if(!is.null(treg.tfppi.down)){
806
    treg.tfppi.down$Dir <- "Down"
807
}
808
809
treg.tfppi <- do.call(rbind.data.frame, list(treg.tfppi.up, treg.tfppi.down))
810
treg.tfppi$logP <- -log10(treg.tfppi$P.value)
811
treg.tfppi$logP[treg.tfppi$Dir %in% c("Down")] <- -1 * treg.tfppi$logP[treg.tfppi$Dir %in% c("Down")]
812
813
ggplot(treg.tfppi[treg.tfppi$P.value < 0.01, ],
814
       aes(x=reorder(Term, logP), y=logP)) +
815
    geom_hline(yintercept=0, lty=2, colour='grey80') +
816
    geom_point() +
817
    coord_flip() +
818
    labs(x="Pathway", y="Odds Rato") +
819
    theme_cowplot()
820
```
821
822
823
Aggregate all results from the linear trend analysis.
824
825
```{r}
826
cd4.msigdb$Sub.Annotation <- "CD4.CM"
827
cd4.naive.msigdb$Sub.Annotation <- "CD4.Naive"
828
cd8.naive.msigdb$Sub.Annotation <- "CD8.Naive"
829
cd8.em.msigdb$Sub.Annotation <- "CD8.EM"
830
cd8.te.msigdb$Sub.Annotation <- "CD8.TE"
831
tfh.msigdb$Sub.Annotation <- "CD4.Tfh"
832
# treg.msigdb$Sub.Annotation <- "Treg"
833
mait.msigdb$Sub.Annotation <- "MAIT"
834
# gdt.msigdb$Sub.Annotation <- "gdT"
835
836
msigdb.linear.enrichments <- list(cd4.msigdb, cd4.naive.msigdb, cd8.naive.msigdb, cd8.em.msigdb, cd8.te.msigdb,
837
                                  tfh.msigdb, mait.msigdb)
838
839
msigdb.linear.enrich.df <- do.call(rbind.data.frame,
840
                                   msigdb.linear.enrichments)
841
```
842
843
```{r}
844
cell.order <- c("CD4.Naive", "CD4.CM", "CD4.EM", "CD4.IL22", "CD4.Prolif", "CD4.Th1", "CD4.Th2", "CD4.Th17", "CD4.Tfh",
845
                "Treg", "CD8.Naive", "CD8.Activated", "CD8.Prolif", "CD8.CM", "CD8.TE", "CD8.EM", "gdT", "MAIT", "NKT")
846
847
all.qual.cols <- brewer.pal.info[brewer.pal.info$category %in% c("qual") & brewer.pal.info$colorblind, ]
848
col_vector = unlist(mapply(brewer.pal, all.qual.cols$maxcolors, rownames(all.qual.cols)))
849
850
# cell.cols <- col_vector[c(1:7, 9:19)]
851
cell.cols <- col_vector[c(1:17, 19, 20)]
852
names(cell.cols) <- cell.order
853
```
854
855
856
```{r, fig.height=5.95, fig.width=6.95}
857
ggplot(msigdb.linear.enrich.df[msigdb.linear.enrich.df$P.value < 0.01, ],
858
       aes(x=reorder(Term, logP), y=logP, colour=Sub.Annotation)) +
859
    geom_hline(yintercept=0, lty=2, colour='grey80') +
860
    geom_point(size=3.5, shape=18) +
861
    scale_colour_manual(values=cell.cols) +
862
    #facet_wrap(~Term, scales="free_y", ncol=1) +
863
    labs(x="Pathway", y="Odds Rato") +
864
    guides(colour=guide_legend(title="Cell Type", override.aes=list(size=5, shape=18))) +
865
    theme_cowplot() +
866
    coord_flip() +
867
    theme(panel.spacing=unit(0, "lines"),
868
          strip.text=element_blank(),
869
          strip.background=element_blank()) +
870
    ggsave("~/Dropbox/COVID19/Updated_plots/Tcell-linear_MSigDB_enriched.pdf",
871
           height=5.95, width=6.95, useDingbats=FALSE) +
872
    NULL
873
```
874
875
And for the enriched TFs. Aggregate all results from the linear trend analysis.
876
877
```{r}
878
cd4.tfppi$Sub.Annotation <- "CD4.CM"
879
cd4.naive.tfppi$Sub.Annotation <- "CD4.Naive"
880
cd8.naive.tfppi$Sub.Annotation <- "CD8.Naive"
881
cd8.em.tfppi$Sub.Annotation <- "CD8.EM"
882
cd8.te.tfppi$Sub.Annotation <- "CD8.TE"
883
tfh.tfppi$Sub.Annotation <- "CD4.Tfh"
884
# treg.tfppi$Sub.Annotation <- "Treg"
885
mait.tfppi$Sub.Annotation <- "MAIT"
886
# gdt.tfppi$Sub.Annotation <- "gdT"
887
888
tfppi.linear.enrichments <- list(cd4.tfppi, cd4.naive.tfppi, cd8.naive.tfppi, cd8.em.tfppi, cd8.te.tfppi,
889
                                  tfh.tfppi,  mait.tfppi)
890
891
tfppi.linear.enrich.df <- do.call(rbind.data.frame,
892
                                   tfppi.linear.enrichments)
893
```
894
895
896
```{r, fig.height=8.95, fig.width=6.95}
897
ggplot(tfppi.linear.enrich.df[tfppi.linear.enrich.df$P.value < 0.01, ],
898
       aes(x=reorder(Term, logP), y=logP, colour=Sub.Annotation)) +
899
    geom_hline(yintercept=0, lty=2, colour='grey80') +
900
    geom_point(size=3.5, shape=18) +
901
    scale_colour_manual(values=cell.cols) +
902
    #facet_wrap(~Term, scales="free_y", ncol=1) +
903
    labs(x="Pathway", y="Odds Rato") +
904
    guides(colour=guide_legend(title="Cell Type", override.aes=list(size=5, shape=18))) +
905
    theme_cowplot() +
906
    coord_flip() +
907
    theme(panel.spacing=unit(0, "lines"),
908
          strip.text=element_blank(),
909
          strip.background=element_blank()) +
910
ggsave("~/Dropbox/COVID19/Updated_plots/Tcell-linear_TFPPI_enriched.pdf",
911
           height=5.95, width=6.95, useDingbats=FALSE) +
912
    NULL
913
```
914
915
916
917
# DGE testing across COVID19 severity - quadratic trends
918
919
As the model above, but testing for a linear trend across disease severity, from healthy through to critical.
920
921
```{r}
922
dge.files <- list.files("~/Dropbox/COVID19/Data/Updated/DEResults.dir/", pattern="\\.Q\\.csv")
923
quadratic.dge.list <- list()
924
925
for(x in seq_along(dge.files)){
926
    x.csv <- read.csv(paste0("~/Dropbox/COVID19/Data/Updated/DEResults.dir/", dge.files[x]),
927
                      header=TRUE, stringsAsFactors=FALSE)
928
    x.annot <- gsub(dge.files[x], pattern="DE_(\\S*)_Severity\\.Q\\.csv", replacement="\\1")
929
    x.csv$Sub.Annotation <- x.annot
930
    quadratic.dge.list[[dge.files[x]]] <- x.csv
931
}
932
933
quadratic.dge.df <- do.call(rbind.data.frame, quadratic.dge.list)
934
quadratic.dge.df$Diff <- sign(quadratic.dge.df$logFC)
935
quadratic.dge.df$Diff[quadratic.dge.df$FDR >= 0.01] <- 0
936
937
table(quadratic.dge.df$Diff, quadratic.dge.df$Sub.Annotation)
938
```
939
940
941
There are variable numbers of gene DE across categories, but generally quite a small number. Somehow this doesn't feel right...
942
943
## CD4.CM
944
945
```{r}
946
enrich.dbs <- c("Transcription_Factor_PPIs", "MSigDB_Computational", "MSigDB_Hallmark_2020", 
947
                "UK_Biobank_GWAS_v1", "KEGG_2019_Human", "GO_Biological_Process_2018")
948
```
949
950
951
```{r, fig.height=3.95, fig.width=4.95}
952
cd4.cm.labels <- quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.CM"), ]$X
953
cd4.cm.labels[quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.CM"), ]$FDR > 1e-3] <- ""
954
955
ggplot(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.CM"), ],
956
       aes(x=logFC, y=-log10(FDR))) +
957
    geom_point() +
958
    theme_cowplot() +
959
    geom_text_repel(aes(label=cd4.cm.labels)) +
960
        ggsave("~/Dropbox/COVID19/Updated_plots/CD4.CM-quadratic_volcano.pdf",
961
           height=3.95, width=4.95, useDingbats=FALSE) +
962
    NULL
963
```
964
965
What are the enriched pathways amongst these genes?
966
967
```{r}
968
cd4.cm.enriched.up <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.CM") &
969
                                                quadratic.dge.df$FDR < 0.01 &
970
                                                quadratic.dge.df$logFC > 0, ]$X,
971
                              enrich.dbs)
972
973
cd4.cm.enriched.down <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.CM") &
974
                                                quadratic.dge.df$FDR < 0.01 &
975
                                                quadratic.dge.df$logFC < 0, ]$X,
976
                              enrich.dbs)
977
```
978
979
980
## MSigDB 2020 enrichments
981
982
```{r, fig.height=4.15, fig.width=4.15}
983
cd4.msigdb.up <- cd4.cm.enriched.up[["MSigDB_Hallmark_2020"]]
984
cd4.msigdb.up$Dir <- "Up"
985
986
cd4.msigdb.down <- cd4.cm.enriched.down[["MSigDB_Hallmark_2020"]]
987
cd4.msigdb.down$Dir <- "Down"
988
989
cd4.msigdb <- do.call(rbind.data.frame, list(cd4.msigdb.up, cd4.msigdb.down))
990
cd4.msigdb$logP <- -log10(cd4.msigdb$P.value)
991
cd4.msigdb$logP[cd4.msigdb$Dir %in% c("Down")] <- -1 * cd4.msigdb$logP[cd4.msigdb$Dir %in% c("Down")]
992
993
ggplot(cd4.msigdb[cd4.msigdb$P.value < 0.01, ],
994
       aes(x=reorder(Term, logP), y=logP)) +
995
    geom_hline(yintercept=0, lty=2, colour='grey80') +
996
    geom_point() +
997
    coord_flip() +
998
    labs(x="Pathway", y="Odds Rato") +
999
    theme_cowplot()
1000
```
1001
1002
1003
```{r, fig.height=4.15, fig.width=4.15}
1004
cd4.tfppi.up <- cd4.cm.enriched.up[["Transcription_Factor_PPIs"]]
1005
cd4.tfppi.up$Dir <- "Up"
1006
1007
cd4.tfppi.down <- cd4.cm.enriched.down[["Transcription_Factor_PPIs"]]
1008
cd4.tfppi.down$Dir <- "Down"
1009
1010
cd4.tfppi <- do.call(rbind.data.frame, list(cd4.tfppi.up, cd4.tfppi.down))
1011
cd4.tfppi$logP <- -log10(cd4.tfppi$P.value)
1012
cd4.tfppi$logP[cd4.tfppi$Dir %in% c("Down")] <- -1 * cd4.tfppi$logP[cd4.tfppi$Dir %in% c("Down")]
1013
1014
ggplot(cd4.tfppi[cd4.tfppi$P.value < 0.01, ],
1015
       aes(x=reorder(Term, logP), y=logP)) +
1016
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1017
    geom_point() +
1018
    coord_flip() +
1019
    labs(x="Pathway", y="Odds Rato") +
1020
    theme_cowplot()
1021
```
1022
1023
1024
## CD4.Naive
1025
1026
```{r, fig.height=3.95, fig.width=4.95}
1027
cd4.naive.labels <- quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.Naive"), ]$X
1028
cd4.naive.labels[quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.Naive"), ]$FDR > 1e-3] <- ""
1029
1030
ggplot(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.Naive"), ],
1031
       aes(x=logFC, y=-log10(FDR))) +
1032
    geom_point() +
1033
    theme_cowplot() +
1034
    geom_text_repel(aes(label=cd4.naive.labels)) +
1035
    ggsave("~/Dropbox/COVID19/Updated_plots/CD4.Naive-quadratic_volcano.pdf",
1036
           height=3.95, width=4.95, useDingbat=FALSE) +
1037
    NULL
1038
```
1039
1040
What are the enriched pathways amongst these genes?
1041
1042
```{r}
1043
cd4.naive.enriched.up <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.Naive") &
1044
                                                quadratic.dge.df$FDR < 0.01 &
1045
                                                quadratic.dge.df$logFC > 0, ]$X,
1046
                              enrich.dbs)
1047
1048
cd4.naive.enriched.down <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.Naive") &
1049
                                                quadratic.dge.df$FDR < 0.01 &
1050
                                                quadratic.dge.df$logFC < 0, ]$X,
1051
                              enrich.dbs)
1052
```
1053
1054
1055
## MSigDB 2020 enrichments
1056
1057
```{r, fig.height=4.15, fig.width=4.15}
1058
cd4.naive.msigdb.up <- cd4.naive.enriched.up[["MSigDB_Hallmark_2020"]]
1059
cd4.naive.msigdb.up$Dir <- "Up"
1060
1061
cd4.naive.msigdb.down <- cd4.naive.enriched.down[["MSigDB_Hallmark_2020"]]
1062
cd4.naive.msigdb.down$Dir <- "Down"
1063
1064
cd4.naive.msigdb <- do.call(rbind.data.frame, list(cd4.naive.msigdb.up, cd4.naive.msigdb.down))
1065
cd4.naive.msigdb$logP <- -log10(cd4.naive.msigdb$P.value)
1066
cd4.naive.msigdb$logP[cd4.naive.msigdb$Dir %in% c("Down")] <- -1 * cd4.naive.msigdb$logP[cd4.naive.msigdb$Dir %in% c("Down")]
1067
1068
ggplot(cd4.naive.msigdb[cd4.naive.msigdb$P.value < 0.01, ],
1069
       aes(x=reorder(Term, logP), y=logP)) +
1070
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1071
    geom_point() +
1072
    coord_flip() +
1073
    labs(x="Pathway", y="Odds Rato") +
1074
    theme_cowplot()
1075
```
1076
1077
1078
```{r, fig.height=4.15, fig.width=4.15}
1079
cd4.naive.tfppi.up <- cd4.naive.enriched.up[["Transcription_Factor_PPIs"]]
1080
cd4.naive.tfppi.up$Dir <- "Up"
1081
1082
cd4.naive.tfppi.down <- cd4.naive.enriched.down[["Transcription_Factor_PPIs"]]
1083
cd4.naive.tfppi.down$Dir <- "Down"
1084
1085
cd4.naive.tfppi <- do.call(rbind.data.frame, list(cd4.naive.tfppi.up, cd4.naive.tfppi.down))
1086
cd4.naive.tfppi$logP <- -log10(cd4.naive.tfppi$P.value)
1087
cd4.naive.tfppi$logP[cd4.naive.tfppi$Dir %in% c("Down")] <- -1 * cd4.naive.tfppi$logP[cd4.naive.tfppi$Dir %in% c("Down")]
1088
1089
ggplot(cd4.naive.tfppi[cd4.naive.tfppi$P.value < 0.01, ],
1090
       aes(x=reorder(Term, logP), y=logP)) +
1091
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1092
    geom_point() +
1093
    coord_flip() +
1094
    labs(x="Pathway", y="Odds Rato") +
1095
    theme_cowplot()
1096
```
1097
1098
1099
1100
## CD8.Naive
1101
1102
```{r, fig.height=3.95, fig.width=4.95}
1103
cd8.naive.labels <- quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.Naive"), ]$X
1104
cd8.naive.labels[quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.Naive"), ]$FDR > 1e-3] <- ""
1105
1106
ggplot(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.Naive"), ],
1107
       aes(x=logFC, y=-log10(FDR))) +
1108
    geom_point() +
1109
    theme_cowplot() +
1110
    geom_text_repel(aes(label=cd8.naive.labels)) +
1111
    ggsave("~/Dropbox/COVID19/Updated_plots/CD8.Naive-quadratic_volcano.pdf",
1112
           height=3.95, width=4.95, useDingbat=FALSE) +
1113
    NULL
1114
```
1115
1116
What are the enriched pathways amongst these genes?
1117
1118
```{r}
1119
cd8.naive.enriched.up <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.Naive") &
1120
                                                quadratic.dge.df$FDR < 0.01 &
1121
                                                quadratic.dge.df$logFC > 0, ]$X,
1122
                              enrich.dbs)
1123
1124
cd8.naive.enriched.down <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.Naive") &
1125
                                                quadratic.dge.df$FDR < 0.01 &
1126
                                                quadratic.dge.df$logFC < 0, ]$X,
1127
                              enrich.dbs)
1128
```
1129
1130
1131
## MSigDB 2020 enrichments
1132
1133
```{r, fig.height=4.15, fig.width=4.15}
1134
cd8.naive.msigdb.up <- cd8.naive.enriched.up[["MSigDB_Hallmark_2020"]]
1135
cd8.naive.msigdb.up$Dir <- "Up"
1136
1137
cd8.naive.msigdb.down <- cd8.naive.enriched.down[["MSigDB_Hallmark_2020"]]
1138
cd8.naive.msigdb.down$Dir <- "Down"
1139
1140
cd8.naive.msigdb <- do.call(rbind.data.frame, list(cd8.naive.msigdb.up, cd8.naive.msigdb.down))
1141
cd8.naive.msigdb$logP <- -log10(cd8.naive.msigdb$P.value)
1142
cd8.naive.msigdb$logP[cd8.naive.msigdb$Dir %in% c("Down")] <- -1 * cd8.naive.msigdb$logP[cd8.naive.msigdb$Dir %in% c("Down")]
1143
1144
ggplot(cd8.naive.msigdb[cd8.naive.msigdb$P.value < 0.01, ],
1145
       aes(x=reorder(Term, logP), y=logP)) +
1146
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1147
    geom_point() +
1148
    coord_flip() +
1149
    labs(x="Pathway", y="Odds Rato") +
1150
    theme_cowplot()
1151
```
1152
1153
1154
```{r, fig.height=4.15, fig.width=4.15}
1155
cd8.naive.tfppi.up <- cd8.naive.enriched.up[["Transcription_Factor_PPIs"]]
1156
cd8.naive.tfppi.up$Dir <- "Up"
1157
1158
cd8.naive.tfppi.down <- cd8.naive.enriched.down[["Transcription_Factor_PPIs"]]
1159
cd8.naive.tfppi.down$Dir <- "Down"
1160
1161
cd8.naive.tfppi <- do.call(rbind.data.frame, list(cd8.naive.tfppi.up, cd8.naive.tfppi.down))
1162
cd8.naive.tfppi$logP <- -log10(cd8.naive.tfppi$P.value)
1163
cd8.naive.tfppi$logP[cd8.naive.tfppi$Dir %in% c("Down")] <- -1 * cd8.naive.tfppi$logP[cd8.naive.tfppi$Dir %in% c("Down")]
1164
1165
ggplot(cd8.naive.tfppi[cd8.naive.tfppi$P.value < 0.01, ],
1166
       aes(x=reorder(Term, logP), y=logP)) +
1167
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1168
    geom_point() +
1169
    coord_flip() +
1170
    labs(x="Pathway", y="Odds Rato") +
1171
    theme_cowplot()
1172
```
1173
1174
1175
1176
## CD8.EM
1177
1178
```{r, fig.height=3.95, fig.width=4.95}
1179
cd8.em.labels <- quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.EM"), ]$X
1180
cd8.em.labels[quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.EM"), ]$FDR > 1e-3] <- ""
1181
1182
ggplot(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.EM"), ],
1183
       aes(x=logFC, y=-log10(FDR))) +
1184
    geom_point() +
1185
    theme_cowplot() +
1186
    geom_text_repel(aes(label=cd8.em.labels)) +
1187
    ggsave("~/Dropbox/COVID19/Updated_plots/CD8.CEMquadratic_volcano.pdf",
1188
           height=3.95, width=4.95, useDingbats=FALSE) +
1189
    NULL
1190
```
1191
1192
What are the enriched pathways amongst these genes?
1193
1194
```{r}
1195
cd8.em.enriched.up <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.EM") &
1196
                                                quadratic.dge.df$FDR < 0.01 &
1197
                                                quadratic.dge.df$logFC > 0, ]$X,
1198
                              enrich.dbs)
1199
1200
cd8.em.enriched.down <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.EM") &
1201
                                                quadratic.dge.df$FDR < 0.01 &
1202
                                                quadratic.dge.df$logFC < 0, ]$X,
1203
                              enrich.dbs)
1204
```
1205
1206
1207
## MSigDB 2020 enrichments
1208
1209
```{r, fig.height=4.15, fig.width=4.15}
1210
1211
cd8.em.msigdb.up <- cd8.em.enriched.up[["MSigDB_Hallmark_2020"]]
1212
if(!is.null(cd8.em.msigdb.up)){
1213
    cd8.em.msigdb.up$Dir <- "Up"
1214
    
1215
    cd8.em.msigdb.down <- cd8.em.enriched.down[["MSigDB_Hallmark_2020"]]
1216
    cd8.em.msigdb.down$Dir <- "Down"
1217
    
1218
    cd8.em.msigdb <- do.call(rbind.data.frame, list(cd8.em.msigdb.up, cd8.em.msigdb.down))
1219
} else{
1220
    cd8.em.msigdb.down <- cd8.em.enriched.down[["MSigDB_Hallmark_2020"]]
1221
    cd8.em.msigdb.down$Dir <- "Down"
1222
    
1223
    cd8.em.msigdb <- do.call(rbind.data.frame, list(cd8.em.msigdb.up, cd8.em.msigdb.down))
1224
}
1225
cd8.em.msigdb$logP <- -log10(cd8.em.msigdb$P.value)
1226
cd8.em.msigdb$logP[cd8.em.msigdb$Dir %in% c("Down")] <- -1 * cd8.em.msigdb$logP[cd8.em.msigdb$Dir %in% c("Down")]
1227
1228
ggplot(cd8.em.msigdb[cd8.em.msigdb$P.value < 0.01, ],
1229
       aes(x=reorder(Term, logP), y=logP)) +
1230
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1231
    geom_point() +
1232
    coord_flip() +
1233
    labs(x="Pathway", y="Odds Rato") +
1234
    theme_cowplot()
1235
```
1236
1237
1238
```{r, fig.height=4.15, fig.width=4.15}
1239
cd8.em.tfppi.up <- cd8.em.enriched.up[["Transcription_Factor_PPIs"]]
1240
if(!is.null(cd8.em.tfppi.up)){
1241
    cd8.em.tfppi.up$Dir <- "Up"
1242
    
1243
    cd8.em.tfppi.down <- cd8.em.enriched.down[["Transcription_Factor_PPIs"]]
1244
    
1245
    cd8.em.tfppi.down$Dir <- "Down"
1246
    
1247
    cd8.em.tfppi <- do.call(rbind.data.frame, list(cd8.em.tfppi.up, cd8.em.tfppi.down))
1248
} else{
1249
    cd8.em.tfppi.down <- cd8.em.enriched.down[["Transcription_Factor_PPIs"]]
1250
    cd8.em.tfppi.down$Dir <- "Down"
1251
    
1252
    cd8.em.tfppi <- do.call(rbind.data.frame, list(cd8.em.tfppi.down))
1253
}
1254
cd8.em.tfppi$logP <- -log10(cd8.em.tfppi$P.value)
1255
cd8.em.tfppi$logP[cd8.em.tfppi$Dir %in% c("Down")] <- -1 * cd8.em.tfppi$logP[cd8.em.tfppi$Dir %in% c("Down")]
1256
1257
ggplot(cd8.em.tfppi[cd8.em.tfppi$P.value < 0.01, ],
1258
       aes(x=reorder(Term, logP), y=logP)) +
1259
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1260
    geom_point() +
1261
    coord_flip() +
1262
    labs(x="Pathway", y="Odds Rato") +
1263
    theme_cowplot()
1264
```
1265
1266
1267
1268
## CD8.TE
1269
1270
```{r, fig.height=3.95, fig.width=4.95}
1271
cd8.te.labels <- quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.TE"), ]$X
1272
cd8.te.labels[quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.TE"), ]$FDR > 1e-3] <- ""
1273
1274
ggplot(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.TE"), ],
1275
       aes(x=logFC, y=-log10(FDR))) +
1276
    geom_point() +
1277
    theme_cowplot() +
1278
    geom_text_repel(aes(label=cd8.te.labels)) +
1279
    ggsave("~/Dropbox/COVID19/Updated_plots/CD8.TE-quadratic_volcano.pdf",
1280
           height=3.95, width=4.95, useDingbats=FALSE) +
1281
    NULL
1282
```
1283
1284
1285
What are the enriched pathways amongst these genes?
1286
1287
```{r}
1288
cd8.te.enriched.up <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.TE") &
1289
                                                quadratic.dge.df$FDR < 0.01 &
1290
                                                quadratic.dge.df$logFC > 0, ]$X,
1291
                              enrich.dbs)
1292
1293
cd8.te.enriched.down <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD8.TE") &
1294
                                                quadratic.dge.df$FDR < 0.01 &
1295
                                                quadratic.dge.df$logFC < 0, ]$X,
1296
                              enrich.dbs)
1297
```
1298
1299
1300
## MSigDB 2020 enrichments
1301
1302
```{r, fig.height=4.15, fig.width=4.15}
1303
cd8.te.msigdb.up <- cd8.te.enriched.up[["MSigDB_Hallmark_2020"]]
1304
cd8.te.msigdb.up$Dir <- "Up"
1305
1306
cd8.te.msigdb.down <- cd8.te.enriched.down[["MSigDB_Hallmark_2020"]]
1307
if(nrow(cd8.te.msigdb.down) > 0){
1308
    cd8.te.msigdb.down$Dir <- "Down"
1309
}
1310
1311
cd8.te.msigdb <- do.call(rbind.data.frame, list(cd8.te.msigdb.up, cd8.te.msigdb.down))
1312
cd8.te.msigdb$logP <- -log10(cd8.te.msigdb$P.value)
1313
cd8.te.msigdb$logP[cd8.te.msigdb$Dir %in% c("Down")] <- -1 * cd8.te.msigdb$logP[cd8.te.msigdb$Dir %in% c("Down")]
1314
1315
ggplot(cd8.te.msigdb[cd8.te.msigdb$P.value < 0.01, ],
1316
       aes(x=reorder(Term, logP), y=logP)) +
1317
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1318
    geom_point() +
1319
    coord_flip() +
1320
    labs(x="Pathway", y="Odds Rato") +
1321
    theme_cowplot()
1322
```
1323
1324
1325
```{r, fig.height=4.15, fig.width=4.15}
1326
cd8.te.tfppi.up <- cd8.te.enriched.up[["Transcription_Factor_PPIs"]]
1327
if(nrow(cd8.te.tfppi.up) > 0){
1328
    cd8.te.tfppi.up$Dir <- "Up"
1329
}
1330
1331
cd8.te.tfppi.down <- cd8.te.enriched.down[["Transcription_Factor_PPIs"]]
1332
if(nrow(cd8.te.tfppi.down) > 0){
1333
    cd8.te.tfppi.down$Dir <- "Down"
1334
}
1335
1336
cd8.te.tfppi <- do.call(rbind.data.frame, list(cd8.te.tfppi.up, cd8.te.tfppi.down))
1337
cd8.te.tfppi$logP <- -log10(cd8.te.tfppi$P.value)
1338
cd8.te.tfppi$logP[cd8.te.tfppi$Dir %in% c("Down")] <- -1 * cd8.te.tfppi$logP[cd8.te.tfppi$Dir %in% c("Down")]
1339
1340
ggplot(cd8.te.tfppi[cd8.te.tfppi$P.value < 0.01, ],
1341
       aes(x=reorder(Term, logP), y=logP)) +
1342
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1343
    geom_point() +
1344
    coord_flip() +
1345
    labs(x="Pathway", y="Odds Rato") +
1346
    theme_cowplot()
1347
```
1348
1349
1350
1351
## CD4.Tfh
1352
1353
```{r, fig.height=3.95, fig.width=4.95}
1354
tfh.labels <- quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.Tfh"), ]$X
1355
tfh.labels[quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.Tfh"), ]$FDR > 1e-3] <- ""
1356
1357
ggplot(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.Tfh"), ],
1358
       aes(x=logFC, y=-log10(FDR))) +
1359
    geom_point() +
1360
    theme_cowplot() +
1361
    geom_text_repel(aes(label=tfh.labels)) +
1362
    ggsave("~/Dropbox/COVID19/Updated_plots/CD4.Tfh-quadratic_volcano.pdf",
1363
           height=3.95, width=4.95, useDingbats=FALSE) +
1364
    NULL
1365
```
1366
1367
What are the enriched pathways amongst these genes?
1368
1369
```{r}
1370
tfh.enriched.up <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.Tfh") &
1371
                                                quadratic.dge.df$FDR < 0.01 &
1372
                                                quadratic.dge.df$logFC > 0, ]$X,
1373
                              enrich.dbs)
1374
1375
tfh.enriched.down <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("CD4.Tfh") &
1376
                                                quadratic.dge.df$FDR < 0.01 &
1377
                                                quadratic.dge.df$logFC < 0, ]$X,
1378
                              enrich.dbs)
1379
```
1380
1381
1382
## MSigDB 2020 enrichments
1383
1384
```{r, fig.height=4.15, fig.width=4.15}
1385
tfh.msigdb.up <- tfh.enriched.up[["MSigDB_Hallmark_2020"]]
1386
if(!is.null(tfh.msigdb.up)){
1387
tfh.msigdb.up$Dir <- "Up"
1388
} 
1389
1390
tfh.msigdb.down <- tfh.enriched.down[["MSigDB_Hallmark_2020"]]
1391
if(!is.null(tfh.msigdb.down)){
1392
    tfh.msigdb.down$Dir <- "Down"
1393
}
1394
1395
if(!is.null(tfh.msigdb.down) & !is.null(tfh.msigdb.up)){
1396
    tfh.msigdb <- do.call(rbind.data.frame, list(tfh.msigdb.up, tfh.msigdb.down))
1397
    if(nrow(tfh.msigdb) > 0){
1398
        tfh.msigdb$logP <- -log10(tfh.msigdb$P.value)
1399
        tfh.msigdb$logP[tfh.msigdb$Dir %in% c("Down")] <- -1 * tfh.msigdb$logP[tfh.msigdb$Dir %in% c("Down")]
1400
        
1401
        ggplot(tfh.msigdb[tfh.msigdb$P.value < 0.01, ],
1402
               aes(x=reorder(Term, logP), y=logP)) +
1403
            geom_hline(yintercept=0, lty=2, colour='grey80') +
1404
            geom_point() +
1405
            coord_flip() +
1406
            labs(x="Pathway", y="Odds Rato") +
1407
            theme_cowplot()
1408
    }
1409
}
1410
```
1411
1412
1413
```{r, fig.height=4.15, fig.width=4.15}
1414
tfh.tfppi.up <- tfh.enriched.up[["Transcription_Factor_PPIs"]]
1415
if(!is.null(tfh.tfppi.up)){
1416
    tfh.tfppi.up$Dir <- "Up"
1417
}
1418
1419
tfh.tfppi.down <- tfh.enriched.down[["Transcription_Factor_PPIs"]]
1420
if(!is.null(tfh.tfppi.down)){
1421
    tfh.tfppi.down$Dir <- "Down"
1422
}
1423
1424
tfh.tfppi <- do.call(rbind.data.frame, list(tfh.tfppi.up, tfh.tfppi.down))
1425
if(nrow(tfh.tfppi) > 0){
1426
    tfh.tfppi$logP <- -log10(tfh.tfppi$P.value)
1427
    tfh.tfppi$logP[tfh.tfppi$Dir %in% c("Down")] <- -1 * tfh.tfppi$logP[tfh.tfppi$Dir %in% c("Down")]
1428
    
1429
    ggplot(tfh.tfppi[tfh.tfppi$P.value < 0.01, ],
1430
           aes(x=reorder(Term, logP), y=logP)) +
1431
        geom_hline(yintercept=0, lty=2, colour='grey80') +
1432
        geom_point() +
1433
        coord_flip() +
1434
        labs(x="Pathway", y="Odds Rato") +
1435
        theme_cowplot()
1436
}
1437
```
1438
1439
1440
1441
## gdT
1442
1443
```{r, fig.height=3.95, fig.width=4.95}
1444
gdt.labels <- quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("gdT"), ]$X
1445
gdt.labels[quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("gdT"), ]$FDR > 1e-3] <- ""
1446
1447
ggplot(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("gdT"), ],
1448
       aes(x=logFC, y=-log10(FDR))) +
1449
    geom_point() +
1450
    theme_cowplot() +
1451
    geom_text_repel(aes(label=gdt.labels)) +
1452
    ggsave("~/Dropbox/COVID19/Updated_plots/gdT-quadratic_volcano.pdf",
1453
           height=3.95, width=4.95, useDingbats=FALSE) +
1454
    NULL
1455
```
1456
1457
What are the enriched pathways amongst these genes?
1458
1459
```{r}
1460
gdt.enriched.up <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("gdT") &
1461
                                                quadratic.dge.df$FDR < 0.01 &
1462
                                                quadratic.dge.df$logFC > 0, ]$X,
1463
                              enrich.dbs)
1464
1465
gdt.enriched.down <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("gdT") &
1466
                                                quadratic.dge.df$FDR < 0.01 &
1467
                                                quadratic.dge.df$logFC < 0, ]$X,
1468
                              enrich.dbs)
1469
```
1470
1471
1472
## MSigDB 2020 enrichments
1473
1474
```{r, fig.height=4.15, fig.width=4.15}
1475
gdt.msigdb.up <- gdt.enriched.up[["MSigDB_Hallmark_2020"]]
1476
gdt.msigdb.up$Dir <- "Up"
1477
1478
gdt.msigdb.down <- gdt.enriched.down[["MSigDB_Hallmark_2020"]]
1479
gdt.msigdb.down$Dir <- "Down"
1480
1481
gdt.msigdb <- do.call(rbind.data.frame, list(gdt.msigdb.up, gdt.msigdb.down))
1482
gdt.msigdb$logP <- -log10(gdt.msigdb$P.value)
1483
gdt.msigdb$logP[gdt.msigdb$Dir %in% c("Down")] <- -1 * gdt.msigdb$logP[gdt.msigdb$Dir %in% c("Down")]
1484
1485
ggplot(gdt.msigdb[gdt.msigdb$P.value < 0.01, ],
1486
       aes(x=reorder(Term, logP), y=logP)) +
1487
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1488
    geom_point() +
1489
    coord_flip() +
1490
    labs(x="Pathway", y="Odds Rato") +
1491
    theme_cowplot()
1492
```
1493
1494
1495
```{r, fig.height=4.15, fig.width=4.15}
1496
gdt.tfppi.up <- gdt.enriched.up[["Transcription_Factor_PPIs"]]
1497
gdt.tfppi.up$Dir <- "Up"
1498
1499
gdt.tfppi.down <- gdt.enriched.down[["Transcription_Factor_PPIs"]]
1500
gdt.tfppi.down$Dir <- "Down"
1501
1502
gdt.tfppi <- do.call(rbind.data.frame, list(gdt.tfppi.up, gdt.tfppi.down))
1503
gdt.tfppi$logP <- -log10(gdt.tfppi$P.value)
1504
gdt.tfppi$logP[gdt.tfppi$Dir %in% c("Down")] <- -1 * gdt.tfppi$logP[gdt.tfppi$Dir %in% c("Down")]
1505
1506
ggplot(gdt.tfppi[gdt.tfppi$P.value < 0.01, ],
1507
       aes(x=reorder(Term, logP), y=logP)) +
1508
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1509
    geom_point() +
1510
    coord_flip() +
1511
    labs(x="Pathway", y="Odds Rato") +
1512
    theme_cowplot()
1513
```
1514
1515
1516
1517
1518
## MAIT
1519
1520
```{r, fig.height=3.95, fig.width=4.95}
1521
mait.labels <- quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("MAIT"), ]$X
1522
mait.labels[quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("MAIT"), ]$FDR > 1e-3] <- ""
1523
1524
ggplot(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("MAIT"), ],
1525
       aes(x=logFC, y=-log10(FDR))) +
1526
    geom_point() +
1527
    theme_cowplot() +
1528
    geom_text_repel(aes(label=mait.labels)) +
1529
    ggsave("~/Dropbox/COVID19/Updated_plots/MAIT-quadratic_volcano.pdf",
1530
           height=3.95, width=4.95, useDingbats=FALSE) +
1531
    NULL
1532
```
1533
1534
What are the enriched pathways amongst these genes?
1535
1536
```{r}
1537
mait.enriched.up <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("MAIT") &
1538
                                                quadratic.dge.df$FDR < 0.01 &
1539
                                                quadratic.dge.df$logFC > 0, ]$X,
1540
                              enrich.dbs)
1541
1542
mait.enriched.down <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("MAIT") &
1543
                                                quadratic.dge.df$FDR < 0.01 &
1544
                                                quadratic.dge.df$logFC < 0, ]$X,
1545
                              enrich.dbs)
1546
```
1547
1548
1549
## MSigDB 2020 enrichments
1550
1551
```{r, fig.height=4.15, fig.width=4.15}
1552
mait.msigdb.up <- mait.enriched.up[["MSigDB_Hallmark_2020"]]
1553
mait.msigdb.up$Dir <- "Up"
1554
1555
mait.msigdb.down <- mait.enriched.down[["MSigDB_Hallmark_2020"]]
1556
mait.msigdb.down$Dir <- "Down"
1557
1558
mait.msigdb <- do.call(rbind.data.frame, list(mait.msigdb.up, mait.msigdb.down))
1559
mait.msigdb$logP <- -log10(mait.msigdb$P.value)
1560
mait.msigdb$logP[mait.msigdb$Dir %in% c("Down")] <- -1 * mait.msigdb$logP[mait.msigdb$Dir %in% c("Down")]
1561
1562
ggplot(mait.msigdb[mait.msigdb$P.value < 0.01, ],
1563
       aes(x=reorder(Term, logP), y=logP)) +
1564
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1565
    geom_point() +
1566
    coord_flip() +
1567
    labs(x="Pathway", y="Odds Rato") +
1568
    theme_cowplot()
1569
```
1570
1571
1572
```{r, fig.height=4.15, fig.width=4.15}
1573
mait.tfppi.up <- mait.enriched.up[["Transcription_Factor_PPIs"]]
1574
mait.tfppi.up$Dir <- "Up"
1575
1576
mait.tfppi.down <- mait.enriched.down[["Transcription_Factor_PPIs"]]
1577
mait.tfppi.down$Dir <- "Down"
1578
1579
mait.tfppi <- do.call(rbind.data.frame, list(mait.tfppi.up, mait.tfppi.down))
1580
mait.tfppi$logP <- -log10(mait.tfppi$P.value)
1581
mait.tfppi$logP[mait.tfppi$Dir %in% c("Down")] <- -1 * mait.tfppi$logP[mait.tfppi$Dir %in% c("Down")]
1582
1583
ggplot(mait.tfppi[mait.tfppi$P.value < 0.01, ],
1584
       aes(x=reorder(Term, logP), y=logP)) +
1585
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1586
    geom_point() +
1587
    coord_flip() +
1588
    labs(x="Pathway", y="Odds Rato") +
1589
    theme_cowplot()
1590
```
1591
1592
1593
1594
## Treg
1595
1596
```{r, fig.height=3.95, fig.width=4.95}
1597
treg.labels <- quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("Treg"), ]$X
1598
treg.labels[quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("Treg"), ]$FDR > 1e-3] <- ""
1599
1600
ggplot(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("Treg"), ],
1601
       aes(x=logFC, y=-log10(FDR))) +
1602
    geom_point() +
1603
    theme_cowplot() +
1604
    geom_text_repel(aes(label=treg.labels)) +
1605
    ggsave("~/Dropbox/COVID19/Updated_plots/Treg-quadratic_volcano.pdf",
1606
           height=3.95, width=4.95, useDingbats=FALSE) +
1607
    NULL
1608
```
1609
1610
What are the enriched pathways amongst these genes?
1611
1612
```{r}
1613
treg.enriched.up <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("Treg") &
1614
                                                quadratic.dge.df$FDR < 0.01 &
1615
                                                quadratic.dge.df$logFC > 0, ]$X,
1616
                              enrich.dbs)
1617
1618
treg.enriched.down <- enrichr(quadratic.dge.df[quadratic.dge.df$Sub.Annotation %in% c("Treg") &
1619
                                                quadratic.dge.df$FDR < 0.01 &
1620
                                                quadratic.dge.df$logFC < 0, ]$X,
1621
                              enrich.dbs)
1622
```
1623
1624
1625
## MSigDB 2020 enrichments
1626
1627
```{r, fig.height=4.15, fig.width=4.15}
1628
treg.msigdb.up <- treg.enriched.up[["MSigDB_Hallmark_2020"]]
1629
treg.msigdb.up$Dir <- "Up"
1630
1631
treg.msigdb.down <- treg.enriched.down[["MSigDB_Hallmark_2020"]]
1632
treg.msigdb.down$Dir <- "Down"
1633
1634
treg.msigdb <- do.call(rbind.data.frame, list(treg.msigdb.up, treg.msigdb.down))
1635
treg.msigdb$logP <- -log10(treg.msigdb$P.value)
1636
treg.msigdb$logP[treg.msigdb$Dir %in% c("Down")] <- -1 * treg.msigdb$logP[treg.msigdb$Dir %in% c("Down")]
1637
1638
ggplot(treg.msigdb[treg.msigdb$P.value < 0.01, ],
1639
       aes(x=reorder(Term, logP), y=logP)) +
1640
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1641
    geom_point() +
1642
    coord_flip() +
1643
    labs(x="Pathway", y="Odds Rato") +
1644
    theme_cowplot()
1645
```
1646
1647
1648
```{r, fig.height=4.15, fig.width=4.15}
1649
treg.tfppi.up <- treg.enriched.up[["Transcription_Factor_PPIs"]]
1650
treg.tfppi.up$Dir <- "Up"
1651
1652
treg.tfppi.down <- treg.enriched.down[["Transcription_Factor_PPIs"]]
1653
treg.tfppi.down$Dir <- "Down"
1654
1655
treg.tfppi <- do.call(rbind.data.frame, list(treg.tfppi.up, treg.tfppi.down))
1656
treg.tfppi$logP <- -log10(treg.tfppi$P.value)
1657
treg.tfppi$logP[treg.tfppi$Dir %in% c("Down")] <- -1 * treg.tfppi$logP[treg.tfppi$Dir %in% c("Down")]
1658
1659
ggplot(treg.tfppi[treg.tfppi$P.value < 0.01, ],
1660
       aes(x=reorder(Term, logP), y=logP)) +
1661
    geom_hline(yintercept=0, lty=2, colour='grey80') +
1662
    geom_point() +
1663
    coord_flip() +
1664
    labs(x="Pathway", y="Odds Rato") +
1665
    theme_cowplot()
1666
```
1667
1668
1669
1670