| Title: | Sunburst Plot for Enriched Gene Ontology Terms |
|---|---|
| Description: | GOfan provides an intuitive and compact visualization of Gene Ontology (GO) enrichment results using a sunburst layout inspired by SynGO, preserving hierarchical relationships among GO terms and allowing color-based encoding of information such as p-values or gene counts. By converting complex GO DAGs into clean, circular representations, it allows researchers to quickly grasp the hierarchical structure and biological significance of enriched terms. The interactive and customizable visualizations facilitate exploration of key GO categories, enhancing interpretation and presentation of enrichment analyses. |
| Authors: | Jianhong Ou [aut, cre] (ORCID: <https://orcid.org/0000-0002-8652-2488>), Kenneth Poss [aut, fnd] |
| Maintainer: | Jianhong Ou <[email protected]> |
| License: | GPL-3 |
| Version: | 1.1.0 |
| Built: | 2026-05-10 09:33:57 UTC |
| Source: | https://github.com/bioc/GOfan |
GOfan provides a simple and intuitive way to visualize Gene Ontology (GO) enrichment results using a sunburst layout inspired by SynGO. Unlike graph-based or dot plot methods, it preserves hierarchical relationships among GO terms while maintaining a clean, interpretable view. GOfan accepts any enrichment results containing GO identifiers and uses color to represent additional information such as p-values or gene counts, making GO analysis both informative and visually engaging.
Jianhong Ou
Maintainer: Jianhong Ou [email protected]
Useful links:
Cut the input igraph object by the distances from the root.
filterGraph( g, leaveTerms, cutoff = 4, filterNodesByEdgeNumber = 0, mustkeep = c(), onlyKeep = c() )filterGraph( g, leaveTerms, cutoff = 4, filterNodesByEdgeNumber = 0, mustkeep = c(), onlyKeep = c() )
g |
A igraph object |
leaveTerms |
Leaves must contained GO terms. |
cutoff |
The cutoff distance from the root |
filterNodesByEdgeNumber |
Filter the graphs by the edge number. |
mustkeep |
The GO terms must be kept. |
onlyKeep |
Only keep branches with give GO terms. |
A igraph object after filtering
library(igraph) g_gnp <- sample_gnp(n = 25, p = 0.05) filterGraph(g_gnp, leaveTerms = V(g_gnp), cutoff = 2)library(igraph) g_gnp <- sample_gnp(n = 25, p = 0.05) filterGraph(g_gnp, leaveTerms = V(g_gnp), cutoff = 2)
create a sunburst geom.
geom_sunburst( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "mitre", parse = FALSE, size.unit = "mm", check_overlap = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )geom_sunburst( mapping = NULL, data = NULL, stat = "identity", position = "identity", ..., lineend = "butt", linejoin = "mitre", parse = FALSE, size.unit = "mm", check_overlap = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE )
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
stat |
The statistical transformation to use on the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
... |
Other arguments passed on to
|
lineend |
Line end style (round, butt, square). |
linejoin |
Line join style (round, mitre, bevel). |
parse |
If |
size.unit |
How the |
check_overlap |
If |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
Please note that the width and height aesthetics are not true position
aesthetics and therefore are not subject to scale transformation. It is
only after transformation that these aesthetics are applied.
A ggplot object
geom_sunburst understands the following aesthetics:
x define the locations of x.
y define the locations of y.
xmin define the bottom of rectangle
ymin define the left of rectangle
xmax define the top of rectangle
ymax define the right of rectangle
width define the width of rectangle
height define the height of rectangle
colour rectangle border color
fill rectangle fill color
alpha rectangle fill alpha and font alpha
linewidth line width for rectangle
linetype line type for rectangle
label label text
angle label angle
family label family
size label default size
fontcolour font color
fontface font face
lineheight font line height
hjust horizontal just for label
vjust vertical just for label
rotate90 Rotate the labels 90 degree or not. Default NULL will try
to auto rotate the labels according the space.
sub_rect A proportional sub-rectangle representing a share of the
whole.
plotdata <- data.frame( id = c("GO:0023052", "GO:0007267", "GO:0099536", "GO:0099537", "GO:0098916"), x = 0.5, y = seq.int(5), xmin = 0, ymin = c(0.5, 1.5, 2.5, 3.5, 4.5), xmax = 1, ymax = c(1.5, 2.5, 3.5, 4.5, 5.5), fill = seq(1, 5), label = c( "signaling", "cell-cell signaling", "synaptic signaling", "trans-synaptic signaling", "anterograde trans-synaptic signaling" ) ) library(ggplot2) ggplot(plotdata, aes( x = x, y = y, xmin = xmin, ymin = ymin, xmax = xmax, ymax = ymax, fill = fill, label = label )) + geom_sunburst(size = 0.5, angle = -90) + coord_polar()plotdata <- data.frame( id = c("GO:0023052", "GO:0007267", "GO:0099536", "GO:0099537", "GO:0098916"), x = 0.5, y = seq.int(5), xmin = 0, ymin = c(0.5, 1.5, 2.5, 3.5, 4.5), xmax = 1, ymax = c(1.5, 2.5, 3.5, 4.5, 5.5), fill = seq(1, 5), label = c( "signaling", "cell-cell signaling", "synaptic signaling", "trans-synaptic signaling", "anterograde trans-synaptic signaling" ) ) library(ggplot2) ggplot(plotdata, aes( x = x, y = y, xmin = xmin, ymin = ymin, xmax = xmax, ymax = ymax, fill = fill, label = label )) + geom_sunburst(size = 0.5, angle = -90) + coord_polar()
Recursive function to extract (ancestor, offspring) pairs
getAncestors(GO_IDs, onto = c("BP", "CC", "MF"))getAncestors(GO_IDs, onto = c("BP", "CC", "MF"))
GO_IDs |
The Gene ontology term ids |
onto |
The category of the GO ids. It should be one of "BP", "CC", or "MF". |
A data frame with columns ancestor and offspring
ids <- c( "GO:0099536", "GO:0099537", "GO:0007268", "GO:0098916", "GO:0050804", "GO:0099177" ) df <- getAncestors(ids, onto = "BP") head(df)ids <- c( "GO:0099536", "GO:0099537", "GO:0007268", "GO:0098916", "GO:0050804", "GO:0099177" ) df <- getAncestors(ids, onto = "BP") head(df)
Extract all the entrez IDs from a given GO IDs
getGOalias(GO_IDs, org)getGOalias(GO_IDs, org)
GO_IDs |
The Gene ontology term id |
org |
The OrgDb |
A list of entrez IDs for the given GO IDs
library(org.Dr.eg.db) ids <- c( "GO:0099536", "GO:0099537", "GO:0007268", "GO:0098916", "GO:0050804", "GO:0099177" ) eids <- getGOalias(ids, org.Dr.eg.db)library(org.Dr.eg.db) ids <- c( "GO:0099536", "GO:0099537", "GO:0007268", "GO:0098916", "GO:0050804", "GO:0099177" ) eids <- getGOalias(ids, org.Dr.eg.db)
By a given GO enrichment results, extract GO ancestor and offspring info from GO.db and then generate a simplified tree like graph.
getGraph(df, org, termID = "ID", onto = c("BP", "CC", "MF"))getGraph(df, org, termID = "ID", onto = c("BP", "CC", "MF"))
df |
A data frame with enriched GO terms |
org |
An Go3AnnDbBimap object eg org.Dr.egGO2ALLEGS |
termID |
Column name in df which store the GO IDs |
onto |
The ontology category of the GO IDs |
A igraph graph.
library(org.Dr.eg.db) goids <- c("GO:0099536", "GO:0099537", "GO:0007268", "GO:0098916", "GO:0050804") g <- getGraph(data.frame(ID = goids), org = org.Dr.eg.db, onto = "BP")library(org.Dr.eg.db) goids <- c("GO:0099536", "GO:0099537", "GO:0007268", "GO:0098916", "GO:0050804") g <- getGraph(data.frame(ID = goids), org = org.Dr.eg.db, onto = "BP")
Creates sunburst diagram using ggplot2.
ggSunburst( plotdata, fontsize = 1, rotate90 = NULL, maxCharacters = 30, legendTitle = "color", start = 0, end = NULL, clip = "off", expand = FALSE, ... )ggSunburst( plotdata, fontsize = 1, rotate90 = NULL, maxCharacters = 30, legendTitle = "color", start = 0, end = NULL, clip = "off", expand = FALSE, ... )
plotdata |
A data.frame. |
fontsize |
Default fontsize. |
rotate90 |
Rotate the labels 90 degree or not. Default NULL will try to auto rotate the labels according the space. |
maxCharacters |
Maximal number of characters for labels |
legendTitle |
The title of the legend. |
start, end
|
Offset of starting or ending point from 12 o'clock in radians. see coord_radial. |
clip |
Should drawing be clipped to the extent of the plot panel? Default "on" means yes. |
expand |
If TRUE, adds a small expansion factor the the limits to prevent overlap between data and axes. If FALSE, the default, limits are taken directly from the scale. |
... |
Other parameters (except theta) passed to coord_radial. |
A ggplot object
plotdata <- data.frame( id = c("GO:0023052", "GO:0007267", "GO:0099536", "GO:0099537", "GO:0098916"), x = 0.5, y = seq.int(5), xmin = 0, ymin = c(0.5, 1.5, 2.5, 3.5, 4.5), xmax = 1, ymax = c(1.5, 2.5, 3.5, 4.5, 5.5), fill = seq(1, 5), label = c( "signaling", "cell-cell signaling", "synaptic signaling", "trans-synaptic signaling", "anterograde trans-synaptic signaling" ) ) ggSunburst(plotdata, end = pi / 2)plotdata <- data.frame( id = c("GO:0023052", "GO:0007267", "GO:0099536", "GO:0099537", "GO:0098916"), x = 0.5, y = seq.int(5), xmin = 0, ymin = c(0.5, 1.5, 2.5, 3.5, 4.5), xmax = 1, ymax = c(1.5, 2.5, 3.5, 4.5, 5.5), fill = seq(1, 5), label = c( "signaling", "cell-cell signaling", "synaptic signaling", "trans-synaptic signaling", "anterograde trans-synaptic signaling" ) ) ggSunburst(plotdata, end = pi / 2)
This function creates an igraph graph from one data frames containing the ancestor and offspring information.
goGraph(df)goGraph(df)
df |
A data frame, output of getAncestors |
A igraph graph.
goids <- c("GO:0099536", "GO:0099537", "GO:0007268", "GO:0098916", "GO:0050804") anc <- getAncestors(goids, onto = "BP") goGraph(anc)goids <- c("GO:0099536", "GO:0099537", "GO:0007268", "GO:0098916", "GO:0050804") anc <- getAncestors(goids, onto = "BP") goGraph(anc)
simplify graph by keeping only strongest parent, to make the DAG to a tree like graph
simplifyDAG(g, org)simplifyDAG(g, org)
g |
A igraph object |
org |
A Go3AnnDbBimap object |
Simplified graph
library(igraph) library(org.Dr.eg.db) edges <- data.frame( ancestor = c("GO:0007154", "GO:0007267", "GO:0099536", "GO:0099537"), offspring = c("GO:0099536", "GO:0099536", "GO:0099537", "GO:0098916") ) g <- graph_from_data_frame(edges) g1 <- simplifyDAG(g, org.Dr.eg.db)library(igraph) library(org.Dr.eg.db) edges <- data.frame( ancestor = c("GO:0007154", "GO:0007267", "GO:0099536", "GO:0099537"), offspring = c("GO:0099536", "GO:0099536", "GO:0099537", "GO:0098916") ) g <- graph_from_data_frame(edges) g1 <- simplifyDAG(g, org.Dr.eg.db)
Sunburst plot for enriched GO term
sunburstGO( df, org, g, termID = "ID", fill = "qvalue", sub_rect = NULL, GO_annotation_level_cutoff = 4, filterNodesByEdgeNumber = 2, mustkeep = c(), onlyKeep = c(), fillNAby0 = TRUE, onto = c("BP", "CC", "MF"), plotBy = c("plotly", "ggplot2"), ... )sunburstGO( df, org, g, termID = "ID", fill = "qvalue", sub_rect = NULL, GO_annotation_level_cutoff = 4, filterNodesByEdgeNumber = 2, mustkeep = c(), onlyKeep = c(), fillNAby0 = TRUE, onto = c("BP", "CC", "MF"), plotBy = c("plotly", "ggplot2"), ... )
df |
A data frame with enriched GO terms |
org |
An OrgDb object |
g |
An igraph graph. Output of getGraph. |
termID |
Column name in df which store the GO IDs |
fill |
Column name in df used to set the fill colors |
sub_rect |
Column name in df used to set the area of a proportional sub-rectangle, which represent a share of the whole. The values should be a number in the range from 0 to 1. If it is a count number, it will be convert to a proportion by divided the total number of features in the term. Otherwise, will simply re-scale to . |
GO_annotation_level_cutoff |
The cutoff of the GO annotation levels |
filterNodesByEdgeNumber |
Filter the sub graphs by the edge numbers. |
mustkeep |
The GO terms must be kept. |
onlyKeep |
Only keep branches with give GO terms. |
fillNAby0 |
Fill the NA values by 0 or not for the color column. |
onto |
The ontology category of the GO IDs |
plotBy |
plot tools, plotly or ggplot2. |
... |
parameter passed to ggSunburst. |
A plot handle
library(org.Dr.eg.db) df <- data.frame( ID = c("GO:0007267", "GO:0099536", "GO:0099537", "GO:0098916"), qvalue = -10 * log10(runif(4, max = 0.05)) ) sunburstGO(df, org.Dr.eg.db)library(org.Dr.eg.db) df <- data.frame( ID = c("GO:0007267", "GO:0099536", "GO:0099537", "GO:0098916"), qvalue = -10 * log10(runif(4, max = 0.05)) ) sunburstGO(df, org.Dr.eg.db)