-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.P259.pDC_GSEA.Rmd
266 lines (208 loc) · 7.8 KB
/
3.P259.pDC_GSEA.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
---
title: 'P259: Gene set enrichment analysis (GSEA)'
subtitle: "Dendritic cells (pDC)"
author: "Kim Dill-McFarland, [email protected]"
date: "version `r format(Sys.time(), '%B %d, %Y')`"
output:
html_document:
toc: yes
toc_depth: 3
toc_float:
collapsed: no
pdf_document:
toc: yes
toc_depth: '3'
editor_options:
chunk_output_type: console
---
# Background
The purpose of this workflow is to perform GSEA for the impacts of human rhinovirus (RV) infection, eosinophil (EOS) supernatant, and Anti-IL5 therapy.
# Setup
Load packages
```{r message=FALSE, warning=FALSE}
# Data manipulation and figures
library(tidyverse)
# Multipanel figures
library(cowplot)
#GSEA
library(fgsea)
library(gage)
#Print pretty tables to Rmd
library(knitr)
library(kableExtra)
```
Set seed
```{r}
set.seed(589)
```
# Load data
## RNA-seq
Contrast model results.
```{r results.data, message=FALSE}
pval_2 <- read_csv("results/gene_level/P259.2_gene_pval.csv") %>%
filter(model=="contrasts")
pval_1 <- read_csv("results/gene_level/P259.1_gene_pval.csv") %>%
filter(model=="contrasts")
```
Extract and format fold change (FC) for each contrast.
```{r}
gene.ls <- list()
for (contrast in unique(pval_2$group)){
#Subset to contrast of interest
pval.temp <- pval_2 %>% filter(group == contrast)
genes.temp <- pval.temp$logFC
names(genes.temp) <- pval.temp$hgnc_symbol
list.name <- paste(gsub(" - ", ".", contrast), 2, sep=".")
gene.ls[[list.name]] <- genes.temp
}
for (contrast in unique(pval_1$group)){
#Subset to contrast of interest
pval.temp <- pval_1 %>% filter(group == contrast)
genes.temp <- pval.temp$logFC
names(genes.temp) <- pval.temp$hgnc_symbol
list.name <- paste(gsub(" - ", ".", contrast), 1, sep=".")
gene.ls[[list.name]] <- genes.temp
}
```
## Broad gene sets
From <https://www.gsea-msigdb.org/gsea/msigdb/collections.jsp>. Downloaded in `data_clean/Broad_gmt/`
# Gene set enrichment analysis (GSEA)
The following function performs GSEA using both fast gene set enrichment analysis (`fgsea`) and generally applicable gene-set enrichment (`gage`).
```{r}
source("https://raw.githubusercontent.com/kdillmcfarland/R_bioinformatic_scripts/master/GSEA_fxn.R")
```
## Run GSEA
#### Hallmark (H)
```{r h, warnings=FALSE, message=FALSE, eval=FALSE}
GSEA(gene_list = gene.ls,
gmt_file="data_clean/Broad_gmt/h.all.v7.4.symbols.gmt")
```
#### Curated canonical pathway gene sets (C2:CP)
```{r c2, warnings=FALSE, message=FALSE, eval=FALSE}
GSEA(gene_list = gene.ls,
gmt_file="data_clean/Broad_gmt/c2.cp.v7.4.symbols.gmt")
```
#### GO biological procress gene sets (C5:GO:BP)
```{r c5, warnings=FALSE, message=FALSE, eval=FALSE}
GSEA(gene_list = gene.ls,
gmt_file="data_clean/Broad_gmt/c5.go.bp.v7.4.symbols.gmt")
```
## Significant GSEA
```{r echo=FALSE, message=FALSE}
fdr.cut <- 0.1
#Load results for faster knitting
h_GSEA.result <- read_csv("results/GSEA/h_GSEA.result.csv")
c2_GSEA.result <- read_csv("results/GSEA/c2_GSEA.result.csv")
c5_GSEA.result <- read_csv("results/GSEA/c5_GSEA.result.csv")
#Combine and filter signif
GSEA.all <- bind_rows(h_GSEA.result,c2_GSEA.result,c5_GSEA.result)
#list all terms with at least 1 significant treatment contrast
term.OI.t <- GSEA.all %>%
filter(fgsea.FDR <= fdr.cut & gage.FDR <= fdr.cut) %>%
filter(group %in% c("AntiIL5_nonenone_none", "AntiIL5_HRVnone_HRV",
"EOSsupp_nonenone_none", "EOSsupp_HRVnone_HRV")) %>%
distinct(pathway) %>% unlist(use.names=FALSE)
#list all terms with at least 1 significant virus contrast
term.OI.v <- GSEA.all %>%
filter(fgsea.FDR <= fdr.cut & gage.FDR <= fdr.cut) %>%
filter(group %in% c("none_HRVnone_none","AntiIL5_HRVAntiIL5_none",
"EOSsupp_HRVEOSsupp_none")) %>%
distinct(pathway) %>% unlist(use.names=FALSE)
#Find terms with both t and v cutoffs
term.OI <- intersect(term.OI.t, term.OI.v)
GSEA.signif <- GSEA.all %>%
filter(pathway %in% term.OI)
```
Gene sets of interest are those significant for both virus AND EOS supernatant or Anti-IL5 therapy. Results are only considered significant if both fgsea and gage methods meet the FDR threshold in the same fold change direction.
```{R echo=FALSE}
GSEA.signif %>%
select(pathway, group, fgsea.FDR,fgsea.NES) %>%
separate(pathway, into=c("set","pathway"), sep="_", extra = "merge") %>%
select(set, pathway, group, fgsea.FDR,fgsea.NES) %>%
arrange(set, pathway, fgsea.NES) %>%
kable() %>%
kable_styling(bootstrap_options = "striped", full_width = FALSE) %>%
collapse_rows(1:2, valign = "top")
```
# Hypergeometric enrichment of DEGs
```{r echo=FALSE}
fdr.cut <- 0.1
```
Test for Broad gene set enrichment in differentially expressed genes (DEG) as defined by change with virus (*e.g.* significant for virus in untreated and/or treated donors) AND different between untreated and treated donors in media OR RV. DEGs are defined at FDR < `r fdr.cut`
```{r}
#Define change with virus
DEG1.v <- read_csv("results/gene_level/P259.1_gene_pval.csv") %>%
filter(group %in% c("none_HRV - none_none", "EOS.supp_HRV - EOS.supp_none") &
adj.P.Val <= fdr.cut)
#Define change with treament
DEG1.t <- read_csv("results/gene_level/P259.1_gene_pval.csv") %>%
filter(group %in% c("EOS.supp_none - none_none", "EOS.supp_HRV - none_HRV") &
adj.P.Val <= fdr.cut)
#Define change with virus
DEG2.v <- read_csv("results/gene_level/P259.2_gene_pval.csv") %>%
filter(group %in% c("none_HRV - none_none", "AntiIL5_HRV - AntiIL5_none") &
adj.P.Val <= fdr.cut)
#Define change with treament
DEG2.t <- read_csv("results/gene_level/P259.2_gene_pval.csv") %>%
filter(group %in% c("AntiIL5_none - none_none", "AntiIL5_HRV - none_HRV") &
adj.P.Val <= fdr.cut)
#Format in list
DEG.ls <- list()
DEG.ls[["EOSsup"]] <- intersect(DEG1.v$hgnc_symbol, DEG1.t$hgnc_symbol)
DEG.ls[["AntiIL5"]] <- intersect(DEG2.v$hgnc_symbol, DEG2.t$hgnc_symbol)
```
```{r message=FALSE, warning=FALSE}
#Script for running term enrichment
source("https://raw.githubusercontent.com/kdillmcfarland/R_bioinformatic_scripts/master/hypergeo_enricher.R")
```
## Run enrichment
#### Hallmark (H)
```{r h.2, warnings=FALSE, message=FALSE, eval=FALSE}
enrich.fxn(gene.list = DEG.ls, ID.type="SYMBOL",
category = "H",
genome = "org.Hs.eg.db",
basename = "DEG",
outdir = "results/enrichment/")
```
#### Curated canonical pathway gene sets (C2:CP)
```{r c2.2, warnings=FALSE, message=FALSE, eval=FALSE}
enrich.fxn(gene.list = DEG.ls, ID.type="SYMBOL",
category = "C2", subcategory="CP",
genome = "org.Hs.eg.db",
basename = "DEG",
outdir = "results/enrichment/")
```
#### GO biological procress gene sets (C5:GO:BP)
```{r c5.2, warnings=FALSE, message=FALSE, eval=FALSE}
enrich.fxn(gene.list = DEG.ls, ID.type="SYMBOL",
category = "C5", subcategory = "GO:BP",
genome = "org.Hs.eg.db",
basename = "DEG",
outdir = "results/enrichment/")
```
## Significant enrichment
```{r echo=FALSE, message=FALSE}
fdr.cut <- 0.05
#Load results for faster knitting
h_enrich.result <- read_csv("results/enrichment/enrich_DEG_H.csv")
c2_enrich.result <- read_csv("results/enrichment/enrich_DEG_C2_CP.csv")
c5_enrich.result <- read_csv("results/enrichment/enrich_DEG_C5_GO.BP.csv")
#Combine and filter signif
enrich.signif <- bind_rows(h_enrich.result,c2_enrich.result,c5_enrich.result)%>%
filter(p.adjust <= fdr.cut)
```
Gene sets enriched in DEGs at FDR < `r fdr.cut`
```{R echo=FALSE}
enrich.signif %>%
separate(Description, into=c("set","pathway"), sep="_", extra = "merge") %>%
dplyr::select(group, set, pathway, p.adjust, SYMBOLs) %>%
arrange(group, set, p.adjust) %>%
kable() %>%
kable_styling(bootstrap_options = "striped", full_width = FALSE) %>%
collapse_rows(1:2, valign = "top")
```
# R session
```{r}
sessionInfo()
```
***