Last updated: 2025-11-27

Checks: 7 0

Knit directory: 5_gd_Tcell/1_analysis/

This reproducible R Markdown analysis was created with workflowr (version 1.7.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(12345) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version b9f184a. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Untracked files:
    Untracked:  .DS_Store
    Untracked:  figure/scatter2-1.png
    Untracked:  figure/scatter3-1.png
    Untracked:  figure/scatter4-1.png
    Untracked:  figure/scatter5-1.png
    Untracked:  figure/scatter_3d4-1.png
    Untracked:  figure/scatter_interactive4-1.png
    Untracked:  figure/treemap2-1.png
    Untracked:  figure/treemap3-1.png
    Untracked:  figure/treemap4-1.png
    Untracked:  figure/treemap5-1.png

Unstaged changes:
    Modified:   0_data/RDS_plots/go_combined_dotPlot.rds
    Modified:   0_data/RDS_plots/go_combined_parTerm_dotPlot.rds
    Modified:   0_data/RDS_plots/go_dotPlot.rds
    Modified:   0_data/RDS_plots/go_parTerm_dotPlot.rds
    Modified:   0_data/RDS_plots/go_parTerm_scatter.rds
    Modified:   0_data/RDS_plots/kegg_dotPlot.rds
    Modified:   0_data/RDS_plots/kegg_path_Hmap.rds
    Modified:   0_data/RDS_plots/ma_plots.rds
    Modified:   0_data/RDS_plots/react_combined_dotPlot.rds
    Modified:   0_data/RDS_plots/react_dotPlot.rds
    Modified:   0_data/RDS_plots/vol_plots.rds
    Modified:   2_plots/1_QC/PC1_PC2.svg
    Modified:   2_plots/1_QC/PC1_PC3.svg
    Modified:   2_plots/1_QC/PC2_PC3.svg
    Modified:   2_plots/2_DE/heat_down_INT vs CONT.svg
    Modified:   2_plots/2_DE/heat_down_INT vs SVX_VAS.svg
    Modified:   2_plots/2_DE/heat_down_INT vs VAS.svg
    Modified:   2_plots/2_DE/heat_down_SVX vs SVX_VAS.svg
    Modified:   2_plots/2_DE/heat_down_SVX_VAS vs CONT.svg
    Modified:   2_plots/2_DE/heat_down_VAS vs SVX_VAS.svg
    Modified:   2_plots/2_DE/heat_up_INT vs CONT.svg
    Modified:   2_plots/2_DE/heat_up_INT vs SVX_VAS.svg
    Modified:   2_plots/2_DE/heat_up_INT vs VAS.svg
    Modified:   2_plots/2_DE/heat_up_SVX vs SVX_VAS.svg
    Modified:   2_plots/2_DE/heat_up_SVX_VAS vs CONT.svg
    Modified:   2_plots/2_DE/heat_up_VAS vs SVX_VAS.svg
    Modified:   2_plots/2_DE/hist_INT vs CONT.svg
    Modified:   2_plots/2_DE/hist_INT vs SVX_VAS.svg
    Modified:   2_plots/2_DE/hist_INT vs VAS.svg
    Modified:   2_plots/2_DE/hist_SVX vs SVX_VAS.svg
    Modified:   2_plots/2_DE/hist_SVX_VAS vs CONT.svg
    Modified:   2_plots/2_DE/hist_VAS vs SVX_VAS.svg
    Modified:   2_plots/3_FA/go/combine_go_dot.svg
    Modified:   2_plots/3_FA/go/parTerm_dot_INT vs CONT.svg
    Modified:   2_plots/3_FA/go/parTerm_dot_INT vs SVX_VAS.svg
    Modified:   2_plots/3_FA/go/parTerm_dot_SVX vs SVX_VAS.svg
    Modified:   2_plots/3_FA/go/parTerm_dot_SVX_VAS vs CONT.svg
    Modified:   2_plots/3_FA/go/parTerm_dot_VAS vs SVX_VAS.svg
    Modified:   2_plots/3_FA/go/semSim_dendrogram_INT vs CONT.svg
    Modified:   2_plots/3_FA/go/semSim_dendrogram_INT vs SVX_VAS.svg
    Modified:   2_plots/3_FA/go/semSim_dendrogram_SVX vs SVX_VAS.svg
    Modified:   2_plots/3_FA/go/semSim_dendrogram_SVX_VAS vs CONT.svg
    Modified:   2_plots/3_FA/go/semSim_dendrogram_VAS vs SVX_VAS.svg
    Modified:   2_plots/3_FA/go/semSim_scatter_INT vs CONT.svg
    Modified:   2_plots/3_FA/go/semSim_scatter_INT vs SVX_VAS.svg
    Modified:   2_plots/3_FA/go/semSim_scatter_SVX vs SVX_VAS.svg
    Modified:   2_plots/3_FA/go/semSim_scatter_SVX_VAS vs CONT.svg
    Modified:   2_plots/3_FA/kegg/combine_kegg_dot.svg
    Modified:   2_plots/3_FA/kegg/heat_Neutrophil extracellular trap formation.svg
    Modified:   2_plots/3_FA/kegg/heat_PD-L1 expression and PD-1 checkpoint pathway in cancer.svg
    Modified:   2_plots/3_FA/kegg/heat_T cell receptor signaling pathway.svg
    Modified:   2_plots/3_FA/kegg/heat_Th1 and Th2 cell differentiation.svg
    Modified:   2_plots/3_FA/kegg/heat_Th17 cell differentiation.svg
    Modified:   2_plots/3_FA/kegg/kegg_dot_INT vs CONT.svg
    Modified:   2_plots/3_FA/kegg/kegg_dot_INT vs SVX_VAS.svg
    Modified:   2_plots/3_FA/kegg/kegg_dot_SVX_VAS vs CONT.svg
    Modified:   2_plots/3_FA/kegg/kegg_dot_VAS vs SVX_VAS.svg
    Modified:   2_plots/3_FA/kegg/kegg_upset_INT vs CONT.svg
    Modified:   2_plots/3_FA/kegg/kegg_upset_INT vs SVX_VAS.svg
    Modified:   2_plots/3_FA/kegg/kegg_upset_SVX_VAS vs CONT.svg
    Modified:   2_plots/3_FA/kegg/kegg_upset_VAS vs SVX_VAS.svg
    Modified:   2_plots/3_FA/reactome/combine_react_dot.svg
    Modified:   2_plots/3_FA/reactome/react_dot_INT vs CONT.svg
    Modified:   2_plots/3_FA/reactome/react_dot_INT vs SVX_VAS.svg
    Modified:   2_plots/3_FA/reactome/react_dot_INT vs VAS.svg
    Modified:   2_plots/3_FA/reactome/react_dot_SVX vs SVX_VAS.svg
    Modified:   2_plots/3_FA/reactome/react_dot_SVX_VAS vs CONT.svg
    Modified:   2_plots/3_FA/reactome/react_dot_VAS vs SVX_VAS.svg
    Modified:   2_plots/3_FA/reactome/react_upset_INT vs CONT.svg
    Modified:   2_plots/3_FA/reactome/react_upset_INT vs SVX_VAS.svg
    Modified:   2_plots/3_FA/reactome/react_upset_INT vs VAS.svg
    Modified:   2_plots/3_FA/reactome/react_upset_SVX vs SVX_VAS.svg
    Modified:   2_plots/3_FA/reactome/react_upset_SVX_VAS vs CONT.svg
    Modified:   2_plots/3_FA/reactome/react_upset_VAS vs SVX_VAS.svg
    Modified:   2_plots/4_paper/subset_degs.svg
    Modified:   2_plots/combine_ipa_dot.svg
    Modified:   2_plots/dnf_plot.svg
    Modified:   2_plots/intVsvxVAS.svg
    Modified:   2_plots/upstream_hmap.svg
    Modified:   3_output/DEGs.xlsx
    Modified:   3_output/Gene Ontology.xlsx
    Modified:   3_output/KEGG.xlsx
    Modified:   3_output/Reactome.xlsx
    Modified:   3_output/deg_all_new.xlsx
    Modified:   3_output/deg_sig_new.xlsx
    Modified:   3_output/eigenvalues.xlsx
    Modified:   3_output/enrichKEGG_sig.xlsx
    Modified:   3_output/reactome_all_new.xlsx
    Modified:   3_output/reactome_sig_new.xlsx
    Modified:   3_output/semSim_GO_sig.xlsx
    Modified:   README.html
    Modified:   README.md
    Modified:   figure/dot2-1.png
    Modified:   figure/dot3-1.png
    Modified:   figure/dot4-1.png
    Modified:   figure/dot5-1.png
    Modified:   figure/upset2-1.png
    Modified:   figure/upset3-1.png
    Modified:   figure/upset4-1.png
    Modified:   figure/upset5-1.png

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (1_analysis/go.Rmd) and HTML (docs/go.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd b9f184a Ha Tran 2025-11-27 wflow_publish(here::here("1_analysis/*.Rmd"))
html d519e7f Ha Tran 2024-12-03 Build site.
Rmd 9fc0156 Ha Tran 2024-12-03 workflowr::wflow_publish(here::here("1_analysis/*.Rmd"))
html 5dce909 Ha Tran 2024-11-07 Build site.
html d71eeb4 Ha Tran 2024-10-16 Build site.
Rmd 5f0c7a1 Ha Tran 2024-10-16 workflowr::wflow_publish(here::here("1_analysis/*.Rmd"))
html ae93fcc tranmanhha135 2024-02-02 Build site.
Rmd fbcdd69 tranmanhha135 2024-02-02 workflowr::wflow_publish(here::here("1_analysis/*.Rmd"))
html 2c24612 tranmanhha135 2022-10-13 build website
Rmd 324032b tranmanhha135 2022-10-11 resize images
html 11a5cf4 tranmanhha135 2022-10-03 build wedsite
Rmd 1101367 tranmanhha135 2022-10-02 Completed functional enrichment for all comparison
html 1101367 tranmanhha135 2022-10-02 Completed functional enrichment for all comparison
html 68585df tranmanhha135 2022-09-20 build webste
Rmd 192d010 tranmanhha135 2022-09-20 functional enrichment with new dataset
html 192d010 tranmanhha135 2022-09-20 functional enrichment with new dataset
Rmd 0df047f tranmanhha135 2022-09-08 minor changes to build and publish
html 0df047f tranmanhha135 2022-09-08 minor changes to build and publish
html 54e0166 Ha Manh Tran 2022-01-01 Build site.
html 32454d5 Ha Manh Tran 2022-01-01 Build site.
Rmd c667dd0 Ha Manh Tran 2022-01-01 workflowr::wflow_publish(files = here::here(c("1_analysis/index.Rmd",
Rmd 3b268fc Ha Tran 2021-12-09 multiple FC, reactome, big clean up.
html 3b268fc Ha Tran 2021-12-09 multiple FC, reactome, big clean up.
Rmd 7247e9c Ha Tran 2021-11-30 additional KEGG heatmap, pathview, reactome
html 7247e9c Ha Tran 2021-11-30 additional KEGG heatmap, pathview, reactome
html b409b38 Ha Manh Tran 2021-11-30 Build site.
Rmd d19f8aa Ha Manh Tran 2021-11-30 workflowr::wflow_publish(files = c("1_analysis/index.Rmd", "1_analysis/figure/setUp.Rmd/",

Data Setup

# working with data
library(dplyr)
library(magrittr)
library(readr)
library(tibble)
library(reshape2)
library(tidyverse)

# Visualisation:
library(kableExtra)
library(ggplot2)
library(grid)
library(DT)
library(extrafont)
library(VennDiagram)
# Custom ggplot
library(gridExtra)
library(ggbiplot)
library(ggrepel)
library(rrvgo)
library(d3treeR)
library(plotly)
library(GOSemSim)
library(data.table)

# Bioconductor packages:
library(edgeR)
library(limma)
library(Glimma)
library(clusterProfiler)
library(org.Mm.eg.db)
library(enrichplot)
library(patchwork)

library(pandoc)
library(knitr)
# load DGElist previously created in the set up
dge <- readRDS(here::here("0_data/RDS_objects/dge.rds"))
lm <- readRDS(here::here("0_data/RDS_objects/lm.rds"))
lm_all <- readRDS(here::here("0_data/RDS_objects/lm_all.rds"))
lm_sig <- readRDS(here::here("0_data/RDS_objects/lm_sig.rds"))
Comp <- readRDS(here::here("0_data/RDS_objects/comp.rds"))
# to increase the knitting speed. change to T to save all plots
savePlots <- T
export <- T
# Theme
bossTheme <- readRDS(here::here("0_data/functions/bossTheme.rds"))
bossTheme_bar <- readRDS(here::here("0_data/functions/bossTheme_bar.rds"))
groupColour <- readRDS(here::here("0_data/functions/groupColour.rds"))
groupColour_dark <- readRDS(here::here("0_data/functions/groupColour_dark.rds"))
expressionCol <- readRDS(here::here("0_data/functions/expressionCol.rds"))
expressionCol_dark <- readRDS(here::here("0_data/functions/expressionCol_dark.rds"))
compColour <- readRDS(here::here("0_data/functions/compColour.rds"))


DT <- readRDS(here::here("0_data/functions/DT.rds"))

# Plotting
convert_to_superscript <- readRDS(here::here("0_data/functions/convert_to_superscript.rds"))
exponent <- readRDS(here::here("0_data/functions/exponent.rds"))
format_y_axis <- readRDS(here::here("0_data/functions/format_y_axis.rds"))

firstCap <- function(x) {
  substr(x, 1, 1) <- toupper(substr(x, 1, 1))
  x
}

Gene ontology (GO) Analysis

Functional enrichment analysis is a method used to identify biological functions or processes overrepresented in a set of genes or proteins.

Gene Ontology (GO) is a standardized system for annotating genes and their products with terms from a controlled vocabulary, organized into three main categories: Molecular Function, Biological Process, and Cellular Component.

  • Biological Process (BP): Describes the larger, coordinated biological events or processes in which a gene product is involved. This category represents a series of molecular events that contribute to a specific function.

  • Molecular Function (MF): Describes the specific molecular activities that a gene product performs, such as catalytic or binding activities.

  • Cellular Component (CC): Describes the location or structure within the cell where a gene product is active, such as the nucleus, cytoplasm, or membrane.

Each of these three main categories is further organized into a hierarchical structure with more specific terms. The terms become more specialized as you move down the hierarchy (ontology level). Comparing a gene list to a reference database offers critical insights into the biological significance of gene expression changes.

enrichGO <- readRDS(here::here("0_data/RDS_objects/enrichGO_new.rds"))
enrichGO_sig <- readRDS(here::here("0_data/RDS_objects/enrichGO_sig_new.rds"))
# `goSummaries` is a package created by Dr Stevie Pederson for filtering GO terms based on ontology level.
goSummaries <- url("https://uofabioinformaticshub.github.io/summaries2GO/data/goSummaries.RDS") %>%
  readRDS()
minPath <- 3
rm(comp)
mmGO <- lapply(c("BP","MF","CC"), function(ont){godata('org.Mm.eg.db', ont=ont)}) %>% setNames(c("BP","MF","CC"))

enrichGO_new=list()
enrichGO_sig_new <- list()

for (comp in Comp) {
  # find enriched GO terms
  enrichGO_new[[comp]] <- clusterProfiler::enrichGO(
    gene =lm_sig[[comp]]$entrezid,
    universe = lm_all[[comp]]$entrezid,
    OrgDb = org.Mm.eg.db,
    keyType = "ENTREZID",
    ont = "ALL",
    pAdjustMethod = "fdr",
    pvalueCutoff = 0.05
  )
}

for (comp in Comp) {
  enrichGO_new[[comp]] <- pairwise_termsim(enrichGO_new[[comp]], method = "Wang",semData = mmGO[[1]], showCategory = nrow(enrichGO_new[[comp]]@result))
  
}

for (comp in Comp) {
  # bind to goSummaries to elminate go terms with ontology levels 1 and 2.
  enrichGO_sig_new[[comp]] <- enrichGO_new[[comp]] %>% 
    clusterProfiler::setReadable(OrgDb = org.Mm.eg.db, keyType = "auto")
  
  enrichGO_sig_new[[comp]] <- enrichGO_sig_new[[comp]] %>%
    as.data.frame() %>%
    rownames_to_column("id") %>%
    left_join(goSummaries) %>%
    # dplyr::filter(shortest_path >= minPath) %>%
    column_to_rownames("id")
  
  # adjust go results, separate compound column, add FDR column, adjust the GeneRatio column
  enrichGO_sig_new[[comp]] <- enrichGO_sig_new[[comp]] %>%
    separate(col = BgRatio, sep = "/", into = c("Total", "Universe")) %>%
    dplyr::mutate(
      logFDR = -log(p.adjust, 10),
      GeneRatio = Count / as.numeric(Total))
  # %>% 
  #   dplyr::select(c("Description", "ontology", "GeneRatio", "pvalue", "p.adjust", "logFDR", "qvalue", "geneID", "Count"))
  
  
  enrichGO_sig_new[[comp]]$Description <- enrichGO_sig_new[[comp]]$Description %>% firstCap() %>% str_wrap(width = 45)
  
  
}

saveRDS(object = enrichGO_sig_new,file = here::here("0_data/RDS_objects/enrichGO_sig_new.rds"))
saveRDS(object = enrichGO_new,file = here::here("0_data/RDS_objects/enrichGO_new.rds"))
simMatrix <- list()
scores <- list()
reducedTerms <- list()

enrichGO <- enrichGO_new
enrichGO_sig <- enrichGO_sig_new

simMatrix[["BP"]] <- lapply(Comp[1:5], function(comp) {
    calculateSimMatrix(enrichGO[[comp]]@result$ID,
                       orgdb="org.Mm.eg.db",
                       ont="BP",
                       method="Wang",
                       semdata = mmGO[["BP"]])
  }) %>% setNames(Comp[1:5])


scores[["BP"]] <- lapply(enrichGO[1:5], function(x) {setNames(-log10(x@result$p.adjust), x@result$ID)}) %>% setNames(names(enrichGO[1:5]))

reducedTerms[["BP"]] <- lapply(Comp[1:5], function(comp) {
  reduced_tb <- reduceSimMatrix(simMatrix[["BP"]][[comp]],
                                scores[["BP"]][[comp]],
                                threshold=0.7,
                                orgdb="org.Mm.eg.db")
  
  reduced_tb$parentTerm <- reduced_tb$parentTerm %>% firstCap() %>% str_wrap(width = 45)
  reduced_tb$term <- reduced_tb$term %>% firstCap() %>% str_wrap(width = 35)
  return(reduced_tb)
}) %>% setNames(Comp[1:5])
    

semSim_df <- list()
reduced_semSim_df <- list()
for(ont in "BP") {
  for (comp in Comp[1:5]) {
    subset_df <- subset(reducedTerms[[ont]][[comp]], parent == rownames(reducedTerms[[ont]][[comp]]))

    parentTerm_size <- reducedTerms[[ont]][[comp]]$parentTerm %>% as.factor() %>% summary(500)
    semSim_df[[ont]][[comp]] <- cbind(subset_df, parentTerm_size)
  }
  
  reduced_semSim_df[[ont]] <- as.data.frame(do.call(rbind, semSim_df[[ont]])) %>%
    rownames_to_column("comparison")
  reduced_semSim_df[[ont]]$comparison <- gsub(pattern = "\\..*", "", reduced_semSim_df[[ont]]$comparison) %>% as.factor()
}

reducedTerms_all <- as.data.frame(do.call(rbind, reduced_semSim_df)) %>%
  rownames_to_column("ont")

reducedTerms_all$ont <- gsub(pattern = "\\..*", "", reducedTerms_all$ont) %>% as.factor()


saveRDS(simMatrix, here::here("0_data/RDS_objects/simMatrix_ora.rds"))
saveRDS(scores, here::here("0_data/RDS_objects/scores_ora.rds"))
saveRDS(reducedTerms, here::here("0_data/RDS_objects/reducedTerms_ora.rds"))
saveRDS(semSim_df, here::here("0_data/RDS_objects/semSim_df.rds"))
saveRDS(reduced_semSim_df, here::here("0_data/RDS_objects/reduced_semSim_df.rds"))
saveRDS(reducedTerms_all, here::here("0_data/RDS_objects/reducedTerms_all.rds"))

Visualisations

The following visualisations are GO enrichment analysis performed with set of DE genes significantly below FDR 0.1 without FC threshold (TREAT). IMPORTANTLY, these GO terms are all significantly enriched (FDR <0.05)

  • Dot plot: illustrates the top 25 enriched GO terms.

    • \(Gene ratio =\) the number of significant DE gene in the term / the total of number of genes in the term. Indicated by the size
    • The shapes represents the three main GO categories, either BP, MP, or CC
  • Table: list of all the significant GO terms

  • Upset: illustrate the overlap of gene between different functional terms

Semantic similarity plots - GO specific

Due to the hierarchical structure of Gene Ontologies, the enriched sets generated often exhibit redundancy and pose challenges in interpretation. The subsequent analyses and visualizations seek to alleviate this redundancy in GO sets by grouping comparable terms based on their semantic similarity. The underlying concept behind measuring semantic similarity is grounded in the idea that genes sharing similar functions should possess analogous annotation vocabulary and exhibit close relationships within the ontology structure.

NOTE: the following semantic similarity analyses are performed using Graph-based method (Wang et al. 2007)

  • Dendrogram plot: performs hierarchical clustering on the semantic similarity of GO terms.

    • NOTE: to maintain readability, only the top 50 most significant GO terms are clustered. These clusters are then divided into 9 clades and labeled using the top 4 high-frequency words.
  • Scatter plot: illustrates the UMAP space between semantically similar significant GO terms

    • Distances represent the similarity between terms,
    • Size represents the significance (in \(-\log_{10}FDR\)))
    • NOTE: to maintain reability, only the top 15 most significant parent terms are labeled. Parent terms are the most significant term in a particular cluster
  • Treemap plot: Visualise the of hierarchical structures of semantically similar GO terms.

    • The terms are colored based on their parent term,
    • The size of the term is proportional to the significance.

I recommend reading through the full list of significant GO terms and selecting the most biologically relevant for better visualisation

INT vs CONT

Dot plot

dot <- list()
tab <- list()
upset <- list()

for (comp in Comp) {
  if (nrow(enrichGO_sig[[comp]]) > 20) { n <- 20 } else { n <-  nrow(enrichGO_sig[[comp]]) }
  dot[[comp]] <- ggplot(enrichGO_sig[[comp]][1:n, ]) +
    geom_point(aes(x = GeneRatio, y = reorder(Description, GeneRatio), colour = logFDR, size = Count, shape = ontology %>% as.factor())) +
    scale_color_gradientn(colors = rev(c("#FB8072","#FDB462","#8DD3C7","#80B1D3")),
                          values = scales::rescale(c(min(enrichGO_sig[[comp]]$logFDR), max(enrichGO_sig[[comp]]$logFDR))),
                          breaks = scales::pretty_breaks(n = 5)) +
    scale_size(range = c(2,5)) +
    labs(x = "Gene ratio", y = "", color = expression("-log"[10] * "FDR"), size = "Gene Counts", shape = "Ontology")+
    bossTheme(base_size = 14,legend = "right")
  
  tab[[comp]] <- enrichGO_sig[[comp]] %>% 
    dplyr::mutate_if(is.numeric, funs(as.character(signif(.,3)))) %>% 
    DT(., caption = "Significantly enriched GO terms")
  
  
  upset[[comp]] <- upsetplot(x = enrichGO[[comp]], 10)
  
  # if(savePlots == TRUE) {
  #   ggsave(filename = paste0("dot_", comp, ".svg"), plot = dot[[comp]], path = here::here("2_plots/3_FA/go/"),
  #          width = 18, height = 20, units = "cm")
  #   ggsave(filename = paste0("upset_", comp, ".svg"), plot = upset[[comp]], path = here::here("2_plots/3_FA/go/"), width = 20, height = 14, units = "cm")

  # }
}

saveRDS(dot, here::here("0_data/rds_plots/go_dotPlot.rds"))

dot[[1]]

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Table

tab[[1]]

Upset plot

upset[[1]]

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Dendrogram

den <- lapply(enrichGO[1:5], function(x) {
  treeplot(x,showCategory = 50, fontsize = 3, cex_category = 0.5,
         cluster.params      = list(method = "ward.D", n = 9, label_words_n = 4, label_format = 30),
         hilight.params      = list(hilight = F, align = "both"),
         clusterPanel.params = list(clusterPanel = "heatMap", pie = "equal", legend_n = 3),
         offset.params       = list(bar_tree = rel(3), tiplab = rel(4), extend = 0.1, hexpand = 0.4)) +
  theme(legend.position = "bottom")
}) %>% setNames(enrichGO[1:5])

# saveRDS(den, here::here("0_data/rds_objects/ora_dendrogram.rds"))
# den <- readRDS(here::here("0_data/rds_objects/ora_dendrogram.rds"))

den[[6]] <- ggplot() + theme_void()
den[[1]]

Version Author Date
d71eeb4 Ha Tran 2024-10-16
for(i in 1:length(Comp[1:5])){
  if(savePlots == TRUE) {
    ggsave(filename = paste0("semSim_dendrogram_", Comp[i], ".svg"), plot = den[[i]], path = here::here("2_plots/3_FA/go/"),
           width = 20, height = 25, units = "cm")
  }
}

Scatter plot

simMatrix <- readRDS(here::here("0_data/rds_objects/simMatrix_ora.rds"))
scores <- readRDS(here::here("0_data/rds_objects/scores_ora.rds"))
reducedTerms <- readRDS(here::here("0_data/rds_objects/reducedTerms_ora.rds"))

revigo_dimReduction <- function(simMatrix, reducedTerms, algorithm = c("pca", "umap"), size = "score") {
  
  x <- switch(match.arg(algorithm), pca = cmdscale(as.matrix(as.dist(1 - simMatrix)), eig = TRUE, k = 3)$points, umap = umap::umap(as.matrix(as.dist(1 - simMatrix)),n_components = 3)$layout)
  df <- cbind(as.data.frame(x), reducedTerms[match(rownames(x), reducedTerms$go), c("term", "parent", "parentTerm", size)])
  
  return(df)
}
dimReduced <- list()
scatter <- list()
for (comp in Comp[c(1:3,5)]){
  set.seed(3)
  dimReduced[[comp]] <- revigo_dimReduction(simMatrix[["BP"]][[comp]], reducedTerms[["BP"]][[comp]], algorithm = "umap")
  
  m <- subset(dimReduced[[comp]], parent == rownames(dimReduced[[comp]]))[1:10,]
  
  scatter[[comp]] <- ggplot(dimReduced[[comp]], aes(x = V1, y = V2, color = parentTerm)) +
    geom_point(aes_string(size = "score"), alpha = 0.5, stroke = 0) + 
    scale_color_discrete(guide = "none") +
    # scale_fill_discrete(guide = "none") +
    scale_size_continuous(name = expression("-log"[10] * "FDR"), range = c(0,12)) + 
    scale_x_continuous(name = "UMAP1") +
    scale_y_continuous(name = "UMAP2") +
    guides(x = ggh4x::guide_axis_truncated(trunc_lower = unit(0, "npc"),trunc_upper = unit(3, "cm")), 
           y = ggh4x::guide_axis_truncated(trunc_lower = unit(0, "npc"),trunc_upper = unit(3, "cm"))) +
    geom_label_repel(aes(label = m$parentTerm),data = m, box.padding = grid::unit(1,"lines"), size = 3, label.size = 0.15) + 
    bossTheme(14) +
    theme(
      line = element_blank(),
      rect = element_blank(),
      panel.border = element_blank(),
      axis.text.x = element_blank(),
      axis.text.y = element_blank(),
      axis.ticks = element_blank(),
      legend.position = "right",
      axis.line = element_line(arrow = arrow()),
      axis.title = element_text(hjust = 0),
      axis.title.y = element_text(
        family = "Arial Narrow",
        face = "plain",
        size = 13,
        angle = 90,
        vjust = 1
      ),
      axis.title.x = element_text(
        family = "Arial Narrow",
        face = "plain",
        size = 13,
        angle = 0,
        vjust = 0
      )
    )
  
  if(savePlots == TRUE) {
    ggsave(filename = paste0("semSim_scatter_", comp, ".svg"), plot = scatter[[comp]], path = here::here("2_plots/3_FA/go/"),
           width = 18, height = 18, units = "cm")

  }
  
}

for(comp in Comp[c(4,6)]) {scatter[[comp]] <- ggplot() + theme_void()}


saveRDS(scatter, here::here("0_data/rds_plots/go_parTerm_scatter.rds"))

scatter[[Comp[1]]]

Version Author Date
d71eeb4 Ha Tran 2024-10-16
scatter_plotly <- list()
for (comp in Comp[c(1:3,5)]){
  scatter_plotly[[comp]] <- ggplotly(scatter[[comp]] + bossTheme(14)) %>% add_markers(size = 5) %>% layout(showlegend = FALSE)
}

for(comp in Comp[c(4,6)]) {scatter_plotly[[comp]] <- ggplot() + theme_void()}

scatter_plotly[[Comp[1]]]

3D Interactive scatter

scatter_3d <- list()

for(comp in Comp[c(1:3,5)]){
  scatter_3d[[comp]] <- plot_ly(dimReduced[[comp]], x = ~ V1, y = ~ V2, z = ~ V3, color = ~ parentTerm, size = ~ score,
  marker = list(symbol = 'circle', sizemode = 'diameter'),
  sizes = c(5, 70),
  text = ~paste('Term    :', term,'<br>P. Term:', parentTerm, '<br>Sig       :', score),
  hoverinfo = 'text') %>% 
  layout(showlegend = FALSE,
         title = 'Semantically similar GO terms',
         scene = list(xaxis = list(title = 'UMAP 1',
                      gridcolor = 'rgb(255, 255, 255)',
                      zerolinewidth = 1,
                      ticklen = 5,
                      gridwidth = 2),
               yaxis = list(title = 'UMAP 2',
                      gridcolor = 'rgb(255, 255, 255)',
                      zerolinewidth = 1,
                      ticklen = 5,
                      gridwith = 2),
               zaxis = list(title = 'UMAP 3',
                            gridcolor = 'rgb(255, 255, 255)',
                            zerolinewidth = 1,
                            ticklen = 5,
                            gridwith = 2)))
  
}
for(comp in Comp[c(4,6)]) {scatter_3d[[comp]] <- ggplot() + theme_void()}
scatter_3d[[Comp[1]]]

Parent terms

semSim_df <- readRDS(here::here("0_data/rds_objects/semSim_df.rds"))

semSim_dot <- lapply(Comp[1:5], function(comp){
  if (nrow(semSim_df[["BP"]][[comp]]) > 20) { n <- 20 } else { n <- nrow(semSim_df[["BP"]][[comp]]) }
  df <- semSim_df[["BP"]][[comp]][1:n,]
  df$parentTerm <- df$parentTerm %>% str_wrap(50)
  
  plot <- ggplot(df) +
    geom_point(aes(x = parentTerm_size, y = reorder(parentTerm, score), colour = score, size = parentTerm_size)) +
    scale_color_gradientn(colors = rev(c("#FB8072","#FDB462","#8DD3C7","#80B1D3")),
                          values = scales::rescale(c(min(df$score), max(df$score))),
                          breaks = scales::pretty_breaks(n = 5)) +
    scale_size(range = c(2,5), guide = F) +
    labs(x = "Term size", y = "", color = expression("-log"[10] * "FDR"))+
    bossTheme(base_size = 14,legend = "right")
  
  if(savePlots == TRUE) {
    ggsave(filename = paste0("parTerm_dot_", comp, ".svg"), plot = plot, path = here::here("2_plots/3_FA/go/"),
           width = 18, height = 20, units = "cm")
  }
  
  return(plot)
  
}) 
semSim_dot[["BP"]][[Comp[6]]] <- ggplot() + theme_void()

saveRDS(semSim_dot, here::here("0_data/rds_plots/go_parTerm_dotPlot.rds"))

semSim_dot[1]
[[1]]

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Treemap plot

adjTreemap <- function (x, size = "score", title = "", ...) {
  treemap::treemap(
    x,
    index = c("parentTerm", "term"),
    vSize = size,
    type = "index",
    title = title,
    palette = "Set2",
    fontcolor.labels = c("grey85","#00000080"),
    bg.labels = 0,
    border.col = "grey10",
    border.lwds = c(1,0.5),
    fontfamily.labels = "Arial Narrow"
  )
}

adjTreemap(reducedTerms[[1]][[1]])

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Interactive Tree

# png(filename=here::here("2_plots/tree.png"),width=20, height=20,units = "cm",res = 900)
# tree <- adjTreemap(reducedTerms)
# dev.off()

library(htmltools)

interactive_treemap <- function(x){
  browsable(
    tagList(
      tags$head(
        tags$style('text.label{font-size: 20px !important}')
      ),
      d3tree3(adjTreemap(x), rootname = "General")
    )
  )
}

interactive_treemap(reducedTerms[[1]][[4]])

Version Author Date
d71eeb4 Ha Tran 2024-10-16
## this function is basically creating chunks within chunks, and then
## I use results='asis' so that the html image code is rendered 
kexpand <- function(wd, ht, cap, res, echo) {
  cat(knit(text = knit_expand(text = 
     sprintf("```{r %s, results='%s', echo = '%s',fig.keep='all', fig.width=%s, fig.height=%s}\n.pl\n```", cap, res, echo, wd, ht)
)))}

special_kexpand <- function(wd, ht, cap, res, echo) {
  cat(knit(text = knit_expand(text = 
     sprintf("```{r %s, results='%s', echo = '%s',fig.keep='all', fig.width=%s, fig.height=%s}\ninteractive_treemap(reducedTerms[[1]][[i]])\n```", cap, res, echo, wd, ht)
)))}

# Loop through each FC value
headers <- Comp[1:5]
types <- c("Dot plot", "Table", "Upset plot", "Dendrogram", "Scatter", "Parent term", "Treemap")

for (i in 2:length(headers)) {
  cat(paste0("### ",headers[i],"{.tabset .tabset-pills} \n\n"))
  
  cat(paste0("#### ",types[[1]]," \n"))
  .pl <- dot[[Comp[i]]] 
  kexpand(wd = 8,ht = 10,cap = paste0("dot",i),res = "markup",echo = "TRUE")
  cat("\n\n")
  
  cat(paste0("#### ",types[[2]]," \n"))
  .pl <- tab[[Comp[i]]]
  kexpand(wd = 11,ht = 8,cap = paste0("tab",i), res = "markup",echo = "TRUE")
  cat("\n\n")
  
  cat(paste0("#### ",types[[3]]," \n"))
  .pl <- upset[[Comp[i]]] 
  kexpand(wd = 11,ht = 9,cap = paste0("upset",i),res = "markup",echo = "TRUE")
  cat("\n\n")
  
  cat(paste0("#### ",types[[4]]," \n"))
  .pl <- den[[Comp[i]]] 
  kexpand(wd = 8,ht = 11,cap = paste0("den",i),res = "markup",echo = "TRUE")
  cat("\n\n")
  
  cat(paste0("#### ",types[[5]]," \n"))
  .pl <- scatter[[Comp[i]]] 
  kexpand(wd = 8,ht = 8,cap = paste0("scatter",i),res = "markup",echo = "TRUE")
  cat("\n\n")
  
  cat(paste0("Interactive Scatter \n"))
  .pl <- scatter_plotly[[Comp[i]]] 
  kexpand(wd = 9,ht = 9,cap = paste0("scatter_interactive",i),res = "markup",echo = "TRUE")
  cat("\n\n")
  
  cat(paste0("3D scatter \n"))
  .pl <- scatter_3d[[Comp[i]]] 
  kexpand(wd = 9,ht = 9,cap = paste0("scatter_3d",i),res = "markup",echo = "TRUE")
  cat("\n\n")
  
  cat(paste0("#### ",types[[6]]," \n"))
  .pl <- semSim_dot[[Comp[i]]]
  kexpand(wd = 9,ht = 12 ,cap = paste0("parentTerm",i),res = "markup",echo = "TRUE")
  cat("\n\n")
  
  cat(paste0("#### ",types[[7]]," \n"))
  # special_kexpand(wd = 9,ht = 9,cap = paste0("treemap",i),res = "hide",echo = "FALSE")
  # cat("\n\n")
  
  # cat(paste0("Interactive Treemap\n"))
  # .pl <- interactive_treemap(reducedTerms[[i]])
  special_kexpand(wd = 9,ht = 9,cap = paste0("treemap",i),res = "markup",echo = "FALSE")
  cat("\n\n")
}

INT vs SVX_VAS

Dot plot

| | | 0% | |………………………………………………………| 100% [dot2]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Table

| | | 0% | |………………………………………………………| 100% [tab2]

.pl

Upset plot

| | | 0% | |…………………………………………………….| 100% [upset2]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Dendrogram

| | | 0% | |………………………………………………………| 100% [den2]

.pl
NULL

Scatter

| | | 0% | |…………………………………………………..| 100% [scatter2]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Interactive Scatter | | | 0% | |………………………………………..| 100% [scatter_interactive2]

.pl

3D scatter | | | 0% | |………………………………………………..| 100% [scatter_3d2]

.pl

Parent term

| | | 0% | |………………………………………………..| 100% [parentTerm2]

.pl
NULL

Treemap

| | | 0% | |…………………………………………………..| 100% [treemap2]

interactive_treemap(reducedTerms[[1]][[i]])

Version Author Date
d71eeb4 Ha Tran 2024-10-16

SVX vs SVX_VAS

Dot plot

| | | 0% | |………………………………………………………| 100% [dot3]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Table

| | | 0% | |………………………………………………………| 100% [tab3]

.pl

Upset plot

| | | 0% | |…………………………………………………….| 100% [upset3]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Dendrogram

| | | 0% | |………………………………………………………| 100% [den3]

.pl
NULL

Scatter

| | | 0% | |…………………………………………………..| 100% [scatter3]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Interactive Scatter | | | 0% | |………………………………………..| 100% [scatter_interactive3]

.pl

3D scatter | | | 0% | |………………………………………………..| 100% [scatter_3d3]

.pl

Parent term

| | | 0% | |………………………………………………..| 100% [parentTerm3]

.pl
NULL

Treemap

| | | 0% | |…………………………………………………..| 100% [treemap3]

interactive_treemap(reducedTerms[[1]][[i]])

Version Author Date
d71eeb4 Ha Tran 2024-10-16

VAS vs SVX_VAS

Dot plot

| | | 0% | |………………………………………………………| 100% [dot4]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Table

| | | 0% | |………………………………………………………| 100% [tab4]

.pl

Upset plot

| | | 0% | |…………………………………………………….| 100% [upset4]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Dendrogram

| | | 0% | |………………………………………………………| 100% [den4]

.pl
NULL

Scatter

| | | 0% | |…………………………………………………..| 100% [scatter4]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Interactive Scatter | | | 0% | |………………………………………..| 100% [scatter_interactive4]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

3D scatter | | | 0% | |………………………………………………..| 100% [scatter_3d4]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Parent term

| | | 0% | |………………………………………………..| 100% [parentTerm4]

.pl
NULL

Treemap

| | | 0% | |…………………………………………………..| 100% [treemap4]

interactive_treemap(reducedTerms[[1]][[i]])

Version Author Date
d71eeb4 Ha Tran 2024-10-16

SVX_VAS vs CONT

Dot plot

| | | 0% | |………………………………………………………| 100% [dot5]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Table

| | | 0% | |………………………………………………………| 100% [tab5]

.pl

Upset plot

| | | 0% | |…………………………………………………….| 100% [upset5]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Dendrogram

| | | 0% | |………………………………………………………| 100% [den5]

.pl
NULL

Scatter

| | | 0% | |…………………………………………………..| 100% [scatter5]

.pl

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Interactive Scatter | | | 0% | |………………………………………..| 100% [scatter_interactive5]

.pl

3D scatter | | | 0% | |………………………………………………..| 100% [scatter_3d5]

.pl

Parent term

| | | 0% | |………………………………………………..| 100% [parentTerm5]

.pl
NULL

Treemap

| | | 0% | |…………………………………………………..| 100% [treemap5]

interactive_treemap(reducedTerms[[1]][[i]])

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Combined

Venn diagram

Dot plot

# combine all df in list into one df
go_dot_all <- as.data.frame(do.call(rbind, enrichGO_sig)) %>%
  rownames_to_column("group")

# clean group names and change to factor
go_dot_all$group <- gsub(pattern = "\\..*", "", go_dot_all$group) %>% as.factor()

# factor the descriptions
top10 <- as.data.frame(do.call(rbind, lapply(enrichGO_sig, "[", 1:15,3))) %>% rownames_to_column("group")
top10 <- reshape2::melt(top10, "group")
terms <- top10$value %>% as.factor() %>% levels()
go_dot_all <- go_dot_all[go_dot_all$Description %in% terms,]
go_dot_all$group <- factor(go_dot_all$group,levels = c("INT vs CONT", "INT vs SVX_VAS","SVX vs SVX_VAS",
                                                       "VAS vs SVX_VAS","SVX_VAS vs CONT", "INT vs VAS"))
go_dot_all$Description <- go_dot_all$Description %>% str_wrap(55)
combine_go <- ggplot(go_dot_all) +
    geom_point(aes(x = group, y = reorder(Description, logFDR), colour = logFDR, size = Count, shape = ONTOLOGY %>% as.factor())) +
    scale_color_gradientn(colors = rev(c("#FB8072","#FDB462","#8DD3C7","#80B1D3")),
                          values = scales::rescale(c(min(go_dot_all$logFDR), max(go_dot_all$logFDR))),
                          breaks = scales::pretty_breaks(n = 5)) +
    scale_size(range = c(2,5)) +
    labs(x = "", y = "", color = expression("-log"[10] * "FDR"), size = "Counts", shape = "Ontology")+
    bossTheme(base_size = 14,legend = "right")
  
  
  if(savePlots == TRUE) {
    ggsave(filename = paste0("combine_go_dot.svg"), plot = combine_go, path = here::here("2_plots/3_FA/go/"),
           width = 20, height = 25, units = "cm")
  }

saveRDS(combine_go, here::here("0_data/rds_plots/go_combined_dotPlot.rds"))


combine_go

Version Author Date
d71eeb4 Ha Tran 2024-10-16

Parent term Venn

 # cat.pos = c(-27, 27, 135),
 #               cat.dist = c(0.055, 0.055, 0.085)
futile.logger::flog.threshold(futile.logger::ERROR, name = "VennDiagramLogger")
NULL
# INT vs CONT SVX_VAS vs CONT  INT vs SVX_VAS  SVX vs SVX_VAS 
#       "#BEBADA"       "#FFFFB3"       "#8DD3C7"       "#FB8072" 
#  VAS vs SVX_VAS      INT vs VAS 
#       "#FDB462"       "#FCCDE5" 
cat.pos <- list(BP =c(0,0,180),
                MF =c(-170,170,0),
                CC =c(-27, 27, 135))
cat.dist <- list(BP =c(0.05, .05, .05),
                 MF =c(0.085, 0.06, 0.085),
                 CC =c(0.055, 0.055, 0.085))

for(ont in "BP"){
  venn.diagram(x = list("INT vs SVX_VAS"   = reducedTerms[[ont]][[2]]$parentTerm %>% as.character(), 
                        "SVX vs SVX_VAS" = reducedTerms[[ont]][[3]]$parentTerm %>% as.character(),
                        "VAS vs SVX_VAS"  = reducedTerms[[ont]][[4]]$parentTerm %>% as.character()),
               filename = here::here(paste0("docs/assets/go_parTerm_",ont,"_venn.png")),
               lwd = 2,
               disable.logging = T,
               fill = compColour[c(3,4,5)],
               alpha = 0.75,
               lty = 'blank',
               imagetype = "png",
               # main = paste0(ont, "parent terms"),
               
               # Numbers
               cex = 2,
               fontface = "plain",
               fontfamily = "Arial Narrow",
               
               # Set names
               cat.cex = 2,
               cat.fontface = "bold",
               cat.fontfamily = "Arial Narrow",
               cat.default.pos = "outer",
               cat.pos = cat.pos[[ont]],
               cat.dist = cat.dist[[ont]]
  )
}
Biological Processes parent terms
Biological Processes parent terms

Parent term dot

reducedTerms_all <- readRDS(here::here("0_data/rds_objects/reducedTerms_all.rds"))
reducedTerms_all_BP <- reducedTerms_all[!reducedTerms_all$ont %in% c("MF", "CC"),] 
reducedTerms_all_BP <- reducedTerms_all_BP[reducedTerms_all_BP$comparison %in% c(Comp[c(2,3,4)]),] %>% dplyr::arrange(parentTerm)
reducedTerms_all_BP$parentTerm <- reducedTerms_all_BP$parentTerm %>% str_wrap(38)

dotplot <- function(data){
  ggplot(data) +
    geom_point(aes(x = comparison, y = parentTerm, colour = score, size = parentTerm_size), alpha=0.8) +
    scale_color_gradientn(colours = rev(c("#FB8072","#FDB462","#8DD3C7","#80B1D3")),
                          limits = c(min(reducedTerms_all_BP$score), max(reducedTerms_all_BP$score)),
                          breaks = scales::pretty_breaks(n = 5)) +
    scale_size(range = c(2,5),limits = c(min(reducedTerms_all_BP$parentTerm_size), max(reducedTerms_all_BP$parentTerm_size))) +
    labs(x = "", y = "", color = expression("-log"[10] * "FDR"), size = "Term size")+
    bossTheme(base_size = 14,legend = "bottom")
}


t <- wrap_plots(list(dotplot(reducedTerms_all_BP[1:32, ]), dotplot(reducedTerms_all_BP[32:nrow(reducedTerms_all_BP), ]))) + 
  plot_layout(guides = "collect") &
  bossTheme(base_size = 12, legend = "none") &
  theme(legend.box.margin = margin(-5, 0, 0, -50, unit = "mm"),
        # plot.margin = margin(1, 1, 1, 0, unit = "pt"),
        axis.text.y = element_text(family = "Arial Narrow", face = "plain", size = 10, hjust = 1),
        axis.text.x = element_text(family =  "Arial", face = "plain", size = 11, hjust = 1, vjust = 1, angle = 40))

t
Biological processes parent terms

Biological processes parent terms

Version Author Date
d71eeb4 Ha Tran 2024-10-16
saveRDS(t, here::here("0_data/rds_plots/go_combined_parTerm_dotPlot.rds"))

ggsave(filename = "parentTerm_all.png", plot = t, path = here::here("2_plots/3_FA/go/"),
           width = 21, height = 27, units = "cm")

Export Data

The following are exported:

  • GO.xlsx - This spreadsheet contains all significantly enriched GO terms. NOTE:
# save to excel
writexl::write_xlsx(x = lapply(enrichGO_sig[c(2,3,4)], function(x) {x %>% dplyr::select(c(2,1,3:11,19,12:14))}) , here::here("3_output/Gene Ontology.xlsx"))
writexl::write_xlsx(x = reducedTerms[["BP"]], here::here("3_output/semSim_GO_sig.xlsx"))

# saveRDS(object = enrichGO_sig,file = here::here("0_data/RDS_objects/enrichGO_sig.rds"))
# saveRDS(object = enrichGO,file = here::here("0_data/RDS_objects/enrichGO.rds"))

sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS 26.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Australia/Adelaide
tzcode source: internal

attached base packages:
[1] stats4    grid      stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] htmltools_0.5.8.1      knitr_1.50             pandoc_0.2.0          
 [4] patchwork_1.3.2        enrichplot_1.26.6      org.Mm.eg.db_3.20.0   
 [7] AnnotationDbi_1.68.0   IRanges_2.40.1         S4Vectors_0.44.0      
[10] Biobase_2.66.0         BiocGenerics_0.52.0    clusterProfiler_4.14.6
[13] Glimma_2.16.0          edgeR_4.4.2            limma_3.62.2          
[16] data.table_1.17.8      GOSemSim_2.32.0        plotly_4.11.0         
[19] d3treeR_0.1            rrvgo_1.18.0           ggrepel_0.9.6         
[22] ggbiplot_0.6.2         gridExtra_2.3          VennDiagram_1.7.3     
[25] futile.logger_1.4.3    extrafont_0.19         DT_0.34.0             
[28] kableExtra_1.4.0       lubridate_1.9.4        forcats_1.0.0         
[31] stringr_1.5.2          purrr_1.1.0            tidyr_1.3.1           
[34] ggplot2_4.0.0          tidyverse_2.0.0        reshape2_1.4.4        
[37] tibble_3.3.0           readr_2.1.5            magrittr_2.0.4        
[40] dplyr_1.1.4           

loaded via a namespace (and not attached):
  [1] splines_4.4.1               later_1.4.4                
  [3] ggplotify_0.1.3             R.oo_1.27.1                
  [5] XML_3.99-0.19               lifecycle_1.0.4            
  [7] rprojroot_2.1.1             NLP_0.3-2                  
  [9] lattice_0.22-7              crosstalk_1.2.2            
 [11] sass_0.4.10                 rmarkdown_2.29             
 [13] jquerylib_0.1.4             yaml_2.3.10                
 [15] ggtangle_0.0.7              httpuv_1.6.16              
 [17] askpass_1.2.1               reticulate_1.43.0          
 [19] cowplot_1.2.0               DBI_1.2.3                  
 [21] RColorBrewer_1.1-3          abind_1.4-8                
 [23] zlibbioc_1.52.0             GenomicRanges_1.58.0       
 [25] R.utils_2.13.0              yulab.utils_0.2.1          
 [27] rappdirs_0.3.3              git2r_0.36.2               
 [29] GenomeInfoDbData_1.2.13     data.tree_1.2.0            
 [31] tm_0.7-16                   tidytree_0.4.6             
 [33] pheatmap_1.0.13             umap_0.2.10.0              
 [35] RSpectra_0.16-2             svglite_2.2.1              
 [37] gridSVG_1.7-6               codetools_0.2-20           
 [39] DelayedArray_0.32.0         DOSE_4.0.1                 
 [41] xml2_1.4.0                  tidyselect_1.2.1           
 [43] aplot_0.2.9                 UCSC.utils_1.2.0           
 [45] farver_2.1.2                matrixStats_1.5.0          
 [47] jsonlite_2.0.0              systemfonts_1.2.3          
 [49] ggnewscale_0.5.2            tools_4.4.1                
 [51] ragg_1.5.0                  treeio_1.30.0              
 [53] Rcpp_1.1.0                  glue_1.8.0                 
 [55] Rttf2pt1_1.3.12             SparseArray_1.6.2          
 [57] here_1.0.2                  xfun_0.53                  
 [59] DESeq2_1.46.0               qvalue_2.38.0              
 [61] MatrixGenerics_1.18.1       GenomeInfoDb_1.42.3        
 [63] withr_3.0.2                 formatR_1.14               
 [65] fastmap_1.2.0               ggh4x_0.3.1                
 [67] openssl_2.3.3               digest_0.6.37              
 [69] timechange_0.3.0            R6_2.6.1                   
 [71] mime_0.13                   gridGraphics_0.5-1         
 [73] textshaping_1.0.3           colorspace_2.1-1           
 [75] GO.db_3.20.0                RSQLite_2.4.3              
 [77] R.methodsS3_1.8.2           generics_0.1.4             
 [79] httr_1.4.7                  htmlwidgets_1.6.4          
 [81] S4Arrays_1.6.0              whisker_0.4.1              
 [83] pkgconfig_2.0.3             gtable_0.3.6               
 [85] blob_1.2.4                  workflowr_1.7.2            
 [87] S7_0.2.0                    XVector_0.46.0             
 [89] fgsea_1.32.4                ggupset_0.4.1              
 [91] scales_1.4.0                png_0.1-8                  
 [93] wordcloud_2.6               ggfun_0.2.0                
 [95] lambda.r_1.2.4              rstudioapi_0.17.1          
 [97] tzdb_0.5.0                  nlme_3.1-168               
 [99] cachem_1.1.0                parallel_4.4.1             
[101] treemap_2.4-4               pillar_1.11.1              
[103] vctrs_0.6.5                 slam_0.1-55                
[105] promises_1.3.3              xtable_1.8-4               
[107] extrafontdb_1.0             evaluate_1.0.5             
[109] cli_3.6.5                   locfit_1.5-9.12            
[111] compiler_4.4.1              futile.options_1.0.1       
[113] rlang_1.1.6                 crayon_1.5.3               
[115] labeling_0.4.3              plyr_1.8.9                 
[117] fs_1.6.6                    writexl_1.5.4              
[119] stringi_1.8.7               viridisLite_0.4.2          
[121] gridBase_0.4-7              BiocParallel_1.40.2        
[123] Biostrings_2.74.1           lazyeval_0.2.2             
[125] Matrix_1.7-4                hms_1.1.3                  
[127] bit64_4.6.0-1               KEGGREST_1.46.0            
[129] statmod_1.5.0               shiny_1.11.1               
[131] SummarizedExperiment_1.36.0 igraph_2.1.4               
[133] memoise_2.0.1               bslib_0.9.0                
[135] ggtree_3.14.0               fastmatch_1.1-6            
[137] bit_4.6.0                   gson_0.1.0                 
[139] ape_5.8-1