knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(radialgo) install.packages("BiocManager", repos="http://cran.utstat.utoronto.ca/") library(BiocManager) BiocManager::install("topGO") BiocManager::install("hgu95av2.db") BiocManager::install("ALL") library(topGO) library(ALL)
RadialGO is a package for visualizing Gene Ontology enrichment analyses, using a radial tree layout. This document gives a quick tour of how to use the package.
The function generateGraph() produces a graph of the GO enrichment, taking as input 3 parameters: the first is a CSV file containing a "GO ID" column, which consists of Gene Ontology identifiers such as "GO:0008150", and a "P value" column, consisting of the corresponding P-value in the enrichment analysis.
An example workflow follows.
For this example we will obtain the GO enrichment results using the topGO package.
data(ALL) data(geneList) affyLib <- paste(annotation(ALL), "db", sep = ".") library(package = affyLib, character.only = TRUE) sampleGOdata <- new("topGOdata", description = "Simple session", ontology = "BP", allGenes = geneList, geneSel = topDiffGenes, nodeSize = 10, annot = annFUN.db, affyLib = affyLib) resultFisher <- runTest(sampleGOdata, algorithm = "classic", statistic = "fisher")
This gets us our GO enrichment analysis results in the variable resultFisher. We can use the score() function to extract a named numeric vector containing GO IDs and P values, which we will use to build a data frame.
df <- data.frame("GO ID"= names(score(resultFisher)), "P value"= as.numeric(score(resultFisher))) df
We can store this data frame easily using the following code:
write.csv(df, "enrichment_results.csv")
Once we have this data frame, we can call generateGraph() to create our graph, and then render it:
library(radialgo) library(DiagrammeR) gr <- generateGraph(df, 5, 0.5) DiagrammeR::grViz(generate_dot(gr))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.