iSEEpathways 1.2.0
In this vignette, we demonstrate how one may use the package GO.db to dynamically display additional information about selected pathways in the interactive user interface.
First, we generate pathway analysis results for simulated data using fgsea.
In particular, we use the package org.Hs.eg.db to fetch real gene sets. To reduce memory footprint, we retain only the gene sets associated with 15 to 500 genes.
Then, we simulate a score for each of the gene present in any of those remaining gene sets. In practice, that score could be the log2 fold-change of the gene in a differential expression analysis (among other possibilities).
Finally, we perform an FGSEA on the simulated data.
library("org.Hs.eg.db")
library("fgsea")
# Example data ----
## Pathways
pathways <- select(org.Hs.eg.db, keys(org.Hs.eg.db, "SYMBOL"), c("GOALL"), keytype = "SYMBOL")
pathways <- subset(pathways, ONTOLOGYALL == "BP")
pathways <- unique(pathways[, c("SYMBOL", "GOALL")])
pathways <- split(pathways$SYMBOL, pathways$GOALL)
len_pathways <- lengths(pathways)
pathways <- pathways[len_pathways > 15 & len_pathways < 500]
## Features
set.seed(1)
# simulate a score for all genes found across all pathways
feature_stats <- rnorm(length(unique(unlist(pathways))))
names(feature_stats) <- unique(unlist(pathways))
# arbitrarily select a pathway to simulate enrichment
pathway_id <- "GO:0046324"
pathway_genes <- pathways[[pathway_id]]
# increase score of genes in the selected pathway to simulate enrichment
feature_stats[pathway_genes] <- feature_stats[pathway_genes] + 1
# fgsea ----
set.seed(42)
fgseaRes <- fgsea(pathways = pathways,
stats = feature_stats,
minSize = 15,
maxSize = 500)
head(fgseaRes[order(pval), ])
#> pathway pval padj log2err ES NES size
#> <char> <num> <num> <num> <num> <num> <int>
#> 1: GO:0046323 2.018801e-09 9.026334e-06 0.7749390 0.5528682 2.358238 78
#> 2: GO:0046324 3.683466e-09 9.026334e-06 0.7749390 0.6107195 2.482373 60
#> 3: GO:0010827 3.316644e-07 5.418291e-04 0.6749629 0.5055047 2.156210 78
#> 4: GO:0046326 7.586889e-07 9.295836e-04 0.6594444 0.6448166 2.350896 37
#> 5: GO:0010828 1.635088e-06 1.602713e-03 0.6435518 0.5906760 2.223814 44
#> 6: GO:1904659 3.387729e-06 2.525999e-03 0.6272567 0.4322504 1.974356 118
#> leadingEdge
#> <list>
#> 1: AKT1, SE....
#> 2: AKT1, SE....
#> 3: AKT1, SE....
#> 4: AKT1, ER....
#> 5: AKT1, ER....
#> 6: AKT1, SE....
Then, we embed the fgsea results in a SummarizedExperiment object.
In this case, we create an empty ?SummarizedExperiment-class
object, without any simulated count data nor metadata, as we will not be using any of those data in this example.
We then embed the pathway analysis results in the newly created ?SummarizedExperiment-class
object.
But first, we reorder the results by increasing p-value. Although not essential, this implicitly defines the default ordering of the table in the live app.
library("SummarizedExperiment")
library("iSEEpathways")
se <- SummarizedExperiment()
fgseaRes <- fgseaRes[order(pval), ]
se <- embedPathwaysResults(fgseaRes, se, name = "fgsea", class = "fgsea", pathwayType = "GO")
In this example, we configure the app option PathwaysTable.select.details
to define a function that,
given the identifier of the GO term currently selected in a panel,
displays information about that GO term.
Although not essential, this is a user-friendly and immediate way to ‘translate’ machine-friendly database identifiers into human-friendly descriptions.
library("iSEE")
library("GO.db")
library("shiny")
go_details <- function(x) {
info <- select(GO.db, x, c("TERM", "ONTOLOGY", "DEFINITION"), "GOID")
html <- list(p(strong(info$GOID), ":", info$TERM, paste0("(", info$ONTOLOGY, ")")))
if (!is.na(info$DEFINITION)) {
html <- append(html, list(p(info$DEFINITION)))
}
tagList(html)
}
se <- registerAppOptions(se, PathwaysTable.select.details = go_details)
Finally, we configure the app initial state and launch the live app.
app <- iSEE(se, initial = list(
PathwaysTable(ResultName="fgsea", Selected = "GO:0046324", PanelWidth = 12L)
))
if (interactive()) {
shiny::runApp(app)
}