Purpose: Assemble the final combined enrichment figure with three panels: - Panel A: GO Biological Process enrichment (top) - Panel B: KEGG Pathway enrichment (bottom) - Panel C: LION Lipid enrichment (right)
This script loads pre-generated plots from individual analyses and combines them into a publication-ready figure.
library(ggplot2)
library(ggpubr)
library(cowplot)
# Load GO enrichment plot
go_panel <- readRDS(file.path(paths$intermediate, "go_panel.rds"))
cat("Loaded GO panel\n")
## Loaded GO panel
# Load KEGG enrichment plot
kegg_panel <- readRDS(file.path(paths$intermediate, "kegg_panel.rds"))
cat("Loaded KEGG panel\n")
## Loaded KEGG panel
# Load LION enrichment plot
lion_panel <- readRDS(file.path(paths$intermediate, "lion_plot.rds"))
cat("Loaded LION panel\n")
## Loaded LION panel
# Combine GO and KEGG vertically (left side)
# Increased heights to make bubble plots taller
# Add LION panel to the right
combined_fig_v1 <- ggpubr::ggarrange(
go_panel,
kegg_panel,
lion_panel,
ncol = 1,
# widths = c(2, 1),
labels = c("A", "B","C"),
font.label =list(size=35)
)
print(combined_fig_v1)
# Export as SVG (editable in Illustrator)
ggsave(
combined_fig_v1,
filename = file.path(paths$figures, "combined_enrichment_figure.svg"),
width = 16,
height = 16,
units = "in"
)
cat("Exported combined figure in multiple formats\n")
## Exported combined figure in multiple formats
cat("=== Panel Dimensions ===\n\n")
## === Panel Dimensions ===
cat("GO Panel:\n")
## GO Panel:
cat(" Expected: 12 × 8.4 inches (taller)\n\n")
## Expected: 12 × 8.4 inches (taller)
cat("KEGG Panel:\n")
## KEGG Panel:
cat(" Expected: 12 × 8.4 inches (taller)\n\n")
## Expected: 12 × 8.4 inches (taller)
cat("LION Panel:\n")
## LION Panel:
cat(" Expected: 14 × 12 inches\n\n")
## Expected: 14 × 12 inches
cat("Combined Figure (Recommended):\n")
## Combined Figure (Recommended):
cat(" Layout: Vertical stack (GO + KEGG) + Right panel (LION)\n")
## Layout: Vertical stack (GO + KEGG) + Right panel (LION)
cat(" Dimensions: 16 × 14 inches\n")
## Dimensions: 16 × 14 inches
cat(" Format: PDF at 150 dpi\n")
## Format: PDF at 150 dpi
cat("=== Checking Input Data Files ===\n\n")
## === Checking Input Data Files ===
# Check for plot data CSV files
go_data_exists <- file.exists(file.path(paths$intermediate, "go_plot_input_data.csv"))
kegg_data_exists <- file.exists(file.path(paths$intermediate, "kegg_plot_input_data.csv"))
lion_data_exists <- file.exists(file.path(paths$intermediate, "lion_plot_input_data.csv"))
cat("GO plot data:", ifelse(go_data_exists, "✓ Found", "✗ Missing"), "\n")
## GO plot data: ✓ Found
cat("KEGG plot data:", ifelse(kegg_data_exists, "✓ Found", "✗ Missing"), "\n")
## KEGG plot data: ✓ Found
cat("LION plot data:", ifelse(lion_data_exists, "✓ Found", "✗ Missing"), "\n\n")
## LION plot data: ✗ Missing
if (all(c(go_data_exists, kegg_data_exists, lion_data_exists))) {
cat("All input data files are available for supplementary materials\n")
} else {
cat("⚠ Some data files are missing - run individual analysis scripts with eval=TRUE\n")
}
## ⚠ Some data files are missing - run individual analysis scripts with eval=TRUE
sessionInfo()
## R version 4.5.2 (2025-10-31)
## Platform: aarch64-apple-darwin20
## Running under: macOS Sequoia 15.6.1
##
## Matrix products: default
## BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## time zone: America/New_York
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] cowplot_1.2.0 ggpubr_0.6.2 ggplot2_4.0.1 here_1.0.2
##
## loaded via a namespace (and not attached):
## [1] yulab.utils_0.2.3 rappdirs_0.3.3 sass_0.4.10 generics_0.1.4
## [5] tidyr_1.3.1 rstatix_0.7.3 ggplotify_0.1.3 digest_0.6.39
## [9] magrittr_2.0.4 evaluate_1.0.5 grid_4.5.2 RColorBrewer_1.1-3
## [13] fastmap_1.2.0 rprojroot_2.1.1 jsonlite_2.0.0 ggrepel_0.9.6
## [17] backports_1.5.0 Formula_1.2-5 purrr_1.2.0 scales_1.4.0
## [21] textshaping_1.0.4 jquerylib_0.1.4 abind_1.4-8 cli_3.6.5
## [25] rlang_1.1.6 withr_3.0.2 cachem_1.1.0 yaml_2.3.12
## [29] tools_4.5.2 ggsignif_0.6.4 dplyr_1.1.4 broom_1.0.11
## [33] vctrs_0.6.5 R6_2.6.1 gridGraphics_0.5-1 lifecycle_1.0.4
## [37] fs_1.6.6 car_3.1-3 ragg_1.5.0 pkgconfig_2.0.3
## [41] pillar_1.11.1 bslib_0.9.0 gtable_0.3.6 glue_1.8.0
## [45] Rcpp_1.1.0 systemfonts_1.3.1 xfun_0.55 tibble_3.3.0
## [49] tidyselect_1.2.1 knitr_1.50 farver_2.1.2 htmltools_0.5.9
## [53] svglite_2.2.2 rmarkdown_2.30 carData_3.0-5 labeling_0.4.3
## [57] compiler_4.5.2 S7_0.2.1