Last updated: 2025-06-06

Checks: 6 1

Knit directory: CX5461_Project/

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


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

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(20250129) 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 305a6c0. 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:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    0.1 box.svg
    Ignored:    Rplot04.svg

Untracked files:
    Untracked:  0.1 density.svg
    Untracked:  0.1.emf
    Untracked:  0.1.svg
    Untracked:  0.5 box.svg
    Untracked:  0.5 density.svg
    Untracked:  0.5.svg
    Untracked:  Additional/
    Untracked:  Autosome factors.svg
    Untracked:  CX_5461_Pattern_Genes_24hr.csv
    Untracked:  CX_5461_Pattern_Genes_3hr.csv
    Untracked:  Cell viability box plot.svg
    Untracked:  DEG GO terms.svg
    Untracked:  DNA damage associated GO terms.svg
    Untracked:  DRC1.svg
    Untracked:  Figure 1.jpeg
    Untracked:  Figure 1.pdf
    Untracked:  Figure_CM_Purity.pdf
    Untracked:  G Quadruplex DEGs.svg
    Untracked:  PC2 Vs PC3 Autosome.svg
    Untracked:  PCA autosome.svg
    Untracked:  Rplot 18.svg
    Untracked:  Rplot.svg
    Untracked:  Rplot01.svg
    Untracked:  Rplot02.svg
    Untracked:  Rplot03.svg
    Untracked:  Rplot05.svg
    Untracked:  Rplot06.svg
    Untracked:  Rplot07.svg
    Untracked:  Rplot08.jpeg
    Untracked:  Rplot08.svg
    Untracked:  Rplot09.svg
    Untracked:  Rplot10.svg
    Untracked:  Rplot11.svg
    Untracked:  Rplot12.svg
    Untracked:  Rplot13.svg
    Untracked:  Rplot14.svg
    Untracked:  Rplot15.svg
    Untracked:  Rplot16.svg
    Untracked:  Rplot17.svg
    Untracked:  Rplot18.svg
    Untracked:  Rplot19.svg
    Untracked:  Rplot20.svg
    Untracked:  Rplot21.svg
    Untracked:  Rplot22.svg
    Untracked:  Rplot23.svg
    Untracked:  Rplot24.svg
    Untracked:  TOP2B.bed
    Untracked:  TS HPA (Violin).svg
    Untracked:  TS HPA.svg
    Untracked:  TS_HA.svg
    Untracked:  TS_HV.svg
    Untracked:  Violin HA.svg
    Untracked:  Violin HV (CX vs DOX).svg
    Untracked:  Violin HV.svg
    Untracked:  data/AF.csv
    Untracked:  data/AF_Mapped.csv
    Untracked:  data/AF_genes.csv
    Untracked:  data/Annotated_DOX_Gene_Table.csv
    Untracked:  data/BP/
    Untracked:  data/CAD_genes.csv
    Untracked:  data/Cardiotox.csv
    Untracked:  data/Cardiotox_mapped.csv
    Untracked:  data/Corrmotif_GO/
    Untracked:  data/DOX_Vald.csv
    Untracked:  data/DOX_Vald_Mapped.csv
    Untracked:  data/DOX_alt.csv
    Untracked:  data/Entrez_Cardiotox.csv
    Untracked:  data/Entrez_Cardiotox_Mapped.csv
    Untracked:  data/GWAS.xlsx
    Untracked:  data/GWAS_SNPs.bed
    Untracked:  data/HF.csv
    Untracked:  data/HF_Mapped.csv
    Untracked:  data/HF_genes.csv
    Untracked:  data/Hypertension_genes.csv
    Untracked:  data/MI_genes.csv
    Untracked:  data/P53_Target_mapped.csv
    Untracked:  data/Sample_annotated.csv
    Untracked:  data/Samples.csv
    Untracked:  data/Samples.xlsx
    Untracked:  data/TOP2A.bed
    Untracked:  data/TOP2A_target.csv
    Untracked:  data/TOP2A_target_lit.csv
    Untracked:  data/TOP2A_target_lit_mapped.csv
    Untracked:  data/TOP2A_target_mapped.csv
    Untracked:  data/TOP2B.bed
    Untracked:  data/TOP2B_target.csv
    Untracked:  data/TOP2B_target_heatmap.csv
    Untracked:  data/TOP2B_target_heatmap_mapped.csv
    Untracked:  data/TOP2B_target_mapped.csv
    Untracked:  data/TS.csv
    Untracked:  data/TS_HPA.csv
    Untracked:  data/TS_HPA_mapped.csv
    Untracked:  data/Toptable_CX_0.1_24.csv
    Untracked:  data/Toptable_CX_0.1_3.csv
    Untracked:  data/Toptable_CX_0.1_48.csv
    Untracked:  data/Toptable_CX_0.5_24.csv
    Untracked:  data/Toptable_CX_0.5_3.csv
    Untracked:  data/Toptable_CX_0.5_48.csv
    Untracked:  data/Toptable_DOX_0.1_24.csv
    Untracked:  data/Toptable_DOX_0.1_3.csv
    Untracked:  data/Toptable_DOX_0.1_48.csv
    Untracked:  data/Toptable_DOX_0.5_24.csv
    Untracked:  data/Toptable_DOX_0.5_3.csv
    Untracked:  data/Toptable_DOX_0.5_48.csv
    Untracked:  data/count.tsv
    Untracked:  data/ts_data_mapped
    Untracked:  results/
    Untracked:  run_bedtools.bat

Unstaged changes:
    Deleted:    analysis/Actox.Rmd
    Modified:   analysis/Corrmotif_Conc.Rmd
    Modified:   analysis/Corrmotif_Conc_GO.Rmd
    Modified:   data/DOX_0.5_48 (Combined).csv
    Modified:   data/Human_Heart_Genes.csv
    Modified:   data/Total_number_of_Mapped_reads_by_Individuals.csv

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 (analysis/Corrmotif_Conc_GO.Rmd) and HTML (docs/Corrmotif_Conc_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 df65b82 sayanpaul01 2025-06-04 Commit
html df65b82 sayanpaul01 2025-06-04 Commit
Rmd cf7130e sayanpaul01 2025-06-03 Commit
html cf7130e sayanpaul01 2025-06-03 Commit
Rmd c5f10c4 sayanpaul01 2025-06-02 Commit
html c5f10c4 sayanpaul01 2025-06-02 Commit
Rmd c034ee0 sayanpaul01 2025-06-02 Commit
html c034ee0 sayanpaul01 2025-06-02 Commit
Rmd cf95313 sayanpaul01 2025-03-10 Commit
html cf95313 sayanpaul01 2025-03-10 Commit
Rmd 11895c8 sayanpaul01 2025-02-27 Commit
html 11895c8 sayanpaul01 2025-02-27 Commit
Rmd 6484005 sayanpaul01 2025-02-27 Commit
html 6484005 sayanpaul01 2025-02-27 Commit
Rmd 87137ac sayanpaul01 2025-02-27 Commit
html 87137ac sayanpaul01 2025-02-27 Commit

📌 Load Required Libraries

library(tidyverse) 
library(ggfortify)
library(ggplot2)
library(cluster)
library(edgeR)
library(limma)
library(Homo.sapiens)
library(BiocParallel)
library(qvalue)
library(pheatmap)
library(clusterProfiler)
library(AnnotationDbi)
library(org.Hs.eg.db)
library(RColorBrewer)
library(readr)
library(TxDb.Hsapiens.UCSC.hg38.knownGene)
library(DOSE)

# Load UCSC transcript database
txdb <- TxDb.Hsapiens.UCSC.hg38.knownGene

📌 0.1 Micromolar

📌 Read and Process Data

# Load the saved datasets
prob_1_0.1 <- read.csv("data/prob_1_0.1.csv")$Entrez_ID
prob_2_0.1 <- read.csv("data/prob_2_0.1.csv")$Entrez_ID
prob_3_0.1 <- read.csv("data/prob_3_0.1.csv")$Entrez_ID
prob_1_0.5 <- read.csv("data/prob_1_0.5.csv")$Entrez_ID
prob_2_0.5 <- read.csv("data/prob_2_0.5.csv")$Entrez_ID
prob_3_0.5 <- read.csv("data/prob_3_0.5.csv")$Entrez_ID
prob_4_0.5 <- read.csv("data/prob_4_0.5.csv")$Entrez_ID
prob_5_0.5 <- read.csv("data/prob_5_0.5.csv")$Entrez_ID


CX_0.1_3 <- read.csv("data/DEGs/Toptable_CX_0.1_3.csv")
background<-as.character(CX_0.1_3$Entrez_ID)

📌 Non response (0.1 µM)

📌 GO Enrichment Clusterprofiler

# 📦 Load Libraries
library(tidyverse)
library(patchwork)
Warning: package 'patchwork' was built under R version 4.3.3
library(data.table)
Warning: package 'data.table' was built under R version 4.3.3
# 📁 Load File
go_df <- fread("data/BP/CorMotif_Terms_Combined/GO_All_Non_response_(0.1).csv")

# 🧠 Convert and filter (only adj p < 0.05)
process_enrichment_tibble <- function(df, ontology, category_label) {
  df %>%
    filter(Ontology == ontology & p.adjust < 0.05) %>%
    mutate(neglog = -log(p.adjust)) %>%
    arrange(desc(neglog)) %>%
    slice(1:20) %>%
    mutate(Category = category_label)
}

# Create tibbles for each GO class
BP_Tibble <- process_enrichment_tibble(go_df, "BP", "Biological Process")
MF_Tibble <- process_enrichment_tibble(go_df, "MF", "Molecular Function")
CC_Tibble <- process_enrichment_tibble(go_df, "CC", "Cellular Component")

# 📊 Plot function
process_enrichment_plot <- function(tibble, title, color) {
  ggplot(tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log(p-adjust)", y = title,
      title = paste("Top 20", title, "GO Terms (adj p < 0.05)")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, linewidth = 0.3)
    ) +
    xlim(0, max(tibble$neglog, na.rm = TRUE) + 1)
}

# 🔧 Plot for each GO category
plot_BP <- process_enrichment_plot(BP_Tibble, "Biological Process", "#2E86C1")
plot_MF <- process_enrichment_plot(MF_Tibble, "Molecular Function", "#28B463")
plot_CC <- process_enrichment_plot(CC_Tibble, "Cellular Component", "#D35400")

# 🧩 Combine plots
combined_plot <- plot_BP / plot_MF / plot_CC
combined_plot

Version Author Date
84d7de5 sayanpaul01 2025-06-03
87137ac sayanpaul01 2025-02-27

📌 GO Enrichment g:Profiler

# Load the gprofiler2 package
library(gprofiler2)
Warning: package 'gprofiler2' was built under R version 4.3.3
library(ggplot2)
library(dplyr)
library(patchwork)

# Perform GO enrichment analysis with gprofiler2
gost_results <- gost(
  query = prob_1_0.1,           # List of input genes (prob_all_1)
  organism = "hsapiens",   # Human organism
  user_threshold = 0.05,   # Adjusted p-value cutoff
  correction_method = "fdr", # Multiple testing correction
  domain_scope = "custom", # Use custom background
  custom_bg = background,    # Background set of genes
  sources = c("GO:BP", "GO:MF", "GO:CC") # Analyze GO categories
)

# Check if enrichment results exist
if (is.null(gost_results$result) || nrow(gost_results$result) == 0) {
  # If no enriched terms, create a placeholder dataframe
  combined_results <- tibble(
    term_name = "No enriched terms",
    p.adjust = NA,
    source = "N/A",
    Category = "N/A"
  )
} else {
  # Convert results to a data frame
  gost_results_df <- gost_results$result

  # Add a column for adjusted p-value
  gost_results_df <- gost_results_df %>%
    rename(p.adjust = p_value)

  # Separate results for BP, MF, and CC
  BP_results <- gost_results_df %>%
    filter(source == "GO:BP") %>%
    mutate(Category = "Biological Process")

  MF_results <- gost_results_df %>%
    filter(source == "GO:MF") %>%
    mutate(Category = "Molecular Function")

  CC_results <- gost_results_df %>%
    filter(source == "GO:CC") %>%
    mutate(Category = "Cellular Component")

  # Select the top 20 terms by adjusted p-value for each category
  top_BP <- BP_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_MF <- MF_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_CC <- CC_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  # Combine all categories
  combined_results <- bind_rows(top_BP, top_MF, top_CC)
}

# Ensure all columns are atomic types for CSV export
combined_results_clean <- combined_results %>%
  mutate(across(everything(), ~ if (is.list(.)) sapply(., toString) else .))

# Function for plotting top terms
plot_gprofiler_results <- function(data, title, color) {
  ggplot(data, aes(x = -log10(p.adjust), y = reorder(term_name, -log10(p.adjust)))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log10(Adjusted p-value)",
      y = title,
      title = paste("Top 20", title, "GO Terms")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, size = 0.3)
    )
}

# Check if there are enrichment terms to plot
if (nrow(combined_results) == 1 && combined_results$term_name == "No enriched terms") {
  message("No enriched GO terms found for the input gene set.")
} else {
  # Plot the top 20 terms for each category
  plot_BP <- plot_gprofiler_results(top_BP, "Biological Process", "#2E86C1")
  plot_MF <- plot_gprofiler_results(top_MF, "Molecular Function", "#28B463")
  plot_CC <- plot_gprofiler_results(top_CC, "Cellular Component", "#D35400")

  # Combine the plots using patchwork
  combined_plot <- plot_BP / plot_MF / plot_CC

  # Display the combined plot
  combined_plot
}
Warning: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0.
ℹ Please use the `linewidth` argument instead.
This warning is displayed once every 8 hours.
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
generated.

Version Author Date
84d7de5 sayanpaul01 2025-06-03
87137ac sayanpaul01 2025-02-27

📌 Pathway Enrichment

# Load required libraries
library(clusterProfiler)
library(org.Hs.eg.db) # Required for enrichPathway
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)
library(ReactomePA)
Warning: package 'ReactomePA' was built under R version 4.3.1
# Function for ClusterProfiler Reactome & KEGG Analysis
process_clusterProfiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment based on the selected category
  if (category == "Reactome") {
    enrichment <- enrichPathway(
      gene = gene_set,
      organism = "human",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  } else if (category == "KEGG") {
    enrichment <- enrichKEGG(
      gene = gene_set,
      organism = "hsa",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  }
  
  # Check if enrichment results exist
  if (is.null(enrichment) || nrow(as.data.frame(enrichment)) == 0) {
    message(paste("No significant enrichment found for", category, "in ClusterProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- as_tibble(as.data.frame(enrichment)) %>%
    mutate(Category = category,
           neglog = -log10(p.adjust)) %>%  # Compute -log10(p.adjust)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(Adjusted p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Function for gProfiler Reactome & KEGG Analysis
process_gprofiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment using gprofiler2
  enrichment <- gost(
    query = gene_set,
    organism = "hsapiens",
    user_threshold = 0.05,
    correction_method = "fdr",
    domain_scope = "custom",
    custom_bg = background,
    sources = category # Either "REAC" or "KEGG"
  )
  
  # Check if enrichment results exist
  if (is.null(enrichment$result) || nrow(enrichment$result) == 0) {
    message(paste("No significant enrichment found for", category, "in gProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- enrichment$result %>%
    as_tibble() %>%
    mutate(Category = category,
           neglog = -log10(p_value)) %>%  # Compute -log10(p-value)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(term_name, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Perform analysis for Reactome and KEGG using ClusterProfiler
cluster_reactome <- process_clusterProfiler(
  gene_set = prob_1_0.1,
  background = background,
  category = "Reactome",
  color = "#2E86C1",
  y_title = "Reactome Pathways"
)

cluster_kegg <- process_clusterProfiler(
  gene_set = prob_1_0.1,
  background = background,
  category = "KEGG",
  color = "#28B463",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for ClusterProfiler
if (!is.null(cluster_reactome) && !is.null(cluster_kegg)) {
  cluster_combined <- cluster_reactome / cluster_kegg
} else if (!is.null(cluster_reactome)) {
  cluster_combined <- cluster_reactome
} else if (!is.null(cluster_kegg)) {
  cluster_combined <- cluster_kegg
} else {
  cluster_combined <- NULL
}

# Perform analysis for Reactome and KEGG using GProfiler
gprofiler_reactome <- process_gprofiler(
  gene_set = prob_1_0.1,
  background = background,
  category = "REAC",  # Corrected category for Reactome in gProfiler
  color = "#D35400",
  y_title = "Reactome Pathways"
)

gprofiler_kegg <- process_gprofiler(
  gene_set = prob_1_0.1,
  background = background,
  category = "KEGG",
  color = "#F39C12",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for GProfiler
if (!is.null(gprofiler_reactome) && !is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_reactome / gprofiler_kegg
} else if (!is.null(gprofiler_reactome)) {
  gprofiler_combined <- gprofiler_reactome
} else if (!is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_kegg
} else {
  gprofiler_combined <- NULL
}

# Display plots (if they are not NULL)
if (!is.null(cluster_combined)) print(cluster_combined)

Version Author Date
df65b82 sayanpaul01 2025-06-04
84d7de5 sayanpaul01 2025-06-03
87137ac sayanpaul01 2025-02-27
if (!is.null(gprofiler_combined)) print(gprofiler_combined)

Version Author Date
84d7de5 sayanpaul01 2025-06-03
87137ac sayanpaul01 2025-02-27

📌 CX-DOX mid-late response (0.1 µM)

📌 GO Enrichment Clusterprofiler

# 📦 Load Libraries
library(tidyverse)
library(data.table)
library(patchwork)

# 📁 Load GO CSV for CX-DOX mid-late response (0.1)
go_df <- fread("data/BP/CorMotif_Terms_Combined/GO_All_CX-DOX_mid-late_response_(0.1).csv")

# 🧠 Convert and filter (only adj p < 0.05)
process_enrichment_tibble <- function(df, ontology, category_label) {
  df %>%
    filter(Ontology == ontology & p.adjust < 0.05) %>%
    mutate(neglog = -log(p.adjust)) %>%
    arrange(desc(neglog)) %>%
    slice(1:20) %>%
    mutate(Category = category_label)
}

# Create tibbles for each GO class
BP_Tibble <- process_enrichment_tibble(go_df, "BP", "Biological Process")
MF_Tibble <- process_enrichment_tibble(go_df, "MF", "Molecular Function")
CC_Tibble <- process_enrichment_tibble(go_df, "CC", "Cellular Component")

# 📊 Plot function
process_enrichment_plot <- function(tibble, title, color) {
  ggplot(tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log(p-adjust)", y = title,
      title = paste("Top 20", title, "GO Terms (adj p < 0.05)")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, linewidth = 0.3)
    ) +
    xlim(0, max(tibble$neglog, na.rm = TRUE) + 1)
}

# 🔧 Plot for each GO category
plot_BP <- process_enrichment_plot(BP_Tibble, "Biological Process", "#2E86C1")
plot_MF <- process_enrichment_plot(MF_Tibble, "Molecular Function", "#28B463")
plot_CC <- process_enrichment_plot(CC_Tibble, "Cellular Component", "#D35400")

# 🧩 Combine plots
combined_plot <- plot_BP / plot_MF / plot_CC
combined_plot

Version Author Date
84d7de5 sayanpaul01 2025-06-03
87137ac sayanpaul01 2025-02-27

📌 GO Enrichment g:Profiler

# Load the gprofiler2 package
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)

# Perform GO enrichment analysis with gprofiler2
gost_results <- gost(
  query = prob_2_0.1,       
  organism = "hsapiens",   # Human organism
  user_threshold = 0.05,   # Adjusted p-value cutoff
  correction_method = "fdr", # Multiple testing correction
  domain_scope = "custom", # Use custom background
  custom_bg = background,    # Background set of genes
  sources = c("GO:BP", "GO:MF", "GO:CC") # Analyze GO categories
)

# Check if enrichment results exist
if (is.null(gost_results$result) || nrow(gost_results$result) == 0) {
  # If no enriched terms, create a placeholder dataframe
  combined_results <- tibble(
    term_name = "No enriched terms",
    p.adjust = NA,
    source = "N/A",
    Category = "N/A"
  )
} else {
  # Convert results to a data frame
  gost_results_df <- gost_results$result

  # Add a column for adjusted p-value
  gost_results_df <- gost_results_df %>%
    rename(p.adjust = p_value)

  # Separate results for BP, MF, and CC
  BP_results <- gost_results_df %>%
    filter(source == "GO:BP") %>%
    mutate(Category = "Biological Process")

  MF_results <- gost_results_df %>%
    filter(source == "GO:MF") %>%
    mutate(Category = "Molecular Function")

  CC_results <- gost_results_df %>%
    filter(source == "GO:CC") %>%
    mutate(Category = "Cellular Component")

  # Select the top 20 terms by adjusted p-value for each category
  top_BP <- BP_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_MF <- MF_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_CC <- CC_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  # Combine all categories
  combined_results <- bind_rows(top_BP, top_MF, top_CC)
}

# Ensure all columns are atomic types for CSV export
combined_results_clean <- combined_results %>%
  mutate(across(everything(), ~ if (is.list(.)) sapply(., toString) else .))

# Function for plotting top terms
plot_gprofiler_results <- function(data, title, color) {
  ggplot(data, aes(x = -log10(p.adjust), y = reorder(term_name, -log10(p.adjust)))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log10(Adjusted p-value)",
      y = title,
      title = paste("Top 20", title, "GO Terms")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, size = 0.3)
    )
}

# Check if there are enrichment terms to plot
if (nrow(combined_results) == 1 && combined_results$term_name == "No enriched terms") {
  message("No enriched GO terms found for the input gene set.")
} else {
  # Plot the top 20 terms for each category
  plot_BP <- plot_gprofiler_results(top_BP, "Biological Process", "#2E86C1")
  plot_MF <- plot_gprofiler_results(top_MF, "Molecular Function", "#28B463")
  plot_CC <- plot_gprofiler_results(top_CC, "Cellular Component", "#D35400")

  # Combine the plots using patchwork
  combined_plot <- plot_BP / plot_MF / plot_CC

  # Display the combined plot
  combined_plot
}

Version Author Date
84d7de5 sayanpaul01 2025-06-03
87137ac sayanpaul01 2025-02-27

📌 Pathway Enrichment

# Load required libraries
library(clusterProfiler)
library(org.Hs.eg.db) # Required for enrichPathway
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)
library(ReactomePA)

# Function for ClusterProfiler Reactome & KEGG Analysis
process_clusterProfiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment based on the selected category
  if (category == "Reactome") {
    enrichment <- enrichPathway(
      gene = gene_set,
      organism = "human",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  } else if (category == "KEGG") {
    enrichment <- enrichKEGG(
      gene = gene_set,
      organism = "hsa",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  }
  
  # Check if enrichment results exist
  if (is.null(enrichment) || nrow(as.data.frame(enrichment)) == 0) {
    message(paste("No significant enrichment found for", category, "in ClusterProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- as_tibble(as.data.frame(enrichment)) %>%
    mutate(Category = category,
           neglog = -log10(p.adjust)) %>%  # Compute -log10(p.adjust)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(Adjusted p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Function for gProfiler Reactome & KEGG Analysis
process_gprofiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment using gprofiler2
  enrichment <- gost(
    query = gene_set,
    organism = "hsapiens",
    user_threshold = 0.05,
    correction_method = "fdr",
    domain_scope = "custom",
    custom_bg = background,
    sources = category # Either "REAC" or "KEGG"
  )
  
  # Check if enrichment results exist
  if (is.null(enrichment$result) || nrow(enrichment$result) == 0) {
    message(paste("No significant enrichment found for", category, "in gProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- enrichment$result %>%
    as_tibble() %>%
    mutate(Category = category,
           neglog = -log10(p_value)) %>%  # Compute -log10(p-value)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(term_name, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Perform analysis for Reactome and KEGG using ClusterProfiler
cluster_reactome <- process_clusterProfiler(
  gene_set = prob_2_0.1,
  background = background,
  category = "Reactome",
  color = "#2E86C1",
  y_title = "Reactome Pathways"
)

cluster_kegg <- process_clusterProfiler(
  gene_set = prob_2_0.1,
  background = background,
  category = "KEGG",
  color = "#28B463",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for ClusterProfiler
if (!is.null(cluster_reactome) && !is.null(cluster_kegg)) {
  cluster_combined <- cluster_reactome / cluster_kegg
} else if (!is.null(cluster_reactome)) {
  cluster_combined <- cluster_reactome
} else if (!is.null(cluster_kegg)) {
  cluster_combined <- cluster_kegg
} else {
  cluster_combined <- NULL
}

# Perform analysis for Reactome and KEGG using GProfiler
gprofiler_reactome <- process_gprofiler(
  gene_set = prob_2_0.1,
  background = background,
  category = "REAC",  # Corrected category for Reactome in gProfiler
  color = "#D35400",
  y_title = "Reactome Pathways"
)

gprofiler_kegg <- process_gprofiler(
  gene_set = prob_2_0.1,
  background = background,
  category = "KEGG",
  color = "#F39C12",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for GProfiler
if (!is.null(gprofiler_reactome) && !is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_reactome / gprofiler_kegg
} else if (!is.null(gprofiler_reactome)) {
  gprofiler_combined <- gprofiler_reactome
} else if (!is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_kegg
} else {
  gprofiler_combined <- NULL
}

# Display plots (if they are not NULL)
if (!is.null(cluster_combined)) print(cluster_combined)

Version Author Date
df65b82 sayanpaul01 2025-06-04
84d7de5 sayanpaul01 2025-06-03
cf95313 sayanpaul01 2025-03-10
87137ac sayanpaul01 2025-02-27
if (!is.null(gprofiler_combined)) print(gprofiler_combined)

Version Author Date
84d7de5 sayanpaul01 2025-06-03
87137ac sayanpaul01 2025-02-27

📌 DOX only mid-late (0.1 µM)

📌 GO Enrichment Clusterprofiler

# 📦 Load Required Libraries
library(tidyverse)
library(data.table)
library(patchwork)

# 📁 Load GO Enrichment CSV
go_df <- fread("data/BP/CorMotif_Terms_Combined/GO_All_DOX_only_mid-late_(0.1).csv")

# 🧠 Convert and filter (only adj p < 0.05)
process_enrichment_tibble <- function(df, ontology, category_label) {
  df %>%
    filter(Ontology == ontology & p.adjust < 0.05) %>%
    mutate(neglog = -log(p.adjust)) %>%
    arrange(desc(neglog)) %>%
    slice(1:20) %>%
    mutate(Category = category_label)
}

# Create tibbles for each GO class
BP_Tibble <- process_enrichment_tibble(go_df, "BP", "Biological Process")
MF_Tibble <- process_enrichment_tibble(go_df, "MF", "Molecular Function")
CC_Tibble <- process_enrichment_tibble(go_df, "CC", "Cellular Component")

# 📊 Plot function
process_enrichment_plot <- function(tibble, title, color) {
  ggplot(tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log(p-adjust)", y = title,
      title = paste("Top 20", title, "GO Terms (adj p < 0.05)")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, linewidth = 0.3)
    ) +
    xlim(0, max(tibble$neglog, na.rm = TRUE) + 1)
}

# 🔧 Plot for each GO category
plot_BP <- process_enrichment_plot(BP_Tibble, "Biological Process", "#2E86C1")
Warning in max(tibble$neglog, na.rm = TRUE): no non-missing arguments to max;
returning -Inf
plot_MF <- process_enrichment_plot(MF_Tibble, "Molecular Function", "#28B463")
plot_CC <- process_enrichment_plot(CC_Tibble, "Cellular Component", "#D35400")

# 🧩 Combine plots
combined_plot <- plot_BP / plot_MF / plot_CC
combined_plot

Version Author Date
6484005 sayanpaul01 2025-02-27

📌 GO Enrichment g:Profiler

# Load the gprofiler2 package
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)

# Perform GO enrichment analysis with gprofiler2
gost_results <- gost(
  query = prob_3_0.1,           # List of input genes (prob_all_1)
  organism = "hsapiens",   # Human organism
  user_threshold = 0.05,   # Adjusted p-value cutoff
  correction_method = "fdr", # Multiple testing correction
  domain_scope = "custom", # Use custom background
  custom_bg = background,    # Background set of genes
  sources = c("GO:BP", "GO:MF", "GO:CC") # Analyze GO categories
)

# Check if enrichment results exist
if (is.null(gost_results$result) || nrow(gost_results$result) == 0) {
  # If no enriched terms, create a placeholder dataframe
  combined_results <- tibble(
    term_name = "No enriched terms",
    p.adjust = NA,
    source = "N/A",
    Category = "N/A"
  )
} else {
  # Convert results to a data frame
  gost_results_df <- gost_results$result

  # Add a column for adjusted p-value
  gost_results_df <- gost_results_df %>%
    rename(p.adjust = p_value)

  # Separate results for BP, MF, and CC
  BP_results <- gost_results_df %>%
    filter(source == "GO:BP") %>%
    mutate(Category = "Biological Process")

  MF_results <- gost_results_df %>%
    filter(source == "GO:MF") %>%
    mutate(Category = "Molecular Function")

  CC_results <- gost_results_df %>%
    filter(source == "GO:CC") %>%
    mutate(Category = "Cellular Component")

  # Select the top 20 terms by adjusted p-value for each category
  top_BP <- BP_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_MF <- MF_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_CC <- CC_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  # Combine all categories
  combined_results <- bind_rows(top_BP, top_MF, top_CC)
}

# Ensure all columns are atomic types for CSV export
combined_results_clean <- combined_results %>%
  mutate(across(everything(), ~ if (is.list(.)) sapply(., toString) else .))

# Function for plotting top terms
plot_gprofiler_results <- function(data, title, color) {
  ggplot(data, aes(x = -log10(p.adjust), y = reorder(term_name, -log10(p.adjust)))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log10(Adjusted p-value)",
      y = title,
      title = paste("Top 20", title, "GO Terms")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, size = 0.3)
    )
}

# Check if there are enrichment terms to plot
if (nrow(combined_results) == 1 && combined_results$term_name == "No enriched terms") {
  message("No enriched GO terms found for the input gene set.")
} else {
  # Plot the top 20 terms for each category
  plot_BP <- plot_gprofiler_results(top_BP, "Biological Process", "#2E86C1")
  plot_MF <- plot_gprofiler_results(top_MF, "Molecular Function", "#28B463")
  plot_CC <- plot_gprofiler_results(top_CC, "Cellular Component", "#D35400")

  # Combine the plots using patchwork
  combined_plot <- plot_BP / plot_MF / plot_CC

  # Display the combined plot
  combined_plot
}

Version Author Date
84d7de5 sayanpaul01 2025-06-03
6484005 sayanpaul01 2025-02-27

📌 Pathway Enrichment

# Load required libraries
library(clusterProfiler)
library(org.Hs.eg.db) # Required for enrichPathway
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)
library(ReactomePA)

# Function for ClusterProfiler Reactome & KEGG Analysis
process_clusterProfiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment based on the selected category
  if (category == "Reactome") {
    enrichment <- enrichPathway(
      gene = gene_set,
      organism = "human",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  } else if (category == "KEGG") {
    enrichment <- enrichKEGG(
      gene = gene_set,
      organism = "hsa",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  }
  
  # Check if enrichment results exist
  if (is.null(enrichment) || nrow(as.data.frame(enrichment)) == 0) {
    message(paste("No significant enrichment found for", category, "in ClusterProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- as_tibble(as.data.frame(enrichment)) %>%
    mutate(Category = category,
           neglog = -log10(p.adjust)) %>%  # Compute -log10(p.adjust)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(Adjusted p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Function for gProfiler Reactome & KEGG Analysis
process_gprofiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment using gprofiler2
  enrichment <- gost(
    query = gene_set,
    organism = "hsapiens",
    user_threshold = 0.05,
    correction_method = "fdr",
    domain_scope = "custom",
    custom_bg = background,
    sources = category # Either "REAC" or "KEGG"
  )
  
  # Check if enrichment results exist
  if (is.null(enrichment$result) || nrow(enrichment$result) == 0) {
    message(paste("No significant enrichment found for", category, "in gProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- enrichment$result %>%
    as_tibble() %>%
    mutate(Category = category,
           neglog = -log10(p_value)) %>%  # Compute -log10(p-value)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(term_name, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Perform analysis for Reactome and KEGG using ClusterProfiler
cluster_reactome <- process_clusterProfiler(
  gene_set = prob_3_0.1,
  background = background,
  category = "Reactome",
  color = "#2E86C1",
  y_title = "Reactome Pathways"
)

cluster_kegg <- process_clusterProfiler(
  gene_set = prob_3_0.1,
  background = background,
  category = "KEGG",
  color = "#28B463",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for ClusterProfiler
if (!is.null(cluster_reactome) && !is.null(cluster_kegg)) {
  cluster_combined <- cluster_reactome / cluster_kegg
} else if (!is.null(cluster_reactome)) {
  cluster_combined <- cluster_reactome
} else if (!is.null(cluster_kegg)) {
  cluster_combined <- cluster_kegg
} else {
  cluster_combined <- NULL
}

# Perform analysis for Reactome and KEGG using GProfiler
gprofiler_reactome <- process_gprofiler(
  gene_set = prob_3_0.1,
  background = background,
  category = "REAC",  # Corrected category for Reactome in gProfiler
  color = "#D35400",
  y_title = "Reactome Pathways"
)

gprofiler_kegg <- process_gprofiler(
  gene_set = prob_3_0.1,
  background = background,
  category = "KEGG",
  color = "#F39C12",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for GProfiler
if (!is.null(gprofiler_reactome) && !is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_reactome / gprofiler_kegg
} else if (!is.null(gprofiler_reactome)) {
  gprofiler_combined <- gprofiler_reactome
} else if (!is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_kegg
} else {
  gprofiler_combined <- NULL
}

# Display plots (if they are not NULL)
if (!is.null(cluster_combined)) print(cluster_combined)

Version Author Date
df65b82 sayanpaul01 2025-06-04
84d7de5 sayanpaul01 2025-06-03
cf95313 sayanpaul01 2025-03-10
6484005 sayanpaul01 2025-02-27
if (!is.null(gprofiler_combined)) print(gprofiler_combined)

Version Author Date
84d7de5 sayanpaul01 2025-06-03
6484005 sayanpaul01 2025-02-27

📌 0.5 Micromolar

📌 Read and Process Data

# Load the saved datasets
prob_1_0.5 <- read.csv("data/prob_1_0.5.csv")$Entrez_ID
prob_2_0.5 <- read.csv("data/prob_2_0.5.csv")$Entrez_ID
prob_3_0.5 <- read.csv("data/prob_3_0.5.csv")$Entrez_ID
prob_4_0.5 <- read.csv("data/prob_4_0.5.csv")$Entrez_ID
prob_5_0.5 <- read.csv("data/prob_5_0.5.csv")$Entrez_ID


CX_0.1_3 <- read.csv("data/DEGs/Toptable_CX_0.1_3.csv")
background<-as.character(CX_0.1_3$Entrez_ID)

📌 Non response (0.5 µM)

📌 GO Enrichment Clusterprofiler

# 📦 Load Required Libraries
library(tidyverse)
library(data.table)
library(patchwork)

# 📁 Load Enrichment File
go_df <- fread("data/BP/CorMotif_Terms_Combined/GO_All_Non_response_(0.5).csv")

# 🧠 Process Enrichment (only adj p < 0.05)
process_enrichment_tibble <- function(df, ontology, category_label) {
  df %>%
    filter(Ontology == ontology & p.adjust < 0.05) %>%
    mutate(neglog = -log(p.adjust)) %>%
    arrange(desc(neglog)) %>%
    slice(1:20) %>%
    mutate(Category = category_label)
}

# ⛏️ Extract each GO class
BP_Tibble <- process_enrichment_tibble(go_df, "BP", "Biological Process")
MF_Tibble <- process_enrichment_tibble(go_df, "MF", "Molecular Function")
CC_Tibble <- process_enrichment_tibble(go_df, "CC", "Cellular Component")

# 📊 Plotting Function
process_enrichment_plot <- function(tibble, title, color) {
  ggplot(tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log(p-adjust)", y = title,
      title = paste("Top 20", title, "GO Terms (adj p < 0.05)")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, linewidth = 0.3)
    ) +
    xlim(0, max(tibble$neglog, na.rm = TRUE) + 1)
}

# 🎨 Generate GO Plots
plot_BP <- process_enrichment_plot(BP_Tibble, "Biological Process", "#2E86C1")
plot_MF <- process_enrichment_plot(MF_Tibble, "Molecular Function", "#28B463")
plot_CC <- process_enrichment_plot(CC_Tibble, "Cellular Component", "#D35400")

# 🧩 Combine & Show
combined_plot <- plot_BP / plot_MF / plot_CC
combined_plot

Version Author Date
11895c8 sayanpaul01 2025-02-27

📌 GO Enrichment g:Profiler

# Load the gprofiler2 package
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)

# Perform GO enrichment analysis with gprofiler2
gost_results <- gost(
  query = prob_1_0.5,           # List of input genes (prob_all_1)
  organism = "hsapiens",   # Human organism
  user_threshold = 0.05,   # Adjusted p-value cutoff
  correction_method = "fdr", # Multiple testing correction
  domain_scope = "custom", # Use custom background
  custom_bg = background,    # Background set of genes
  sources = c("GO:BP", "GO:MF", "GO:CC") # Analyze GO categories
)

# Check if enrichment results exist
if (is.null(gost_results$result) || nrow(gost_results$result) == 0) {
  # If no enriched terms, create a placeholder dataframe
  combined_results <- tibble(
    term_name = "No enriched terms",
    p.adjust = NA,
    source = "N/A",
    Category = "N/A"
  )
} else {
  # Convert results to a data frame
  gost_results_df <- gost_results$result

  # Add a column for adjusted p-value
  gost_results_df <- gost_results_df %>%
    rename(p.adjust = p_value)

  # Separate results for BP, MF, and CC
  BP_results <- gost_results_df %>%
    filter(source == "GO:BP") %>%
    mutate(Category = "Biological Process")

  MF_results <- gost_results_df %>%
    filter(source == "GO:MF") %>%
    mutate(Category = "Molecular Function")

  CC_results <- gost_results_df %>%
    filter(source == "GO:CC") %>%
    mutate(Category = "Cellular Component")

  # Select the top 20 terms by adjusted p-value for each category
  top_BP <- BP_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_MF <- MF_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_CC <- CC_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  # Combine all categories
  combined_results <- bind_rows(top_BP, top_MF, top_CC)
}

# Ensure all columns are atomic types for CSV export
combined_results_clean <- combined_results %>%
  mutate(across(everything(), ~ if (is.list(.)) sapply(., toString) else .))

# Function for plotting top terms
plot_gprofiler_results <- function(data, title, color) {
  ggplot(data, aes(x = -log10(p.adjust), y = reorder(term_name, -log10(p.adjust)))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log10(Adjusted p-value)",
      y = title,
      title = paste("Top 20", title, "GO Terms")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, size = 0.3)
    )
}

# Check if there are enrichment terms to plot
if (nrow(combined_results) == 1 && combined_results$term_name == "No enriched terms") {
  message("No enriched GO terms found for the input gene set.")
} else {
  # Plot the top 20 terms for each category
  plot_BP <- plot_gprofiler_results(top_BP, "Biological Process", "#2E86C1")
  plot_MF <- plot_gprofiler_results(top_MF, "Molecular Function", "#28B463")
  plot_CC <- plot_gprofiler_results(top_CC, "Cellular Component", "#D35400")

  # Combine the plots using patchwork
  combined_plot <- plot_BP / plot_MF / plot_CC

  # Display the combined plot
  combined_plot
}

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 Pathway Enrichment

# Load required libraries
library(clusterProfiler)
library(org.Hs.eg.db) # Required for enrichPathway
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)
library(ReactomePA)

# Function for ClusterProfiler Reactome & KEGG Analysis
process_clusterProfiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment based on the selected category
  if (category == "Reactome") {
    enrichment <- enrichPathway(
      gene = gene_set,
      organism = "human",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  } else if (category == "KEGG") {
    enrichment <- enrichKEGG(
      gene = gene_set,
      organism = "hsa",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  }
  
  # Check if enrichment results exist
  if (is.null(enrichment) || nrow(as.data.frame(enrichment)) == 0) {
    message(paste("No significant enrichment found for", category, "in ClusterProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- as_tibble(as.data.frame(enrichment)) %>%
    mutate(Category = category,
           neglog = -log10(p.adjust)) %>%  # Compute -log10(p.adjust)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(Adjusted p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Function for gProfiler Reactome & KEGG Analysis
process_gprofiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment using gprofiler2
  enrichment <- gost(
    query = gene_set,
    organism = "hsapiens",
    user_threshold = 0.05,
    correction_method = "fdr",
    domain_scope = "custom",
    custom_bg = background,
    sources = category # Either "REAC" or "KEGG"
  )
  
  # Check if enrichment results exist
  if (is.null(enrichment$result) || nrow(enrichment$result) == 0) {
    message(paste("No significant enrichment found for", category, "in gProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- enrichment$result %>%
    as_tibble() %>%
    mutate(Category = category,
           neglog = -log10(p_value)) %>%  # Compute -log10(p-value)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(term_name, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Perform analysis for Reactome and KEGG using ClusterProfiler
cluster_reactome <- process_clusterProfiler(
  gene_set = prob_1_0.5,
  background = background,
  category = "Reactome",
  color = "#2E86C1",
  y_title = "Reactome Pathways"
)

cluster_kegg <- process_clusterProfiler(
  gene_set = prob_1_0.5,
  background = background,
  category = "KEGG",
  color = "#28B463",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for ClusterProfiler
if (!is.null(cluster_reactome) && !is.null(cluster_kegg)) {
  cluster_combined <- cluster_reactome / cluster_kegg
} else if (!is.null(cluster_reactome)) {
  cluster_combined <- cluster_reactome
} else if (!is.null(cluster_kegg)) {
  cluster_combined <- cluster_kegg
} else {
  cluster_combined <- NULL
}

# Perform analysis for Reactome and KEGG using GProfiler
gprofiler_reactome <- process_gprofiler(
  gene_set = prob_1_0.5,
  background = background,
  category = "REAC",  # Corrected category for Reactome in gProfiler
  color = "#D35400",
  y_title = "Reactome Pathways"
)

gprofiler_kegg <- process_gprofiler(
  gene_set = prob_1_0.5,
  background = background,
  category = "KEGG",
  color = "#F39C12",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for GProfiler
if (!is.null(gprofiler_reactome) && !is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_reactome / gprofiler_kegg
} else if (!is.null(gprofiler_reactome)) {
  gprofiler_combined <- gprofiler_reactome
} else if (!is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_kegg
} else {
  gprofiler_combined <- NULL
}

# Display plots (if they are not NULL)
if (!is.null(cluster_combined)) print(cluster_combined)

Version Author Date
df65b82 sayanpaul01 2025-06-04
84d7de5 sayanpaul01 2025-06-03
cf95313 sayanpaul01 2025-03-10
11895c8 sayanpaul01 2025-02-27
if (!is.null(gprofiler_combined)) print(gprofiler_combined)

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 DOX-specific response (0.5 µM)

📌 GO Enrichment Clusterprofiler

# 📦 Load Required Libraries
library(tidyverse)
library(data.table)
library(patchwork)

# 📁 Load Enrichment File
go_df <- fread("data/BP/CorMotif_Terms_Combined/GO_All_DOX_specific_response_(0.5).csv")

# 🧠 Process Enrichment (only adj p < 0.05)
process_enrichment_tibble <- function(df, ontology, category_label) {
  df %>%
    filter(Ontology == ontology & p.adjust < 0.05) %>%
    mutate(neglog = -log(p.adjust)) %>%
    arrange(desc(neglog)) %>%
    slice(1:20) %>%
    mutate(Category = category_label)
}

# ⛏️ Extract each GO class
BP_Tibble <- process_enrichment_tibble(go_df, "BP", "Biological Process")
MF_Tibble <- process_enrichment_tibble(go_df, "MF", "Molecular Function")
CC_Tibble <- process_enrichment_tibble(go_df, "CC", "Cellular Component")

# 📊 Plotting Function
process_enrichment_plot <- function(tibble, title, color) {
  ggplot(tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log(p-adjust)", y = title,
      title = paste("Top 20", title, "GO Terms (adj p < 0.05)")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, linewidth = 0.3)
    ) +
    xlim(0, max(tibble$neglog, na.rm = TRUE) + 1)
}

# 🎨 Generate GO Plots
plot_BP <- process_enrichment_plot(BP_Tibble, "Biological Process", "#2E86C1")
Warning in max(tibble$neglog, na.rm = TRUE): no non-missing arguments to max;
returning -Inf
plot_MF <- process_enrichment_plot(MF_Tibble, "Molecular Function", "#28B463")
plot_CC <- process_enrichment_plot(CC_Tibble, "Cellular Component", "#D35400")

# 🧩 Combine & Show
combined_plot <- plot_BP / plot_MF / plot_CC
combined_plot

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 GO Enrichment g:Profiler

# Load the gprofiler2 package
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)

# Perform GO enrichment analysis with gprofiler2
gost_results <- gost(
  query = prob_2_0.5,           # List of input genes (prob_all_1)
  organism = "hsapiens",   # Human organism
  user_threshold = 0.05,   # Adjusted p-value cutoff
  correction_method = "fdr", # Multiple testing correction
  domain_scope = "custom", # Use custom background
  custom_bg = background,    # Background set of genes
  sources = c("GO:BP", "GO:MF", "GO:CC") # Analyze GO categories
)

# Check if enrichment results exist
if (is.null(gost_results$result) || nrow(gost_results$result) == 0) {
  # If no enriched terms, create a placeholder dataframe
  combined_results <- tibble(
    term_name = "No enriched terms",
    p.adjust = NA,
    source = "N/A",
    Category = "N/A"
  )
} else {
  # Convert results to a data frame
  gost_results_df <- gost_results$result

  # Add a column for adjusted p-value
  gost_results_df <- gost_results_df %>%
    rename(p.adjust = p_value)

  # Separate results for BP, MF, and CC
  BP_results <- gost_results_df %>%
    filter(source == "GO:BP") %>%
    mutate(Category = "Biological Process")

  MF_results <- gost_results_df %>%
    filter(source == "GO:MF") %>%
    mutate(Category = "Molecular Function")

  CC_results <- gost_results_df %>%
    filter(source == "GO:CC") %>%
    mutate(Category = "Cellular Component")

  # Select the top 20 terms by adjusted p-value for each category
  top_BP <- BP_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_MF <- MF_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_CC <- CC_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  # Combine all categories
  combined_results <- bind_rows(top_BP, top_MF, top_CC)
}

# Ensure all columns are atomic types for CSV export
combined_results_clean <- combined_results %>%
  mutate(across(everything(), ~ if (is.list(.)) sapply(., toString) else .))

# Function for plotting top terms
plot_gprofiler_results <- function(data, title, color) {
  ggplot(data, aes(x = -log10(p.adjust), y = reorder(term_name, -log10(p.adjust)))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log10(Adjusted p-value)",
      y = title,
      title = paste("Top 20", title, "GO Terms")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, size = 0.3)
    )
}

# Check if there are enrichment terms to plot
if (nrow(combined_results) == 1 && combined_results$term_name == "No enriched terms") {
  message("No enriched GO terms found for the input gene set.")
} else {
  # Plot the top 20 terms for each category
  plot_BP <- plot_gprofiler_results(top_BP, "Biological Process", "#2E86C1")
  plot_MF <- plot_gprofiler_results(top_MF, "Molecular Function", "#28B463")
  plot_CC <- plot_gprofiler_results(top_CC, "Cellular Component", "#D35400")

  # Combine the plots using patchwork
  combined_plot <- plot_BP / plot_MF / plot_CC

  # Display the combined plot
  combined_plot
}

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 Pathway Enrichment

# Load required libraries
library(clusterProfiler)
library(org.Hs.eg.db) # Required for enrichPathway
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)
library(ReactomePA)

# Function for ClusterProfiler Reactome & KEGG Analysis
process_clusterProfiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment based on the selected category
  if (category == "Reactome") {
    enrichment <- enrichPathway(
      gene = gene_set,
      organism = "human",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  } else if (category == "KEGG") {
    enrichment <- enrichKEGG(
      gene = gene_set,
      organism = "hsa",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  }
  
  # Check if enrichment results exist
  if (is.null(enrichment) || nrow(as.data.frame(enrichment)) == 0) {
    message(paste("No significant enrichment found for", category, "in ClusterProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- as_tibble(as.data.frame(enrichment)) %>%
    mutate(Category = category,
           neglog = -log10(p.adjust)) %>%  # Compute -log10(p.adjust)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(Adjusted p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Function for gProfiler Reactome & KEGG Analysis
process_gprofiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment using gprofiler2
  enrichment <- gost(
    query = gene_set,
    organism = "hsapiens",
    user_threshold = 0.05,
    correction_method = "fdr",
    domain_scope = "custom",
    custom_bg = background,
    sources = category # Either "REAC" or "KEGG"
  )
  
  # Check if enrichment results exist
  if (is.null(enrichment$result) || nrow(enrichment$result) == 0) {
    message(paste("No significant enrichment found for", category, "in gProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- enrichment$result %>%
    as_tibble() %>%
    mutate(Category = category,
           neglog = -log10(p_value)) %>%  # Compute -log10(p-value)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(term_name, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Perform analysis for Reactome and KEGG using ClusterProfiler
cluster_reactome <- process_clusterProfiler(
  gene_set = prob_2_0.5,
  background = background,
  category = "Reactome",
  color = "#2E86C1",
  y_title = "Reactome Pathways"
)

cluster_kegg <- process_clusterProfiler(
  gene_set = prob_2_0.5,
  background = background,
  category = "KEGG",
  color = "#28B463",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for ClusterProfiler
if (!is.null(cluster_reactome) && !is.null(cluster_kegg)) {
  cluster_combined <- cluster_reactome / cluster_kegg
} else if (!is.null(cluster_reactome)) {
  cluster_combined <- cluster_reactome
} else if (!is.null(cluster_kegg)) {
  cluster_combined <- cluster_kegg
} else {
  cluster_combined <- NULL
}

# Perform analysis for Reactome and KEGG using GProfiler
gprofiler_reactome <- process_gprofiler(
  gene_set = prob_2_0.5,
  background = background,
  category = "REAC",  # Corrected category for Reactome in gProfiler
  color = "#D35400",
  y_title = "Reactome Pathways"
)

gprofiler_kegg <- process_gprofiler(
  gene_set = prob_2_0.5,
  background = background,
  category = "KEGG",
  color = "#F39C12",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for GProfiler
if (!is.null(gprofiler_reactome) && !is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_reactome / gprofiler_kegg
} else if (!is.null(gprofiler_reactome)) {
  gprofiler_combined <- gprofiler_reactome
} else if (!is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_kegg
} else {
  gprofiler_combined <- NULL
}

# Display plots (if they are not NULL)
if (!is.null(cluster_combined)) print(cluster_combined)
if (!is.null(gprofiler_combined)) print(gprofiler_combined)

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 DOX only mid-late response (0.5 µM)

📌 GO Enrichment Clusterprofiler

# 📦 Load Required Libraries
library(tidyverse)
library(data.table)
library(patchwork)

# 📁 Load Enrichment File
go_df <- fread("data/BP/CorMotif_Terms_Combined/GO_All_DOX_only_mid-late_response_(0.5).csv")

# 🧠 Process Enrichment (only adj p < 0.05)
process_enrichment_tibble <- function(df, ontology, category_label) {
  df %>%
    filter(Ontology == ontology & p.adjust < 0.05) %>%
    mutate(neglog = -log(p.adjust)) %>%
    arrange(desc(neglog)) %>%
    slice(1:20) %>%
    mutate(Category = category_label)
}

# ⛏️ Extract each GO class
BP_Tibble <- process_enrichment_tibble(go_df, "BP", "Biological Process")
MF_Tibble <- process_enrichment_tibble(go_df, "MF", "Molecular Function")
CC_Tibble <- process_enrichment_tibble(go_df, "CC", "Cellular Component")

# 📊 Plotting Function
process_enrichment_plot <- function(tibble, title, color) {
  ggplot(tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log(p-adjust)", y = title,
      title = paste("Top 20", title, "GO Terms (adj p < 0.05)")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, linewidth = 0.3)
    ) +
    xlim(0, max(tibble$neglog, na.rm = TRUE) + 1)
}

# 🎨 Generate GO Plots
plot_BP <- process_enrichment_plot(BP_Tibble, "Biological Process", "#2E86C1")
plot_MF <- process_enrichment_plot(MF_Tibble, "Molecular Function", "#28B463")
Warning in max(tibble$neglog, na.rm = TRUE): no non-missing arguments to max;
returning -Inf
plot_CC <- process_enrichment_plot(CC_Tibble, "Cellular Component", "#D35400")
Warning in max(tibble$neglog, na.rm = TRUE): no non-missing arguments to max;
returning -Inf
# 🧩 Combine & Show
combined_plot <- plot_BP / plot_MF / plot_CC
combined_plot

Version Author Date
11895c8 sayanpaul01 2025-02-27

📌 GO Enrichment g:Profiler

# Load the gprofiler2 package
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)

# Perform GO enrichment analysis with gprofiler2
gost_results <- gost(
  query = prob_3_0.5,           # List of input genes (prob_all_1)
  organism = "hsapiens",   # Human organism
  user_threshold = 0.05,   # Adjusted p-value cutoff
  correction_method = "fdr", # Multiple testing correction
  domain_scope = "custom", # Use custom background
  custom_bg = background,    # Background set of genes
  sources = c("GO:BP", "GO:MF", "GO:CC") # Analyze GO categories
)

# Check if enrichment results exist
if (is.null(gost_results$result) || nrow(gost_results$result) == 0) {
  # If no enriched terms, create a placeholder dataframe
  combined_results <- tibble(
    term_name = "No enriched terms",
    p.adjust = NA,
    source = "N/A",
    Category = "N/A"
  )
} else {
  # Convert results to a data frame
  gost_results_df <- gost_results$result

  # Add a column for adjusted p-value
  gost_results_df <- gost_results_df %>%
    rename(p.adjust = p_value)

  # Separate results for BP, MF, and CC
  BP_results <- gost_results_df %>%
    filter(source == "GO:BP") %>%
    mutate(Category = "Biological Process")

  MF_results <- gost_results_df %>%
    filter(source == "GO:MF") %>%
    mutate(Category = "Molecular Function")

  CC_results <- gost_results_df %>%
    filter(source == "GO:CC") %>%
    mutate(Category = "Cellular Component")

  # Select the top 20 terms by adjusted p-value for each category
  top_BP <- BP_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_MF <- MF_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_CC <- CC_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  # Combine all categories
  combined_results <- bind_rows(top_BP, top_MF, top_CC)
}

# Ensure all columns are atomic types for CSV export
combined_results_clean <- combined_results %>%
  mutate(across(everything(), ~ if (is.list(.)) sapply(., toString) else .))

# Function for plotting top terms
plot_gprofiler_results <- function(data, title, color) {
  ggplot(data, aes(x = -log10(p.adjust), y = reorder(term_name, -log10(p.adjust)))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log10(Adjusted p-value)",
      y = title,
      title = paste("Top 20", title, "GO Terms")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, size = 0.3)
    )
}

# Check if there are enrichment terms to plot
if (nrow(combined_results) == 1 && combined_results$term_name == "No enriched terms") {
  message("No enriched GO terms found for the input gene set.")
} else {
  # Plot the top 20 terms for each category
  plot_BP <- plot_gprofiler_results(top_BP, "Biological Process", "#2E86C1")
  plot_MF <- plot_gprofiler_results(top_MF, "Molecular Function", "#28B463")
  plot_CC <- plot_gprofiler_results(top_CC, "Cellular Component", "#D35400")

  # Combine the plots using patchwork
  combined_plot <- plot_BP / plot_MF / plot_CC

  # Display the combined plot
  combined_plot
}

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 Pathway Enrichment

# Load required libraries
library(clusterProfiler)
library(org.Hs.eg.db) # Required for enrichPathway
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)
library(ReactomePA)

# Function for ClusterProfiler Reactome & KEGG Analysis
process_clusterProfiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment based on the selected category
  if (category == "Reactome") {
    enrichment <- enrichPathway(
      gene = gene_set,
      organism = "human",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  } else if (category == "KEGG") {
    enrichment <- enrichKEGG(
      gene = gene_set,
      organism = "hsa",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  }
  
  # Check if enrichment results exist
  if (is.null(enrichment) || nrow(as.data.frame(enrichment)) == 0) {
    message(paste("No significant enrichment found for", category, "in ClusterProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- as_tibble(as.data.frame(enrichment)) %>%
    mutate(Category = category,
           neglog = -log10(p.adjust)) %>%  # Compute -log10(p.adjust)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(Adjusted p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Function for gProfiler Reactome & KEGG Analysis
process_gprofiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment using gprofiler2
  enrichment <- gost(
    query = gene_set,
    organism = "hsapiens",
    user_threshold = 0.05,
    correction_method = "fdr",
    domain_scope = "custom",
    custom_bg = background,
    sources = category # Either "REAC" or "KEGG"
  )
  
  # Check if enrichment results exist
  if (is.null(enrichment$result) || nrow(enrichment$result) == 0) {
    message(paste("No significant enrichment found for", category, "in gProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- enrichment$result %>%
    as_tibble() %>%
    mutate(Category = category,
           neglog = -log10(p_value)) %>%  # Compute -log10(p-value)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(term_name, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Perform analysis for Reactome and KEGG using ClusterProfiler
cluster_reactome <- process_clusterProfiler(
  gene_set = prob_3_0.5,
  background = background,
  category = "Reactome",
  color = "#2E86C1",
  y_title = "Reactome Pathways"
)

cluster_kegg <- process_clusterProfiler(
  gene_set = prob_3_0.5,
  background = background,
  category = "KEGG",
  color = "#28B463",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for ClusterProfiler
if (!is.null(cluster_reactome) && !is.null(cluster_kegg)) {
  cluster_combined <- cluster_reactome / cluster_kegg
} else if (!is.null(cluster_reactome)) {
  cluster_combined <- cluster_reactome
} else if (!is.null(cluster_kegg)) {
  cluster_combined <- cluster_kegg
} else {
  cluster_combined <- NULL
}

# Perform analysis for Reactome and KEGG using GProfiler
gprofiler_reactome <- process_gprofiler(
  gene_set = prob_3_0.5,
  background = background,
  category = "REAC",  # Corrected category for Reactome in gProfiler
  color = "#D35400",
  y_title = "Reactome Pathways"
)

gprofiler_kegg <- process_gprofiler(
  gene_set = prob_3_0.5,
  background = background,
  category = "KEGG",
  color = "#F39C12",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for GProfiler
if (!is.null(gprofiler_reactome) && !is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_reactome / gprofiler_kegg
} else if (!is.null(gprofiler_reactome)) {
  gprofiler_combined <- gprofiler_reactome
} else if (!is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_kegg
} else {
  gprofiler_combined <- NULL
}

# Display plots (if they are not NULL)
if (!is.null(cluster_combined)) print(cluster_combined)
if (!is.null(gprofiler_combined)) print(gprofiler_combined)

📌 CX total + DOX early response (0.5 µM)

📌 GO Enrichment Clusterprofiler

# 📦 Load Required Libraries
library(tidyverse)
library(data.table)
library(patchwork)

# 📁 Load Enrichment File
go_df <- fread("data/BP/CorMotif_Terms_Combined/GO_All_CX_total_+_DOX_early_response_(0.5).csv")

# 🧠 Process Enrichment (only adj p < 0.05)
process_enrichment_tibble <- function(df, ontology, category_label) {
  df %>%
    filter(Ontology == ontology & p.adjust < 0.05) %>%
    mutate(neglog = -log(p.adjust)) %>%
    arrange(desc(neglog)) %>%
    slice(1:20) %>%
    mutate(Category = category_label)
}

# ⛏️ Extract each GO class
BP_Tibble <- process_enrichment_tibble(go_df, "BP", "Biological Process")
MF_Tibble <- process_enrichment_tibble(go_df, "MF", "Molecular Function")
CC_Tibble <- process_enrichment_tibble(go_df, "CC", "Cellular Component")

# 📊 Plotting Function
process_enrichment_plot <- function(tibble, title, color) {
  ggplot(tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log(p-adjust)", y = title,
      title = paste("Top 20", title, "GO Terms (adj p < 0.05)")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, linewidth = 0.3)
    ) +
    xlim(0, max(tibble$neglog, na.rm = TRUE) + 1)
}

# 🎨 Generate GO Plots
plot_BP <- process_enrichment_plot(BP_Tibble, "Biological Process", "#2E86C1")
plot_MF <- process_enrichment_plot(MF_Tibble, "Molecular Function", "#28B463")
plot_CC <- process_enrichment_plot(CC_Tibble, "Cellular Component", "#D35400")

# 🧩 Combine & Show
combined_plot <- plot_BP / plot_MF / plot_CC
combined_plot

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 GO Enrichment g:Profiler

# Load the gprofiler2 package
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)

# Perform GO enrichment analysis with gprofiler2
gost_results <- gost(
  query = prob_4_0.5,           # List of input genes (prob_all_1)
  organism = "hsapiens",   # Human organism
  user_threshold = 0.05,   # Adjusted p-value cutoff
  correction_method = "fdr", # Multiple testing correction
  domain_scope = "custom", # Use custom background
  custom_bg = background,    # Background set of genes
  sources = c("GO:BP", "GO:MF", "GO:CC") # Analyze GO categories
)

# Check if enrichment results exist
if (is.null(gost_results$result) || nrow(gost_results$result) == 0) {
  # If no enriched terms, create a placeholder dataframe
  combined_results <- tibble(
    term_name = "No enriched terms",
    p.adjust = NA,
    source = "N/A",
    Category = "N/A"
  )
} else {
  # Convert results to a data frame
  gost_results_df <- gost_results$result

  # Add a column for adjusted p-value
  gost_results_df <- gost_results_df %>%
    rename(p.adjust = p_value)

  # Separate results for BP, MF, and CC
  BP_results <- gost_results_df %>%
    filter(source == "GO:BP") %>%
    mutate(Category = "Biological Process")

  MF_results <- gost_results_df %>%
    filter(source == "GO:MF") %>%
    mutate(Category = "Molecular Function")

  CC_results <- gost_results_df %>%
    filter(source == "GO:CC") %>%
    mutate(Category = "Cellular Component")

  # Select the top 20 terms by adjusted p-value for each category
  top_BP <- BP_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_MF <- MF_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_CC <- CC_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  # Combine all categories
  combined_results <- bind_rows(top_BP, top_MF, top_CC)
}

# Ensure all columns are atomic types for CSV export
combined_results_clean <- combined_results %>%
  mutate(across(everything(), ~ if (is.list(.)) sapply(., toString) else .))

# Function for plotting top terms
plot_gprofiler_results <- function(data, title, color) {
  ggplot(data, aes(x = -log10(p.adjust), y = reorder(term_name, -log10(p.adjust)))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log10(Adjusted p-value)",
      y = title,
      title = paste("Top 20", title, "GO Terms")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, size = 0.3)
    )
}

# Check if there are enrichment terms to plot
if (nrow(combined_results) == 1 && combined_results$term_name == "No enriched terms") {
  message("No enriched GO terms found for the input gene set.")
} else {
  # Plot the top 20 terms for each category
  plot_BP <- plot_gprofiler_results(top_BP, "Biological Process", "#2E86C1")
  plot_MF <- plot_gprofiler_results(top_MF, "Molecular Function", "#28B463")
  plot_CC <- plot_gprofiler_results(top_CC, "Cellular Component", "#D35400")

  # Combine the plots using patchwork
  combined_plot <- plot_BP / plot_MF / plot_CC

  # Display the combined plot
  combined_plot
}

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 Pathway Enrichment

# Load required libraries
library(clusterProfiler)
library(org.Hs.eg.db) # Required for enrichPathway
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)
library(ReactomePA)

# Function for ClusterProfiler Reactome & KEGG Analysis
process_clusterProfiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment based on the selected category
  if (category == "Reactome") {
    enrichment <- enrichPathway(
      gene = gene_set,
      organism = "human",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  } else if (category == "KEGG") {
    enrichment <- enrichKEGG(
      gene = gene_set,
      organism = "hsa",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  }
  
  # Check if enrichment results exist
  if (is.null(enrichment) || nrow(as.data.frame(enrichment)) == 0) {
    message(paste("No significant enrichment found for", category, "in ClusterProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- as_tibble(as.data.frame(enrichment)) %>%
    mutate(Category = category,
           neglog = -log10(p.adjust)) %>%  # Compute -log10(p.adjust)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(Adjusted p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Function for gProfiler Reactome & KEGG Analysis
process_gprofiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment using gprofiler2
  enrichment <- gost(
    query = gene_set,
    organism = "hsapiens",
    user_threshold = 0.05,
    correction_method = "fdr",
    domain_scope = "custom",
    custom_bg = background,
    sources = category # Either "REAC" or "KEGG"
  )
  
  # Check if enrichment results exist
  if (is.null(enrichment$result) || nrow(enrichment$result) == 0) {
    message(paste("No significant enrichment found for", category, "in gProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- enrichment$result %>%
    as_tibble() %>%
    mutate(Category = category,
           neglog = -log10(p_value)) %>%  # Compute -log10(p-value)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(term_name, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Perform analysis for Reactome and KEGG using ClusterProfiler
cluster_reactome <- process_clusterProfiler(
  gene_set = prob_4_0.5,
  background = background,
  category = "Reactome",
  color = "#2E86C1",
  y_title = "Reactome Pathways"
)

cluster_kegg <- process_clusterProfiler(
  gene_set = prob_4_0.5,
  background = background,
  category = "KEGG",
  color = "#28B463",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for ClusterProfiler
if (!is.null(cluster_reactome) && !is.null(cluster_kegg)) {
  cluster_combined <- cluster_reactome / cluster_kegg
} else if (!is.null(cluster_reactome)) {
  cluster_combined <- cluster_reactome
} else if (!is.null(cluster_kegg)) {
  cluster_combined <- cluster_kegg
} else {
  cluster_combined <- NULL
}

# Perform analysis for Reactome and KEGG using GProfiler
gprofiler_reactome <- process_gprofiler(
  gene_set = prob_4_0.5,
  background = background,
  category = "REAC",  # Corrected category for Reactome in gProfiler
  color = "#D35400",
  y_title = "Reactome Pathways"
)

gprofiler_kegg <- process_gprofiler(
  gene_set = prob_4_0.5,
  background = background,
  category = "KEGG",
  color = "#F39C12",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for GProfiler
if (!is.null(gprofiler_reactome) && !is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_reactome / gprofiler_kegg
} else if (!is.null(gprofiler_reactome)) {
  gprofiler_combined <- gprofiler_reactome
} else if (!is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_kegg
} else {
  gprofiler_combined <- NULL
}

# Display plots (if they are not NULL)
if (!is.null(cluster_combined)) print(cluster_combined)

Version Author Date
df65b82 sayanpaul01 2025-06-04
84d7de5 sayanpaul01 2025-06-03
cf95313 sayanpaul01 2025-03-10
11895c8 sayanpaul01 2025-02-27
if (!is.null(gprofiler_combined)) print(gprofiler_combined)

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 DOX early + CX-DOX mid-late response (0.5 µM)

📌 GO Enrichment Clusterprofiler

# 📦 Load Required Libraries
library(tidyverse)
library(data.table)
library(patchwork)

# 📁 Load Enrichment File
go_df <- fread("data/BP/CorMotif_Terms_Combined/GO_All_DOX_early_+_CX-DOX_mid-late_response_(0.5).csv")

# 🧠 Process Enrichment (only adj p < 0.05)
process_enrichment_tibble <- function(df, ontology, category_label) {
  df %>%
    filter(Ontology == ontology & p.adjust < 0.05) %>%
    mutate(neglog = -log(p.adjust)) %>%
    arrange(desc(neglog)) %>%
    slice(1:20) %>%
    mutate(Category = category_label)
}

# ⛏️ Extract each GO class
BP_Tibble <- process_enrichment_tibble(go_df, "BP", "Biological Process")
MF_Tibble <- process_enrichment_tibble(go_df, "MF", "Molecular Function")
CC_Tibble <- process_enrichment_tibble(go_df, "CC", "Cellular Component")

# 📊 Plotting Function
process_enrichment_plot <- function(tibble, title, color) {
  ggplot(tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log(p-adjust)", y = title,
      title = paste("Top 20", title, "GO Terms (adj p < 0.05)")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, linewidth = 0.3)
    ) +
    xlim(0, max(tibble$neglog, na.rm = TRUE) + 1)
}

# 🎨 Generate GO Plots
plot_BP <- process_enrichment_plot(BP_Tibble, "Biological Process", "#2E86C1")
plot_MF <- process_enrichment_plot(MF_Tibble, "Molecular Function", "#28B463")
plot_CC <- process_enrichment_plot(CC_Tibble, "Cellular Component", "#D35400")

# 🧩 Combine & Show
combined_plot <- plot_BP / plot_MF / plot_CC
combined_plot

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 GO Enrichment g:Profiler

# Load the gprofiler2 package
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)

# Perform GO enrichment analysis with gprofiler2
gost_results <- gost(
  query = prob_5_0.5,           # List of input genes (prob_all_1)
  organism = "hsapiens",   # Human organism
  user_threshold = 0.05,   # Adjusted p-value cutoff
  correction_method = "fdr", # Multiple testing correction
  domain_scope = "custom", # Use custom background
  custom_bg = background,    # Background set of genes
  sources = c("GO:BP", "GO:MF", "GO:CC") # Analyze GO categories
)

# Check if enrichment results exist
if (is.null(gost_results$result) || nrow(gost_results$result) == 0) {
  # If no enriched terms, create a placeholder dataframe
  combined_results <- tibble(
    term_name = "No enriched terms",
    p.adjust = NA,
    source = "N/A",
    Category = "N/A"
  )
} else {
  # Convert results to a data frame
  gost_results_df <- gost_results$result

  # Add a column for adjusted p-value
  gost_results_df <- gost_results_df %>%
    rename(p.adjust = p_value)

  # Separate results for BP, MF, and CC
  BP_results <- gost_results_df %>%
    filter(source == "GO:BP") %>%
    mutate(Category = "Biological Process")

  MF_results <- gost_results_df %>%
    filter(source == "GO:MF") %>%
    mutate(Category = "Molecular Function")

  CC_results <- gost_results_df %>%
    filter(source == "GO:CC") %>%
    mutate(Category = "Cellular Component")

  # Select the top 20 terms by adjusted p-value for each category
  top_BP <- BP_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_MF <- MF_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  top_CC <- CC_results %>%
    arrange(p.adjust) %>%
    slice_head(n = 20)

  # Combine all categories
  combined_results <- bind_rows(top_BP, top_MF, top_CC)
}

# Ensure all columns are atomic types for CSV export
combined_results_clean <- combined_results %>%
  mutate(across(everything(), ~ if (is.list(.)) sapply(., toString) else .))

# Function for plotting top terms
plot_gprofiler_results <- function(data, title, color) {
  ggplot(data, aes(x = -log10(p.adjust), y = reorder(term_name, -log10(p.adjust)))) +
    geom_bar(stat = "identity", fill = color) +
    labs(
      x = "-log10(Adjusted p-value)",
      y = title,
      title = paste("Top 20", title, "GO Terms")
    ) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black"),
      panel.border = element_rect(colour = "black", fill = NA, size = 0.3)
    )
}

# Check if there are enrichment terms to plot
if (nrow(combined_results) == 1 && combined_results$term_name == "No enriched terms") {
  message("No enriched GO terms found for the input gene set.")
} else {
  # Plot the top 20 terms for each category
  plot_BP <- plot_gprofiler_results(top_BP, "Biological Process", "#2E86C1")
  plot_MF <- plot_gprofiler_results(top_MF, "Molecular Function", "#28B463")
  plot_CC <- plot_gprofiler_results(top_CC, "Cellular Component", "#D35400")

  # Combine the plots using patchwork
  combined_plot <- plot_BP / plot_MF / plot_CC

  # Display the combined plot
  combined_plot
}

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 Pathway Enrichment

# Load required libraries
library(clusterProfiler)
library(org.Hs.eg.db) # Required for enrichPathway
library(gprofiler2)
library(ggplot2)
library(dplyr)
library(patchwork)
library(ReactomePA)

# Function for ClusterProfiler Reactome & KEGG Analysis
process_clusterProfiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment based on the selected category
  if (category == "Reactome") {
    enrichment <- enrichPathway(
      gene = gene_set,
      organism = "human",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  } else if (category == "KEGG") {
    enrichment <- enrichKEGG(
      gene = gene_set,
      organism = "hsa",
      pvalueCutoff = 0.05,
      pAdjustMethod = "BH",
      universe = background
    )
  }
  
  # Check if enrichment results exist
  if (is.null(enrichment) || nrow(as.data.frame(enrichment)) == 0) {
    message(paste("No significant enrichment found for", category, "in ClusterProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- as_tibble(as.data.frame(enrichment)) %>%
    mutate(Category = category,
           neglog = -log10(p.adjust)) %>%  # Compute -log10(p.adjust)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(Description, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(Adjusted p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Function for gProfiler Reactome & KEGG Analysis
process_gprofiler <- function(gene_set, background, category, color, y_title) {
  # Perform enrichment using gprofiler2
  enrichment <- gost(
    query = gene_set,
    organism = "hsapiens",
    user_threshold = 0.05,
    correction_method = "fdr",
    domain_scope = "custom",
    custom_bg = background,
    sources = category # Either "REAC" or "KEGG"
  )
  
  # Check if enrichment results exist
  if (is.null(enrichment$result) || nrow(enrichment$result) == 0) {
    message(paste("No significant enrichment found for", category, "in gProfiler"))
    return(NULL)
  }
  
  # Convert results to tibble and process top 20 terms
  enrichment_tibble <- enrichment$result %>%
    as_tibble() %>%
    mutate(Category = category,
           neglog = -log10(p_value)) %>%  # Compute -log10(p-value)
    arrange(desc(neglog)) %>%
    slice_head(n = min(20, nrow(.)))  # Ensure safe slicing
  
  # Generate plot
  plot <- ggplot(enrichment_tibble, aes(x = neglog, y = reorder(term_name, neglog))) +
    geom_bar(stat = "identity", fill = color) +
    labs(x = "-log10(p-value)",
         y = y_title,
         title = paste("Enriched", category, "Pathways")) +
    theme_minimal() +
    theme(
      axis.text.x = element_text(size = 12, face = "bold", colour = "black", angle = 45, hjust = 1),
      axis.text.y = element_text(size = 12, face = "bold", colour = "black"),
      axis.title.x = element_text(size = 14, face = "bold", colour = "black"),
      axis.title.y = element_text(size = 14, face = "bold", colour = "black"),
      plot.title = element_text(size = 14, face = "bold", colour = "black")
    )
  
  return(plot)
}

# Perform analysis for Reactome and KEGG using ClusterProfiler
cluster_reactome <- process_clusterProfiler(
  gene_set = prob_5_0.5,
  background = background,
  category = "Reactome",
  color = "#2E86C1",
  y_title = "Reactome Pathways"
)

cluster_kegg <- process_clusterProfiler(
  gene_set = prob_5_0.5,
  background = background,
  category = "KEGG",
  color = "#28B463",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for ClusterProfiler
if (!is.null(cluster_reactome) && !is.null(cluster_kegg)) {
  cluster_combined <- cluster_reactome / cluster_kegg
} else if (!is.null(cluster_reactome)) {
  cluster_combined <- cluster_reactome
} else if (!is.null(cluster_kegg)) {
  cluster_combined <- cluster_kegg
} else {
  cluster_combined <- NULL
}

# Perform analysis for Reactome and KEGG using GProfiler
gprofiler_reactome <- process_gprofiler(
  gene_set = prob_5_0.5,
  background = background,
  category = "REAC",  # Corrected category for Reactome in gProfiler
  color = "#D35400",
  y_title = "Reactome Pathways"
)

gprofiler_kegg <- process_gprofiler(
  gene_set = prob_5_0.5,
  background = background,
  category = "KEGG",
  color = "#F39C12",
  y_title = "KEGG Pathways"
)

# Combine Reactome and KEGG for GProfiler
if (!is.null(gprofiler_reactome) && !is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_reactome / gprofiler_kegg
} else if (!is.null(gprofiler_reactome)) {
  gprofiler_combined <- gprofiler_reactome
} else if (!is.null(gprofiler_kegg)) {
  gprofiler_combined <- gprofiler_kegg
} else {
  gprofiler_combined <- NULL
}

# Display plots (if they are not NULL)
if (!is.null(cluster_combined)) print(cluster_combined)

Version Author Date
df65b82 sayanpaul01 2025-06-04
84d7de5 sayanpaul01 2025-06-03
cf95313 sayanpaul01 2025-03-10
11895c8 sayanpaul01 2025-02-27
if (!is.null(gprofiler_combined)) print(gprofiler_combined)

Version Author Date
84d7de5 sayanpaul01 2025-06-03
11895c8 sayanpaul01 2025-02-27

📌 Top BP (Cluster Profiler)

### 📦 Load Required Libraries
library(tidyverse)
library(ComplexHeatmap)
Warning: package 'ComplexHeatmap' was built under R version 4.3.1
library(circlize)
Warning: package 'circlize' was built under R version 4.3.3
library(grid)

### 📁 Define CorMotif GO Enrichment Files
go_files <- list(
  "Non response (0.1)"                         = "data/BP/CorMotif_Terms/GO_BP_Non_response_(0.1).csv",
  "CX-DOX mid-late response (0.1)"             = "data/BP/CorMotif_Terms/GO_BP_CX-DOX_mid-late_response_(0.1).csv",
  "DOX only mid-late (0.1)"                    = "data/BP/CorMotif_Terms/GO_BP_DOX_only_mid-late_(0.1).csv",
  "Non response (0.5)"                         = "data/BP/CorMotif_Terms/GO_BP_Non_response_(0.5).csv",
  "DOX specific response (0.5)"                = "data/BP/CorMotif_Terms/GO_BP_DOX_specific_response_(0.5).csv",
  "DOX only mid-late response (0.5)"           = "data/BP/CorMotif_Terms/GO_BP_DOX_only_mid-late_response_(0.5).csv",
  "CX total + DOX early response (0.5)"        = "data/BP/CorMotif_Terms/GO_BP_CX_total_+_DOX_early_response_(0.5).csv",
  "DOX early + CX-DOX mid-late response (0.5)" = "data/BP/CorMotif_Terms/GO_BP_DOX_early_+_CX-DOX_mid-late_response_(0.5).csv"
)

### 🔍 Step 1: Extract Top 5 GO Terms Per Group Based on Adjusted P-value
top_go_terms <- map(go_files, function(file) {
  df <- tryCatch(read.csv(file), error = function(e) return(NULL))
  if (!is.null(df) && nrow(df) > 0 && all(c("Description", "p.adjust") %in% colnames(df))) {
    df %>%
      as_tibble() %>%
      filter(p.adjust < 0.05) %>%
      arrange(p.adjust) %>%
      dplyr::select(Description) %>%
      slice_head(n = 5) %>%
      pull(Description) %>%
      unique()
  } else {
    character(0)
  }
}) %>% unlist() %>% unique()

### 🔁 Step 2: Collect All Matrix Values for Top GO Terms
go_matrix_df <- map_dfr(names(go_files), function(group) {
  file <- go_files[[group]]
  df <- tryCatch(read.csv(file), error = function(e) return(tibble()))

  if (nrow(df) == 0 || !all(c("Description", "pvalue", "p.adjust") %in% colnames(df))) {
    tibble(Description = top_go_terms, pvalue = NA, p.adjust = NA, log10p = NA, Group = group)
  } else {
    df_filtered <- df %>%
      as_tibble() %>%
      dplyr::select(Description, pvalue, p.adjust) %>%
      filter(Description %in% top_go_terms)

    tibble(Description = top_go_terms) %>%
      left_join(df_filtered, by = "Description") %>%
      mutate(
        log10p = ifelse(!is.na(pvalue), -log10(pvalue), NA),
        Group = group
      )
  }
})

### 🧱 Step 3: Pivot to Heatmap Matrices
heatmap_data <- go_matrix_df %>%
  dplyr::select(Description, Group, log10p) %>%
  pivot_wider(names_from = Group, values_from = log10p) %>%
  column_to_rownames("Description") %>%
  as.matrix()

pval_matrix <- go_matrix_df %>%
  dplyr::select(Description, Group, pvalue) %>%
  pivot_wider(names_from = Group, values_from = pvalue) %>%
  column_to_rownames("Description") %>%
  as.matrix()

p_adj_matrix <- go_matrix_df %>%
  dplyr::select(Description, Group, p.adjust) %>%
  pivot_wider(names_from = Group, values_from = p.adjust) %>%
  column_to_rownames("Description") %>%
  as.matrix()

### 🎨 Step 4: Define Heatmap Color Gradient
breaks <- seq(0, 20, by = 2.5)
palette <- colorRampPalette(c("white", "#fde0dd", "#fa9fb5", "#f768a1", "#c51b8a", "#7a0177", "#49006a"))(length(breaks))
col_fun <- colorRamp2(breaks, palette)

### 🔥 Step 5: Draw Heatmap with Stars for p.adjust < 0.05
ht <- Heatmap(
  heatmap_data,
  name = "-log10(p)",
  col = col_fun,
  na_col = "white",
  rect_gp = gpar(col = "black", lwd = 0.5),
  cluster_rows = FALSE,
  cluster_columns = FALSE,
  row_names_gp = gpar(fontsize = 9),
  column_names_gp = gpar(fontsize = 9),
  column_names_rot = 45,
  cell_fun = function(j, i, x, y, width, height, fill) {
    adj_p <- p_adj_matrix[i, j]
    if (!is.na(adj_p) && adj_p < 0.05) {
      grid.text("*", x, y, gp = gpar(fontsize = 12))
    }
  },
  heatmap_legend_param = list(
    title = "-log10(p value)",
    at = breaks,
    labels = as.character(breaks),
    legend_width = unit(5, "cm"),
    direction = "horizontal",
    title_gp = gpar(fontsize = 10, fontface = "bold"),
    labels_gp = gpar(fontsize = 9)
  )
)

### 🖼️ Final Output
draw(ht, heatmap_legend_side = "top")

Version Author Date
df65b82 sayanpaul01 2025-06-04
cf7130e sayanpaul01 2025-06-03
c5f10c4 sayanpaul01 2025-06-02
c034ee0 sayanpaul01 2025-06-02
cf95313 sayanpaul01 2025-03-10

sessionInfo()
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 26100)

Matrix products: default


locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

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

other attached packages:
 [1] circlize_0.4.16                         
 [2] ComplexHeatmap_2.18.0                   
 [3] ReactomePA_1.46.0                       
 [4] gprofiler2_0.2.3                        
 [5] data.table_1.17.0                       
 [6] patchwork_1.3.0                         
 [7] DOSE_3.28.2                             
 [8] TxDb.Hsapiens.UCSC.hg38.knownGene_3.18.0
 [9] RColorBrewer_1.1-3                      
[10] clusterProfiler_4.10.1                  
[11] pheatmap_1.0.12                         
[12] qvalue_2.34.0                           
[13] BiocParallel_1.36.0                     
[14] Homo.sapiens_1.3.1                      
[15] TxDb.Hsapiens.UCSC.hg19.knownGene_3.2.2 
[16] org.Hs.eg.db_3.18.0                     
[17] GO.db_3.18.0                            
[18] OrganismDbi_1.44.0                      
[19] GenomicFeatures_1.54.4                  
[20] GenomicRanges_1.54.1                    
[21] GenomeInfoDb_1.38.8                     
[22] AnnotationDbi_1.64.1                    
[23] IRanges_2.36.0                          
[24] S4Vectors_0.40.2                        
[25] Biobase_2.62.0                          
[26] BiocGenerics_0.48.1                     
[27] edgeR_4.0.16                            
[28] limma_3.58.1                            
[29] cluster_2.1.8.1                         
[30] ggfortify_0.4.17                        
[31] lubridate_1.9.4                         
[32] forcats_1.0.0                           
[33] stringr_1.5.1                           
[34] dplyr_1.1.4                             
[35] purrr_1.0.4                             
[36] readr_2.1.5                             
[37] tidyr_1.3.1                             
[38] tibble_3.2.1                            
[39] ggplot2_3.5.2                           
[40] tidyverse_2.0.0                         

loaded via a namespace (and not attached):
  [1] splines_4.3.0               later_1.3.2                
  [3] BiocIO_1.12.0               bitops_1.0-9               
  [5] ggplotify_0.1.2             filelock_1.0.3             
  [7] polyclip_1.10-7             graph_1.80.0               
  [9] XML_3.99-0.18               lifecycle_1.0.4            
 [11] doParallel_1.0.17           rprojroot_2.0.4            
 [13] lattice_0.22-7              MASS_7.3-60                
 [15] magrittr_2.0.3              plotly_4.10.4              
 [17] sass_0.4.10                 rmarkdown_2.29             
 [19] jquerylib_0.1.4             yaml_2.3.10                
 [21] httpuv_1.6.15               cowplot_1.1.3              
 [23] DBI_1.2.3                   abind_1.4-8                
 [25] zlibbioc_1.48.2             ggraph_2.2.1               
 [27] RCurl_1.98-1.17             yulab.utils_0.2.0          
 [29] tweenr_2.0.3                rappdirs_0.3.3             
 [31] git2r_0.36.2                GenomeInfoDbData_1.2.11    
 [33] enrichplot_1.22.0           ggrepel_0.9.6              
 [35] tidytree_0.4.6              reactome.db_1.86.2         
 [37] codetools_0.2-20            DelayedArray_0.28.0        
 [39] xml2_1.3.8                  ggforce_0.4.2              
 [41] shape_1.4.6.1               tidyselect_1.2.1           
 [43] aplot_0.2.5                 farver_2.1.2               
 [45] viridis_0.6.5               matrixStats_1.5.0          
 [47] BiocFileCache_2.10.2        GenomicAlignments_1.38.2   
 [49] jsonlite_2.0.0              GetoptLong_1.0.5           
 [51] tidygraph_1.3.1             iterators_1.0.14           
 [53] foreach_1.5.2               tools_4.3.0                
 [55] progress_1.2.3              treeio_1.26.0              
 [57] Rcpp_1.0.12                 glue_1.7.0                 
 [59] gridExtra_2.3               SparseArray_1.2.4          
 [61] xfun_0.52                   MatrixGenerics_1.14.0      
 [63] withr_3.0.2                 BiocManager_1.30.25        
 [65] fastmap_1.2.0               digest_0.6.34              
 [67] timechange_0.3.0            R6_2.6.1                   
 [69] gridGraphics_0.5-1          colorspace_2.1-0           
 [71] Cairo_1.6-2                 biomaRt_2.58.2             
 [73] RSQLite_2.3.9               generics_0.1.3             
 [75] rtracklayer_1.62.0          htmlwidgets_1.6.4          
 [77] prettyunits_1.2.0           graphlayouts_1.2.2         
 [79] httr_1.4.7                  S4Arrays_1.2.1             
 [81] scatterpie_0.2.4            graphite_1.48.0            
 [83] whisker_0.4.1               pkgconfig_2.0.3            
 [85] gtable_0.3.6                blob_1.2.4                 
 [87] workflowr_1.7.1             XVector_0.42.0             
 [89] shadowtext_0.1.4            htmltools_0.5.8.1          
 [91] fgsea_1.28.0                RBGL_1.78.0                
 [93] clue_0.3-66                 scales_1.3.0               
 [95] png_0.1-8                   ggfun_0.1.8                
 [97] knitr_1.50                  rstudioapi_0.17.1          
 [99] tzdb_0.5.0                  reshape2_1.4.4             
[101] rjson_0.2.23                nlme_3.1-168               
[103] curl_6.2.2                  GlobalOptions_0.1.2        
[105] cachem_1.1.0                parallel_4.3.0             
[107] HDO.db_0.99.1               restfulr_0.0.15            
[109] pillar_1.10.2               vctrs_0.6.5                
[111] promises_1.3.2              dbplyr_2.5.0               
[113] evaluate_1.0.3              magick_2.8.6               
[115] cli_3.6.1                   locfit_1.5-9.12            
[117] compiler_4.3.0              Rsamtools_2.18.0           
[119] rlang_1.1.3                 crayon_1.5.3               
[121] labeling_0.4.3              plyr_1.8.9                 
[123] fs_1.6.3                    stringi_1.8.3              
[125] viridisLite_0.4.2           munsell_0.5.1              
[127] Biostrings_2.70.3           lazyeval_0.2.2             
[129] GOSemSim_2.28.1             Matrix_1.6-1.1             
[131] hms_1.1.3                   bit64_4.6.0-1              
[133] KEGGREST_1.42.0             statmod_1.5.0              
[135] SummarizedExperiment_1.32.0 igraph_2.1.4               
[137] memoise_2.0.1               bslib_0.9.0                
[139] ggtree_3.10.1               fastmatch_1.1-6            
[141] bit_4.6.0                   gson_0.1.0                 
[143] ape_5.8-1