Contents

1 Introduction

scToppR is a package that allows seamless, workflow-based interaction with ToppGene, a portal for gene enrichment analysis. Researchers can use scToppR to directly query ToppGene’s databases and conduct analysis with a few lines of code. scToppR’s availability on Bioconductor ensures easy installation and integration with other Bioconductor workflows, allowing researchers to easily incorporate functional enrichment analysis from ToppGene into their existing pipelines.

The use of data from ToppGene is governed by their Terms of Use: https://toppgene.cchmc.org/navigation/termsofuse.jsp

2 Installation

if (!requireNamespace("BiocManager", quietly = TRUE)) {
    install.packages("BiocManager")
}
BiocManager::install("scToppR")

3 Load Data

This vignette shows the use of scToppR within a differential expression workflow using data from a Seurat object. Using the IFNB (Kang 2018) dataset included in the SeuratData package, one can find differentially expressed genes between the “CTRL” and “STIM” groups using Seurat’s FindMarkers function. The raw results from this analysis are included as a dataset in scToppR, which can be accessed as such:

library(scToppR)
library(dplyr)
data("ifnb.de")
head(ifnb.de)
##   p_val avg_log2FC pct.1 pct.2 p_val_adj  celltype    gene
## 1     0   7.319139 0.985 0.033         0 CD14 Mono   IFIT1
## 2     0   8.036564 0.984 0.035         0 CD14 Mono  CXCL10
## 3     0   6.741673 0.988 0.045         0 CD14 Mono   RSAD2
## 4     0   6.991279 0.989 0.047         0 CD14 Mono TNFSF10
## 5     0   6.883785 0.992 0.056         0 CD14 Mono   IFIT3
## 6     0   7.179929 0.961 0.039         0 CD14 Mono   IFIT2

As this is the raw data, we will begin by quickly filtering for significant results, using thresholds of 0.05 for the adjusted p value and 0.3 as the average log fold change.

ifnb.de.filtered <- ifnb.de |>
    dplyr::filter(p_val_adj < 0.05, abs(avg_log2FC) > 0.3)

4 Running scToppR with Differential Expression Results

With these results, we will use scToppR to querry the ToppGene database for all categories for each cluster using the toppFun() function. This function requires users to specify the columns in their dataset.

# This is how you would run the analysis with live data (requires internet)
if (curl::has_internet()) {
    toppdata.ifnb <- toppFun(input_data = ifnb.de.filtered,
        type = "degs",
        gene_col = "gene",
        cluster_col = "celltype",
        p_val_col = "p_val_adj",
        logFC_col = "avg_log2FC"
    )
} else {
    data("toppdata.ifnb")
}
head(toppdata.ifnb)
##                        Category         ID
## 1 GeneOntologyMolecularFunction GO:0005126
## 2 GeneOntologyMolecularFunction GO:0005525
## 3 GeneOntologyMolecularFunction GO:0019001
## 4 GeneOntologyMolecularFunction GO:0032561
## 5 GeneOntologyMolecularFunction GO:0042379
## 6 GeneOntologyMolecularFunction GO:0016772
##                                                              Name       PValue
## 1                                       cytokine receptor binding 4.957657e-09
## 2                                                     GTP binding 7.646367e-08
## 3                                       guanyl nucleotide binding 1.383398e-07
## 4                                   guanyl ribonucleotide binding 1.383398e-07
## 5                                      chemokine receptor binding 2.075443e-07
## 6 transferase activity, transferring phosphorus-containing groups 4.295681e-07
##    QValueFDRBH  QValueFDRBY QValueBonferroni TotalGenes GenesInTerm
## 1 8.388356e-06 6.720061e-05     8.388356e-06      19978         327
## 2 5.851773e-05 4.687959e-04     1.293765e-04      19978         623
## 3 5.851773e-05 4.687959e-04     2.340709e-04      19978         663
## 4 5.851773e-05 4.687959e-04     2.340709e-04      19978         663
## 5 7.023300e-05 5.626491e-04     3.511650e-04      19978          81
## 6 1.211382e-04 9.704597e-04     7.268292e-04      19978        1222
##   GenesInQuery GenesInTermInQuery Source URL
## 1          951                 42           
## 2          951                 61           
## 3          951                 63           
## 4          951                 63           
## 5          951                 17           
## 6          951                 97           
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Genes
## 1                                                                                                                                                                                                                                                                                                                                                                                                         CCR2, CXCL9, CCL2, CCL3, CCL4, CCL7, CCL8, CXCL11, CXCL5, YARS1, TNFSF13B, SOCS1, TRADD, TNFSF14, TNFSF10, NARS1, CFLAR, TNFSF18, CXCL1, CXCL3, TGFBR1, TGFBR2, OSM, TNFSF8, IL27, CD2AP, TYK2, PDCL3, VEGFA, IL1B, IL1RN, IL6, CXCL8, IL15, CXCL10, STAP1, JAK2, DEFB1, SPRED1, LYN, ENG, CKLF
## 2                                                                                                                                                                                                                                                                GIMAP4, RIN3, DOCK5, ADSS2, AK4, PREX1, FGD2, RTCB, NOA1, ITSN1, CGAS, MFN1, ARL3, RANGRF, MX1, MX2, HCAR2, TAGAP, SEPTIN9, GBP1, GBP3, SRPRA, GCH1, HCAR3, RGL1, GBP4, GBP5, EHD1, GNA15, GNL1, GUCY1A1, GUCY1B1, ZNG1B, GTPBP4, RIGI, ARL11, TUBA4A, EFTUD2, RASGRP3, RIN2, HRAS, GIMAP6, VAV1, SH3BP5, SEPTIN4, IRGQ, GTPBP1, RAB39A, ARHGEF3, RAPGEF2, GAPVD1, GBP7, DENND1B, ZNG1E, RAB4A, DENND11, PREB, ARL5B, RAB34, FARP1, RPGR
## 3                                                                                                                                                                                                                                               GIMAP4, RIN3, DOCK5, ADSS2, AK4, PREX1, FGD2, RTCB, NOA1, ITSN1, CGAS, MFN1, ARHGDIB, ARL3, RANGRF, MX1, MX2, HCAR2, TAGAP, SEPTIN9, GBP1, GBP3, SRPRA, GCH1, HCAR3, RGL1, GBP4, GBP5, EHD1, GNA15, GNL1, GUCY1A1, GUCY1B1, ZNG1B, GTPBP4, RIGI, ARL11, TUBA4A, EFTUD2, RASGRP3, RIN2, HRAS, GIMAP6, VAV1, SH3BP5, SEPTIN4, IRGQ, GTPBP1, RAB39A, ARHGEF3, RAPGEF2, GAPVD1, GBP7, DENND1B, ZNG1E, RAB4A, RANBP1, DENND11, PREB, ARL5B, RAB34, FARP1, RPGR
## 4                                                                                                                                                                                                                                               GIMAP4, RIN3, DOCK5, ADSS2, AK4, PREX1, FGD2, RTCB, NOA1, ITSN1, CGAS, MFN1, ARHGDIB, ARL3, RANGRF, MX1, MX2, HCAR2, TAGAP, SEPTIN9, GBP1, GBP3, SRPRA, GCH1, HCAR3, RGL1, GBP4, GBP5, EHD1, GNA15, GNL1, GUCY1A1, GUCY1B1, ZNG1B, GTPBP4, RIGI, ARL11, TUBA4A, EFTUD2, RASGRP3, RIN2, HRAS, GIMAP6, VAV1, SH3BP5, SEPTIN4, IRGQ, GTPBP1, RAB39A, ARHGEF3, RAPGEF2, GAPVD1, GBP7, DENND1B, ZNG1E, RAB4A, RANBP1, DENND11, PREB, ARL5B, RAB34, FARP1, RPGR
## 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        CCR2, CXCL9, CCL2, CCL3, CCL4, CCL7, CCL8, CXCL11, CXCL5, YARS1, NARS1, CXCL1, CXCL3, CXCL8, CXCL10, DEFB1, CKLF
## 6 PI4K2B, RPS6KA1, NT5C3A, RPS6KB2, PI4K2A, ADK, MET, CCL2, CCL3, AK4, CCL8, MERTK, STK24, PREX1, NAGK, BMP2K, TENT5A, ITSN1, RGCC, CGAS, HIPK2, CAMK1, STK32C, SEPHS2, OASL, NT5C2, SOCS1, POLD4, STK38L, MAP3K2, NEK6, AXL, CDS2, RIPK2, MAP3K20, CMPK2, NBN, CCNY, NRP1, BLVRA, MLKL, CCNA1, CALM1, TENT4A, GRK6, OAS1, OAS2, OAS3, TGFBR1, TGFBR2, PARP10, NUDT5, P2RX7, MASTL, NCKAP1L, PDGFRL, MAPKAPK2, CKB, TYK2, PNPT1, PLK3, HSPB1, PARP12, SH3BP5, VEGFA, PMP22, CERK, WARS1, POLR2B, POLR1C, BCCIP, CCNJ, PARP14, MOB3A, CSF1R, IKBKE, SELENOI, MAPK13, EIF2AK2, RASSF2, CXCL10, PTDSS1, PXK, STAP1, JAK2, SELENOO, NADK, PARP9, PARP11, HBEGF, DTYMK, LGALS9, SPRED1, TNK2, LYN, TRIB1, FGGY
##     Cluster
## 1 CD14 Mono
## 2 CD14 Mono
## 3 CD14 Mono
## 4 CD14 Mono
## 5 CD14 Mono
## 6 CD14 Mono

As the code reminds you, the use of this data must be done so in accordance with ToppGene’s Terms of Use. For more information, please visit: https://toppgene.cchmc.org/navigation/termsofuse.jsp

5 Visualizing ToppGene Results

The toppData dataframe (whether from live API call or cached data) includes all results from ToppGene. We can use this dataframe to quickly generate pathway analysis plots using the toppPlot() function. The function can be used to generate a single plot, for example:

toppPlot(toppdata.ifnb,
    category = "GeneOntologyMolecularFunction",
    clusters = "CD8 T"
)

The toppPlot() function can also create a plot for each cluster for a specified category; simply assign the parameter clusters to NULL. In this case, the function will return a list of plots.

plot_list <- toppPlot(toppdata.ifnb,
    category = "GeneOntologyMolecularFunction",
    clusters = NULL
)
plot_list[1]
## $`CD14 Mono`

All of these plots can also be automatically saved by the toppPlot() function. The files and their save locations can be set using the parameters: -save = TRUE -save_dir=“/path/to/save_directory” -file_name_prefix=“GO_Molecular_Function”

The cluster/celltype name will be automatically added to the filename prior to saving.

plot_list <- toppPlot(toppdata.ifnb,
    category = "GeneOntologyMolecularFunction",
    clusters = NULL,
    save = TRUE,
    save_dir = tempdir(),
    file_prefix = "GO_molecular_function"
)

scToppR also uses the toppBalloon() function to create a balloon plot, allowing researchers to quickly compare the top terms from the ToppGene results.

toppBalloon(toppdata.ifnb,
    categories = "GeneOntologyBiologicalProcess"
)

Some advantages of using scToppR in a pipeline include access to the other categories in ToppGene. Users can quickly view results from all ToppGene categories using these plotting function, or by examining the toppData results. For example, a user could explore any common results among celltypes in terms such as Pathway, ToppCell, and TFBS.

For example, a quick look at the toppBalloon plot for Pathway shows a distinction with the Dendritic Cells compared to others:

toppBalloon(toppdata.ifnb,
    categories = "Pathway"
)

The Pubmed category also provides researchers with other papers exploring similar data:

toppBalloon(toppdata.ifnb,
    categories = "Pubmed"
)

6 Saving ToppGene Results

To save toppData results, scToppR also includes a toppSave() function. This function can save the toppData results as a single file, or it can split the data into different clusters/celltypes and save each individually. To do so, set save = TRUE in the function call. The function saves the files as Excel spreadsheets by default, but this can be changed to .csv or .tsv files using the format parameter.

toppSave(toppdata.ifnb,
    filename = "IFNB_toppData",
    save_dir = tempdir(),
    split = TRUE,
    format = "xlsx"
)
sessionInfo()
## R version 4.6.0 alpha (2026-04-05 r89794)
## 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] dplyr_1.2.1                 DESeq2_1.51.7              
##  [3] airway_1.31.0               SummarizedExperiment_1.41.1
##  [5] Biobase_2.71.0              GenomicRanges_1.63.2       
##  [7] Seqinfo_1.1.0               IRanges_2.45.0             
##  [9] S4Vectors_0.49.2            BiocGenerics_0.57.1        
## [11] generics_0.1.4              MatrixGenerics_1.23.0      
## [13] matrixStats_1.5.0           scToppR_0.99.10            
## [15] knitr_1.51                  BiocStyle_2.39.0           
## 
## loaded via a namespace (and not attached):
##  [1] gtable_0.3.6        xfun_0.57           bslib_0.10.0       
##  [4] ggplot2_4.0.2       httr2_1.2.2         lattice_0.22-9     
##  [7] vctrs_0.7.3         tools_4.6.0         curl_7.0.0         
## [10] parallel_4.6.0      tibble_3.3.1        pkgconfig_2.0.3    
## [13] Matrix_1.7-5        RColorBrewer_1.1-3  S7_0.2.1-1         
## [16] lifecycle_1.0.5     compiler_4.6.0      farver_2.1.2       
## [19] stringr_1.6.0       textshaping_1.0.5   tinytex_0.59       
## [22] codetools_0.2-20    htmltools_0.5.9     sass_0.4.10        
## [25] yaml_2.3.12         pillar_1.11.1       jquerylib_0.1.4    
## [28] BiocParallel_1.45.0 cachem_1.1.0        DelayedArray_0.37.1
## [31] magick_2.9.1        viridis_0.6.5       abind_1.4-8        
## [34] tidyselect_1.2.1    locfit_1.5-9.12     zip_2.3.3          
## [37] digest_0.6.39       stringi_1.8.7       bookdown_0.46      
## [40] labeling_0.4.3      forcats_1.0.1       fastmap_1.2.0      
## [43] grid_4.6.0          cli_3.6.6           SparseArray_1.11.13
## [46] magrittr_2.0.5      patchwork_1.3.2     S4Arrays_1.11.1    
## [49] dichromat_2.0-0.1   withr_3.0.2         scales_1.4.0       
## [52] rappdirs_0.3.4      rmarkdown_2.31      XVector_0.51.0     
## [55] otel_0.2.0          gridExtra_2.3       ragg_1.5.2         
## [58] openxlsx_4.2.8.1    evaluate_1.0.5      viridisLite_0.4.3  
## [61] rlang_1.2.0         Rcpp_1.1.1-1        glue_1.8.1         
## [64] BiocManager_1.30.27 jsonlite_2.0.0      R6_2.6.1           
## [67] systemfonts_1.3.2