Introduction

Gene Ontology (GO) enrichment analysis is an essential approach for interpreting large-scale omics data. However, visualizing GO results in an informative and intuitive way remains challenging. Because GO terms form a directed acyclic graph (DAG) rather than a simple hierarchy, direct graph-based plots often appear cluttered and difficult to interpret. Meanwhile, common alternatives such as heatmaps or dot plots simplify the presentation but lose the hierarchical relationships among GO terms.

GOfan was developed to simplify GO enrichment visualization while preserving the structural context of the ontology. Inspired by the SynGO visualization, GOfan represents GO terms in a sunburst layout, where each ring corresponds to a hierarchy level and each segment represents a GO term. This radial organization enables users to focus on one or more biological categories and intuitively explore how enriched terms are connected.

Any enrichment result containing GO identifiers can be visualized by GOfan as sunburst plot. Users can map additional information such as p-values or gene counts to colors, highlighting significant biological patterns in a compact and publication-ready figure. Future versions will further enhance the visualization by incorporating additional visual cues such as size or shape.

By translating the complex GO DAG into a clean, circular representation, GOfan helps researchers quickly grasp the biological meaning of enrichment results through a clear and accessible visualization.

Installation

if (!require("BiocManager", quietly = TRUE)) {
    install.packages("BiocManager")
}

BiocManager::install("jianhong/GOfan")

Quick start

There are four main steps to visualize your data with GOfan:

Step 1. Load the required library.

Step 2. Prepare the input data frame.

Step 3. Create a graph representing the hierarchical relationships among GO terms.

Step 4. Generate the sunburst plot.

library(ggplot2)
library(GOfan)
library(org.Dr.eg.db)
## load data
csv <- system.file("extdata", "GO.BP.enrichment.csv", package = "GOfan")
bp <- read.csv(csv, row.names = 1)
head(bp, n = 2)
##                    ID     p.adjust   qvalue count
## GO:0099536 GO:0099536 1.505326e-70 69.91192   134
## GO:0099537 GO:0099537 1.242713e-69 68.99518   131
## build a graph of hierarchical GO term relationships.
g <- getGraph(bp, org = org.Dr.eg.db, onto = "BP")
## visualization
sunburstGO(bp, g,
    org = org.Dr.eg.db, fill = "qvalue",
    filterNodesByEdgeNumber = 0,
    plotBy = "plotly"
)

In the example above, we used the plotly package to visualize the results. One advantage of plotly is its interactivity. You can view all labels by hovering the mouse over each small cell, and clicking on a cell zooms into that GO term along with its offspring.

However, plotly has some limitations when do sunburst plot: legends are not available, and plots can only be saved as PNG files.

To address these issues, you can use ggplot2 for visualization. With ggplot2, plots can be saved in multiple formats (see ?ggsave), including vector graphics, and you have greater flexibility in color customization (see ?scale_fill_continuous. In addition, by using the onlyKeep parameter, you can focus on a specific subset of GO terms.

sunburstGO(bp, g,
    org = org.Dr.eg.db, fill = "qvalue",
    onlyKeep = c("GO:0099536", "GO:0046903", "GO:0034330"),
    plotBy = "ggplot2"
) +
    scale_fill_continuous(palette = "YlOrRd")

Moreover, you can customize the start and end positions of the polar plot to create a fan-shaped visualization.

sunburstGO(bp, g,
    org = org.Dr.eg.db,
    fill = "qvalue", sub_rect = "count",
    onlyKeep = c("GO:0099536"),
    plotBy = "ggplot2",
    fontsize = 2,
    start = 0, end = pi / 2
) +
    scale_fill_continuous(palette = "YlOrRd")

You can also incorporate a second factor into the plot. For example, the q-value can be shown by color, while the gene ratio for each category can be represented by the area proportion of the cell’s foreground to background color.

SessionInfo

## R Under development (unstable) (2026-03-05 r89546)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 24.04.4 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.23-bioc/R/lib/libRblas.so 
## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0  LAPACK version 3.12.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## time zone: America/New_York
## tzcode source: system (glibc)
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
## [1] org.Dr.eg.db_3.22.0  AnnotationDbi_1.73.0 IRanges_2.45.0      
## [4] S4Vectors_0.49.0     Biobase_2.71.0       BiocGenerics_0.57.0 
## [7] generics_0.1.4       GOfan_0.99.2         ggplot2_4.0.2       
## 
## loaded via a namespace (and not attached):
##  [1] KEGGREST_1.51.1     gtable_0.3.6        xfun_0.56          
##  [4] bslib_0.10.0        htmlwidgets_1.6.4   vctrs_0.7.1        
##  [7] tools_4.6.0         tibble_3.3.1        RSQLite_2.4.6      
## [10] blob_1.3.0          pkgconfig_2.0.3     data.table_1.18.2.1
## [13] RColorBrewer_1.1-3  S7_0.2.1            lifecycle_1.0.5    
## [16] compiler_4.6.0      farver_2.1.2        Biostrings_2.79.5  
## [19] BiocStyle_2.39.0    Seqinfo_1.1.0       htmltools_0.5.9    
## [22] sass_0.4.10         yaml_2.3.12         lazyeval_0.2.2     
## [25] plotly_4.12.0       pillar_1.11.1       crayon_1.5.3       
## [28] jquerylib_0.1.4     GO.db_3.22.0        tidyr_1.3.2        
## [31] cachem_1.1.0        tidyselect_1.2.1    digest_0.6.39      
## [34] dplyr_1.2.0         purrr_1.2.1         labeling_0.4.3     
## [37] fastmap_1.2.0       grid_4.6.0          cli_3.6.5          
## [40] magrittr_2.0.4      dichromat_2.0-0.1   withr_3.0.2        
## [43] scales_1.4.0        bit64_4.6.0-1       rmarkdown_2.30     
## [46] XVector_0.51.0      httr_1.4.8          igraph_2.2.2       
## [49] bit_4.6.0           otel_0.2.0          png_0.1-8          
## [52] memoise_2.0.1       evaluate_1.0.5      knitr_1.51         
## [55] viridisLite_0.4.3   rlang_1.1.7         glue_1.8.0         
## [58] DBI_1.3.0           BiocManager_1.30.27 jsonlite_2.0.0     
## [61] R6_2.6.1