-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
243 lines (187 loc) · 7.34 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
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "inst/figures/",
out.width = "100%"
)
```
<div align="center">
**F**isher's Test for **E**nrichment and **D**epletion of **U**ser-Defined **P**athways
<img align="right" width="300" height="345" src="inst/figures/fedup.png">
[![Build Status](https://travis-ci.com/rosscm/fedup.svg?token=GNK3AGqE8dtKVRC56zpJ&branch=main)](https://travis-ci.com/rosscm/fedup)
![R-CMD-check](https://github.com/rosscm/fedup/workflows/R-CMD-check/badge.svg)
![R-CMD-check-bioc](https://github.com/rosscm/fedup/workflows/R-CMD-check-bioc/badge.svg)
![test-coverage](https://github.com/rosscm/fedup/workflows/test-coverage/badge.svg)
[![codecov](https://codecov.io/gh/rosscm/fedup/branch/main/graph/badge.svg?token=AVOAV1ILVL)](https://codecov.io/gh/rosscm/fedup)
<div align="left">
`fedup` is an R package that tests for enrichment and depletion of user-defined
pathways using a Fisher's exact test. The method is designed for versatile
pathway annotation formats (eg. gmt, txt, xlsx) to allow the user to run
pathway analysis on custom annotations. This package is also
integrated with Cytoscape to provide network-based pathway visualization
that enhances the interpretability of the results.
This README will quickly demonstrate how to use `fedup` when testing two
sets of genes. Refer to full
[vignettes](https://www.bioconductor.org/packages/devel/bioc/html/fedup.html)
for additional information and implementations (e.g., using single or
multiple test sets).
# Contents
- [System prerequisites](#system-prerequisites)
- [Installation](#installation)
- [Running the package](#running-the-package)
* [Input data](#input-data)
* [Pathway analysis](#pathway-analysis)
* [Dot plot](#dot-plot)
* [Enrichment map](#enrichment-map)
- [Versioning](#versioning)
- [Shoutouts](#shoutouts)
# System prerequisites
**R version** ≥ 4.1
**R packages**:
- **CRAN**: openxlsx, tibble, dplyr, data.table, ggplot2, ggthemes,
forcats, RColorBrewer
- **Bioconductor**: RCy3
# Installation
Install `fedup` from Bioconductor:
```{r, eval = FALSE, message = FALSE}
if(!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("fedup")
```
Or install the development version from Github:
```{r, message = FALSE}
devtools::install_github("rosscm/fedup", quiet = TRUE)
```
Load necessary packages:
```{r, message = FALSE}
library(fedup)
library(dplyr)
library(tidyr)
library(ggplot2)
```
# Running the package
## Input data
Load test genes (`geneDouble`) and pathway annotations (`pathwaysGMT`):
```{r}
data(geneDouble)
data(pathwaysGMT)
```
Take a look at the data structure:
```{r}
str(geneDouble)
str(head(pathwaysGMT))
```
To see more info on this data, run `?geneDouble` or `?pathwaysGMT`.
You could also run `example("prepInput", package = "fedup")` or
`example("readPathways", package = "fedup")` to see exactly how the
data was generated using the `prepInput()` and `readPathways()` functions.
`?` and `example()` can be used on any other functions mentioned here to
see their documentation and run examples.
## Pathway analysis
Now use `runFedup` on the sample data:
```{r}
fedupRes <- runFedup(geneDouble, pathwaysGMT)
```
The `fedupRes` output is a list of length `length(which(names(geneDouble) !=
"background"))`, corresponding to the number of test sets in `geneDouble`
(i.e., 2).
View `fedup` results for `FASN_negative` sorted by pvalue:
```{r}
set <- "FASN_negative"
print(head(fedupRes[[set]][which(fedupRes[[set]]$status == "enriched"),]))
print(head(fedupRes[[set]][which(fedupRes[[set]]$status == "depleted"),]))
```
Let's also view `fedup` results for `FASN_positive`, sorted by pvalue:
```{r}
set <- "FASN_positive"
print(head(fedupRes[[set]][which(fedupRes[[set]]$status == "enriched"),]))
print(head(fedupRes[[set]][which(fedupRes[[set]]$status == "depleted"),]))
```
## Dot plot
Prepare data for plotting via `dplyr` and `tidyr`:
```{r}
fedupPlot <- fedupRes %>%
bind_rows(.id = "set") %>%
separate(col = "set", into = c("set", "sign"), sep = "_") %>%
subset(qvalue < 0.05) %>%
mutate(log10qvalue = -log10(qvalue)) %>%
mutate(pathway = gsub("\\%.*", "", pathway)) %>%
mutate(status = factor(status, levels = c("enriched", "depleted"))) %>%
as.data.frame()
```
Plot significant results (qvalue < 0.05) in the form of a dot plot via
`plotDotPlot`. Colour and facet the points by the `sign` column:
```{r, fedupDotplot, fig.width = 11, fig.height = 15.5}
p <- plotDotPlot(
df = fedupPlot,
xVar = "log10qvalue",
yVar = "pathway",
xLab = "-log10(qvalue)",
fillVar = "sign",
fillLab = "Genetic interaction",
fillCol = c("#6D90CA", "#F6EB13"),
sizeVar = "fold_enrichment",
sizeLab = "Fold enrichment") +
facet_grid("sign", scales = "free", space = "free") +
theme(strip.text.y = element_blank())
print(p)
```
Look at all those chick... enrichments! This is a bit overwhelming, isn't it?
How do we interpret these 156 fairly redundant pathways in a way that doesn't
hurt our tired brains even more? Oh I know, let's use an enrichment map!
## Enrichment map
First, make sure to have
[Cytoscape](https://cytoscape.org/download.html) downloaded and and open
on your computer. You’ll also need to install the
[EnrichmentMap](http://apps.cytoscape.org/apps/enrichmentmap) (≥ v3.3.0) and
[AutoAnnotate](http://apps.cytoscape.org/apps/autoannotate) apps.
Then format results for compatibility with EnrichmentMap using `writeFemap`:
```{r}
resultsFolder <- tempdir()
writeFemap(fedupRes, resultsFolder)
```
Prepare a pathway annotation file (gmt format) from the pathway list you
passed to `runFedup` using the `writePathways` function (you don't need to run
this function if your pathway annotations are already in gmt format, but it
doesn't hurt to make sure):
```{r}
gmtFile <- tempfile("pathwaysGMT", fileext = ".gmt")
writePathways(pathwaysGMT, gmtFile)
```
Cytoscape is open right? If so, run these lines and let the `plotFemap`
magic happen:
```{r, fedupEM, eval = FALSE}
netFile <- tempfile("fedupEM", fileext = ".png")
plotFemap(
gmtFile = gmtFile,
resultsFolder = resultsFolder,
qvalue = 0.05,
chartData = "DATA_SET",
hideNodeLabels = TRUE,
netName = "fedupEM",
netFile = netFile
)
```
To note here, the EM nodes were coloured manually (by the same colours passed to
`plotDotPlot`) in Cytoscape via the *Change Colors* option in the EM panel.
A feature for automated dataset colouring is set to be released in
[version 3.3.2](https://github.com/BaderLab/EnrichmentMapApp/issues/455)
of EnrichmentMap.
![](inst/figures/fedupEM.png)
This has effectively summarized the 156 pathways from our dot plot into 21
unique biological themes (including 4 unclustered pathways). We can now see
clear themes in the data pertaining to negative *FASN* genetic interactions,
such as `diseases glycosylation, proteins`, `golgi transport`, and
`rab regulation trafficking`. These can be compared and constrasted with the
enrichment seen for *FASN* positive interactions.
Try this out yourself! Hopefully it’s the only fedup you achieve
:grimacing:
# Versioning
For the versions available, see the [tags on this
repo](https://github.com/rosscm/fedup/tags).
# Shoutouts
:sparkles:[**2020**](https://media.giphy.com/media/z9AUvhAEiXOqA/giphy.gif):sparkles: