Date: 2026-05-05

# Enrichment

Y-h. Taguchi1*

1Department of Physics, Chuo University, Tokyo 112-8551, Japan

*tag@granular.com

#### 5 May 2026

# Contents

    library(TDbasedUFE)
    library(TDbasedUFEadv)
    library(RTCGA.rnaseq)
    #> Loading required package: RTCGA
    #> Warning in fun(libname, pkgname): Package 'RTCGA' is deprecated and will be removed from Bioconductor
    #>   version 3.24
    library(RTCGA.clinical)

# 1 Introduction

It might be helpful to demonstrate how to evaluate selected genes by enrichment analysis. Here, we show some of useful tools applied to the output from TDbasedUFEadv In order foe this, we reproduce one example in “How to use TDbasedUFEadv” as follows.

    Multi <- list(
      BLCA.rnaseq[seq_len(100), 1 + seq_len(1000)],
      BRCA.rnaseq[seq_len(100), 1 + seq_len(1000)],
      CESC.rnaseq[seq_len(100), 1 + seq_len(1000)],
      COAD.rnaseq[seq_len(100), 1 + seq_len(1000)]
    )
    Z <- prepareTensorfromList(Multi, 10L)
    Z <- aperm(Z, c(2, 1, 3))
    Clinical <- list(BLCA.clinical, BRCA.clinical, CESC.clinical, COAD.clinical)
    Multi_sample <- list(
      BLCA.rnaseq[seq_len(100), 1, drop = FALSE],
      BRCA.rnaseq[seq_len(100), 1, drop = FALSE],
      CESC.rnaseq[seq_len(100), 1, drop = FALSE],
      COAD.rnaseq[seq_len(100), 1, drop = FALSE]
    )
    # patient.stage_event.tnm_categories.pathologic_categories.pathologic_m
    ID_column_of_Multi_sample <- c(770, 1482, 773, 791)
    # patient.bcr_patient_barcode
    ID_column_of_Clinical <- c(20, 20, 12, 14)
    Z <- PrepareSummarizedExperimentTensor(
      feature = colnames(ACC.rnaseq)[1 + seq_len(1000)],
      sample = array("", 1), value = Z,
      sampleData = prepareCondTCGA(
        Multi_sample, Clinical,
        ID_column_of_Multi_sample, ID_column_of_Clinical
      )
    )
    HOSVD <- computeHosvd(Z)
    #>
      |
      |                                                                      |   0%
      |
      |=======================                                               |  33%
      |
      |===============================================                       |  67%
      |
      |======================================================================| 100%
    cond <- attr(Z, "sampleData")
    index <- selectFeatureProj(HOSVD, Multi, cond, de = 1e-3, input_all = 3) # Batch mode

    head(tableFeatures(Z, index))
    #>       Feature       p value adjusted p value
    #> 10    ACTB|60  0.000000e+00     0.000000e+00
    #> 11   ACTG1|71  0.000000e+00     0.000000e+00
    #> 37  ALDOA|226  0.000000e+00     0.000000e+00
    #> 19 ADAM6|8755 5.698305e-299    1.424576e-296
    #> 22  AEBP1|165 1.057392e-218    2.114785e-216
    #> 9    ACTA2|59 7.862975e-198    1.310496e-195
    genes <- unlist(lapply(strsplit(tableFeatures(Z, index)[, 1], "|",
      fixed = TRUE
    ), "[", 1))
    entrez <- unlist(lapply(strsplit(tableFeatures(Z, index)[, 1], "|",
      fixed = TRUE
    ), "[", 2))

# 2 Enrichr

Enrichr(Kuleshov et al. 2016) is one of tools that often provides us significant results toward genes selected by TDbasedUFE and TDbasedUFEadv.

    if (!requireNamespace("enrichR", quietly = TRUE)) {
        stop("The enrichR package is required to run this example.")
    }

    enrichR::setEnrichrSite("Enrichr")

    dbs <- c(
        "GO_Molecular_Function_2015",
        "GO_Cellular_Component_2015",
        "GO_Biological_Process_2015"
    )

    enriched <- enrichR::enrichr(genes, dbs)

    enrichR::plotEnrich(
        enriched$GO_Biological_Process_2015,
        showTerms = 20,
        numChar = 40,
        y = "Count",
        orderBy = "P.value"
    )

Enrichr can provide you huge number of enrichment analyses, many of which have good compatibility with the genes selected by TDbasedUFE as well as TDbasedUFEadv by the experience. Please check Enrichr’s web site to see what kinds of enrichment analyses can be done.

# 3 STRING

STRING(Szklarczyk et al. 2018) is enrichment analyses based upon protein-protein interaction, which is known to provide often significant results toward genes selected by TDbasedUFE as well as TDbasedUFEadv.

    if (!requireNamespace("STRINGdb", quietly = TRUE)) {
        stop("The STRINGdb package is required to run this example.")
    }

    string_cache <- tools::R_user_dir("TDbasedUFEadv", which = "cache")
    dir.create(string_cache, recursive = TRUE, showWarnings = FALSE)

    string_db <- STRINGdb::STRINGdb$new(
        version = "11.5",
        species = 9606,
        score_threshold = 200,
        network_type = "full",
        input_directory = string_cache
    )

    example1_mapped <- string_db$map(
        data.frame(genes = genes),
        "genes",
        removeUnmappedRows = TRUE
    )

    hits <- example1_mapped$STRING_id
    string_db$plot_network(hits)

# 4 enrichplot

Although these above can provide us enough number of information to evaluate the genes selected by TDbasedUFE as well as TDbasedUFEadv, one might need all one package for which one does not how to decide which category must be evaluated in enrichment analysis.

In this case, we would recommend Metascape(Zhou et al. 2019) that unfortunately
does not have the ways approached from R. Thus, we recommend RITAN as an alternative. It can list significant ones among multiple categories.

    if (
        requireNamespace("DOSE", quietly = TRUE) &&
        requireNamespace("enrichplot", quietly = TRUE) &&
        requireNamespace("gson", quietly = TRUE) &&
        requireNamespace("ggplot2", quietly = TRUE)
    ) {
        edo <- DOSE::enrichDGN(entrez)

        enrichplot::dotplot(edo, showCategory = 30) +
            ggplot2::ggtitle("dotplot for ORA")
    } else {
        message(
            "Skipping DOSE/enrichplot example because one or more optional packages ",
            "are not installed: DOSE, enrichplot, gson, ggplot2."
        )
    }
    #>

    sessionInfo()
    #> R version 4.6.0 RC (2026-04-17 r89917)
    #> 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] stats     graphics  grDevices utils     datasets  methods   base
    #>
    #> other attached packages:
    #> [1] RTCGA.clinical_20151101.42.0 RTCGA.rnaseq_20151101.42.0
    #> [3] RTCGA_1.42.0                 TDbasedUFEadv_1.12.1
    #> [5] TDbasedUFE_1.12.0            BiocStyle_2.40.0
    #>
    #> loaded via a namespace (and not attached):
    #>   [1] rTensor_1.4.9           splines_4.6.0           later_1.4.8
    #>   [4] bitops_1.0-9            ggplotify_0.1.3         tibble_3.3.1
    #>   [7] polyclip_1.10-7         enrichit_0.1.4          XML_3.99-0.23
    #>  [10] lifecycle_1.0.5         rstatix_0.7.3           processx_3.9.0
    #>  [13] lattice_0.22-9          MASS_7.3-65             backports_1.5.1
    #>  [16] magrittr_2.0.5          sass_0.4.10             rmarkdown_2.31
    #>  [19] jquerylib_0.1.4         yaml_2.3.12             httpuv_1.6.17
    #>  [22] otel_0.2.0              ggtangle_0.1.2          chromote_0.5.1
    #>  [25] DBI_1.3.0               RColorBrewer_1.1-3      abind_1.4-8
    #>  [28] MOFAdata_1.28.0         rvest_1.0.5             GenomicRanges_1.64.0
    #>  [31] purrr_1.2.2             BiocGenerics_0.58.0     RCurl_1.98-1.18
    #>  [34] hash_2.2.6.4            yulab.utils_0.2.4       tweenr_2.0.3
    #>  [37] rappdirs_0.3.4          gdtools_0.5.0           IRanges_2.46.0
    #>  [40] S4Vectors_0.50.0        enrichplot_1.32.0       ggrepel_0.9.8
    #>  [43] tidytree_0.4.7          DOSE_4.6.0              xml2_1.5.2
    #>  [46] ggforce_0.5.0           tximportData_1.40.0     tidyselect_1.2.1
    #>  [49] aplot_0.2.9             farver_2.1.2            viridis_0.6.5
    #>  [52] stats4_4.6.0            Seqinfo_1.2.0           jsonlite_2.0.0
    #>  [55] Formula_1.2-5           survival_3.8-6          systemfonts_1.3.2
    #>  [58] tools_4.6.0             ggnewscale_0.5.2        treeio_1.36.1
    #>  [61] Rcpp_1.1.1-1.1          glue_1.8.1              gridExtra_2.3
    #>  [64] xfun_0.57               qvalue_2.44.0           ggthemes_5.2.0
    #>  [67] websocket_1.4.4         dplyr_1.2.1             withr_3.0.2
    #>  [70] BiocManager_1.30.27     fastmap_1.2.0           digest_0.6.39
    #>  [73] R6_2.6.1                mime_0.13               gridGraphics_0.5-1
    #>  [76] GO.db_3.23.1            dichromat_2.0-0.1       RSQLite_2.4.6
    #>  [79] tidyr_1.3.2             generics_0.1.4          fontLiberation_0.1.0
    #>  [82] data.table_1.18.2.1     httr_1.4.8              htmlwidgets_1.6.4
    #>  [85] scatterpie_0.2.6        pkgconfig_2.0.3         gtable_0.3.6
    #>  [88] blob_1.3.0              S7_0.2.2                XVector_0.52.0
    #>  [91] htmltools_0.5.9         fontBitstreamVera_0.1.1 carData_3.0-6
    #>  [94] bookdown_0.46           scales_1.4.0            Biobase_2.72.0
    #>  [97] png_0.1-9               ggfun_0.2.0             knitr_1.51
    #> [100] tzdb_0.5.0              reshape2_1.4.5          nlme_3.1-169
    #> [103] cachem_1.1.0            stringr_1.6.0           parallel_4.6.0
    #> [106] AnnotationDbi_1.74.0    pillar_1.11.1           grid_4.6.0
    #> [109] vctrs_0.7.3             promises_1.5.0          ggpubr_0.6.3
    #> [112] car_3.1-5               tidydr_0.0.6            xtable_1.8-8
    #> [115] cluster_2.1.8.2         tximport_1.40.0         evaluate_1.0.5
    #> [118] readr_2.2.0             cli_3.6.6               compiler_4.6.0
    #> [121] rlang_1.2.0             crayon_1.5.3            ggsignif_0.6.4
    #> [124] labeling_0.4.3          survminer_0.5.2         ps_1.9.3
    #> [127] plyr_1.8.9              fs_2.1.0                ggiraph_0.9.6
    #> [130] stringi_1.8.7           viridisLite_0.4.3       assertthat_0.2.1
    #> [133] Biostrings_2.80.0       lazyeval_0.2.3          GOSemSim_2.38.0
    #> [136] fontquiver_0.2.1        Matrix_1.7-5            hms_1.1.4
    #> [139] patchwork_1.3.2         bit64_4.8.0             ggplot2_4.0.3
    #> [142] KEGGREST_1.52.0         shiny_1.13.0            igraph_2.3.1
    #> [145] broom_1.0.12            memoise_2.0.1           bslib_0.10.0
    #> [148] ggtree_4.2.0            bit_4.6.0               ape_5.8-1
    #> [151] gson_0.1.0

Kuleshov, Maxim V., Matthew R. Jones, Andrew D. Rouillard, Nicolas F. Fernandez, Qiaonan Duan, Zichen Wang, Simon Koplev, et al. 2016. “Enrichr: a comprehensive gene set enrichment analysis web server 2016 update.” Nucleic Acids Research 44 (W1): W90–W97. https://doi.org/10.1093/nar/gkw377.

Szklarczyk, Damian, Annika L Gable, David Lyon, Alexander Junge, Stefan Wyder, Jaime Huerta-Cepas, Milan Simonovic, et al. 2018. “STRING v11: protein窶菟rotein association networks with increased coverage, supporting functional discovery in genome-wide experimental datasets.” Nucleic Acids Research 47 (D1): D607–D613. https://doi.org/10.1093/nar/gky1131.

Zhou, Yingyao, Bin Zhou, Lars Pache, Max Chang, Alireza Hadj Khodabakhshi, Olga Tanaseichuk, Christopher Benner, and Sumit K Chanda. 2019. “Metascape provides a biologist-oriented resource for the analysis of systems-level datasets.” Nature Communications 10 (1): 1523. https://doi.org/10.1038/s41467-019-09234-6.