Overview

Purpose: Visualize LION (Lipid Ontology) enrichment results comparing lipid profiles between Low P and High P treatments.

This is a plotting wrapper for pre-processed LION enrichment data. The enrichment analysis identifies biological categories of lipids (classes, cellular locations, biophysical properties) that are over-represented among differentially abundant lipids under phosphorus stress.

Libraries

library(ggplot2)
library(dplyr)
library(janitor)
library(ggrepel)
library(ggpubr)

Data Loading

# Load LION enrichment results
enrichment <- read.csv(file.path(paths$data, "LION-enrichment_LowPVSHighP.csv"))

cat("Loaded", nrow(enrichment), "enrichment terms\n")
## Loaded 52 enrichment terms

Data Preprocessing

# Clean column names
enrichment <- enrichment %>%
  clean_names()

# Calculate -log10 transformations
enrichment <- enrichment %>%
  mutate(
    neg_log10_fdr = -log10(fdr_q_value),
    neg_log10_pvalue = -log10(p_value)
  )

# Define significance threshold and create labels
fdr_threshold <- 0.05

enrichment <- enrichment %>%
  mutate(
    is_significant = fdr_q_value < fdr_threshold,
    label = ifelse(is_significant, discription, "")
  )

# Filter to significant terms
sig_enrichment <- enrichment %>%
  filter(is_significant)

# Diagnostics
cat("Significant terms (FDR < 0.05):", nrow(sig_enrichment), "/", 
    nrow(enrichment), "\n")
## Significant terms (FDR < 0.05): 21 / 52
cat("Upregulated:", sum(sig_enrichment$regulated == "UP"), "\n")
## Upregulated: 4
cat("Downregulated:", sum(sig_enrichment$regulated == "DOWN"), "\n")
## Downregulated: 17

Summary Tables

# Top upregulated terms
top_up <- enrichment %>%
  filter(regulated == "UP") %>%
  arrange(fdr_q_value) %>%
  select(term_id, discription, annotated, p_value, fdr_q_value, es) %>%
  head(10)

knitr::kable(
  top_up,
  caption = "Top 10 Upregulated Lipid Categories",
  digits = 3
)
Top 10 Upregulated Lipid Categories
term_id discription annotated p_value fdr_q_value es
LION:0000622 triacylglycerols [GL0301] 26 0.000 0.000 0.796
LION:0012011 lipid storage 26 0.000 0.000 0.796
LION:0012084 lipid droplet 26 0.000 0.000 0.796
LION:0000094 headgroup with neutral charge 50 0.000 0.000 0.589
LION:0002956 fatty acid with 17 carbons 4 0.212 0.263 0.495
LION:0000607 diacylglycerols [GL0201] 24 0.232 0.274 0.231
LION:0002968 saturated fatty acid 6 0.271 0.306 0.394
LION:0002966 fatty acid with less than 2 double bonds 11 0.582 0.600 0.232
# Top downregulated terms
top_down <- enrichment %>%
  filter(regulated == "DOWN") %>%
  arrange(fdr_q_value) %>%
  select(term_id, discription, annotated, p_value, fdr_q_value, es) %>%
  head(10)

knitr::kable(
  top_down,
  caption = "Top 10 Downregulated Lipid Categories",
  digits = 3
)
Top 10 Downregulated Lipid Categories
term_id discription annotated p_value fdr_q_value es
LION:0012010 membrane component 78 0.000 0.000 -0.762
LION:0000003 glycerophospholipids [GP] 54 0.000 0.000 -0.605
LION:0012080 endoplasmic reticulum (ER) 47 0.000 0.000 -0.468
LION:0000095 headgroup with positive charge / zwitter-ion 43 0.000 0.001 -0.421
LION:0000093 headgroup with negative charge 11 0.000 0.001 -0.649
LION:0002967 polyunsaturated fatty acid 4 0.001 0.003 -0.891
LION:0080978 average lateral diffusion 11 0.004 0.017 -0.537
LION:0012081 mitochondrion 23 0.005 0.019 -0.398
LION:0000010 glycerophosphocholines [GP01] 27 0.005 0.019 -0.373
LION:0000059 diacylglycerophosphoglycerols [GP0401] 7 0.005 0.019 -0.633

Visualization

# Create bubble plot with labeled significant terms
lion_plot <- sig_enrichment %>%
  ggplot(aes(x = es , y = -log10(fdr_q_value) , label = label)) +
  ggtitle("LION Lipid Enrichment -P vs P")+
  geom_vline(
    xintercept = 0,
    linetype = "dashed",
    color = "grey30",
    size = 0.8
  ) +
  geom_point(
    aes(size = annotated, color = neg_log10_fdr),
    alpha = 0.8,
    shape = 19, 
  
  ) +
  geom_text_repel(
    aes(color = neg_log10_fdr),
    max.overlaps = 10,
    min.segment.length = 2,
    size = 6,
    hjust=1,
    box.padding = 0.2,
    point.padding = 1,
    force = 3
  ) +
  scale_color_gradient(
    low = "dodgerblue",
    high = "tomato",
    name = expression(-log[10](FDR))
  ) +
  scale_size_continuous(
    name = expression("Count"),
    breaks = c(3, 6, 10)
  ) +
  xlab("Enrichment Score (ES)") +
  ylab(expression(-log[10](q))) +

  theme_classic2(base_size = 25) +
  theme(
    plot.title = element_text(size=25),
   # legend.position = c(0.8, 0.2),
    legend.title = element_text(size = 16),
    legend.text = element_text(size = 14),
    legend.key.size = unit(0.8, "lines"),
    legend.spacing.x = unit(0.5, "cm")
  )

print(lion_plot)

Biological Interpretation

# Summary statistics
cat("=== LION Enrichment Summary ===\n\n")
## === LION Enrichment Summary ===
cat("Total terms tested:", nrow(enrichment), "\n")
## Total terms tested: 52
cat("Significant terms:", nrow(sig_enrichment), "\n\n")
## Significant terms: 21
# Most enriched upregulated category
top_up_term <- enrichment %>%
  filter(regulated == "UP") %>%
  arrange(fdr_q_value) %>%
  slice(1)

cat("Top UP category:", top_up_term$discription, "\n")
## Top UP category: triacylglycerols [GL0301]
cat("  FDR:", format(top_up_term$fdr_q_value, scientific = TRUE, digits = 3), "\n")
##   FDR: 1.06e-11
cat("  ES:", round(top_up_term$es, 3), "\n")
##   ES: 0.796
cat("  Lipids:", top_up_term$annotated, "\n\n")
##   Lipids: 26
# Most enriched downregulated category
top_down_term <- enrichment %>%
  filter(regulated == "DOWN") %>%
  arrange(fdr_q_value) %>%
  slice(1)

cat("Top DOWN category:", top_down_term$discription, "\n")
## Top DOWN category: membrane component
cat("  FDR:", format(top_down_term$fdr_q_value, scientific = TRUE, digits = 3), "\n")
##   FDR: 4.03e-11
cat("  ES:", round(top_down_term$es, 3), "\n")
##   ES: -0.762
cat("  Lipids:", top_down_term$annotated, "\n")
##   Lipids: 78

Upregulated Under Low P (Storage Lipids): - Triacylglycerols: Neutral storage lipids in lipid droplets - Increased energy storage under P deficiency

Downregulated Under Low P (Membrane Lipids): - Membrane components: Structural phospholipids - Glycerophospholipids: Major membrane constituents - Polyunsaturated fatty acids: Important for membrane fluidity

Interpretation: Phosphorus stress triggers membrane remodeling, reducing phosphorus-containing membrane lipids (phospholipids) while increasing phosphorus-free storage lipids (triacylglycerols).

Export

# Save for figure assembly
saveRDS(
  lion_plot,
  file = file.path(paths$intermediate, "lion_plot.rds")
)

ggsave(
  lion_plot,
  file = file.path(paths$figures, "lion_plot.pdf"),
  width = 14,
  height = 12
)

# Export processed data
write.csv(
  sig_enrichment,
  file = file.path(paths$intermediate, "LION_enrichment_significant.csv"),
  row.names = FALSE
)

Session Info

sessionInfo()
## R version 4.5.1 (2025-06-13)
## Platform: x86_64-apple-darwin20
## Running under: macOS Sequoia 15.6.1
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.5-x86_64/Resources/lib/libRblas.0.dylib 
## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-x86_64/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] ggpubr_0.6.2  ggrepel_0.9.6 janitor_2.2.1 dplyr_1.1.4   ggplot2_4.0.1
## 
## loaded via a namespace (and not attached):
##  [1] sass_0.4.10        generics_0.1.4     tidyr_1.3.1        rstatix_0.7.3     
##  [5] stringi_1.8.7      digest_0.6.39      magrittr_2.0.4     evaluate_1.0.5    
##  [9] grid_4.5.1         timechange_0.3.0   RColorBrewer_1.1-3 fastmap_1.2.0     
## [13] rprojroot_2.1.1    jsonlite_2.0.0     backports_1.5.0    Formula_1.2-5     
## [17] purrr_1.2.0        scales_1.4.0       textshaping_1.0.4  jquerylib_0.1.4   
## [21] abind_1.4-8        cli_3.6.5          rlang_1.1.6        withr_3.0.2       
## [25] cachem_1.1.0       yaml_2.3.12        tools_4.5.1        ggsignif_0.6.4    
## [29] here_1.0.2         broom_1.0.11       vctrs_0.6.5        R6_2.6.1          
## [33] lifecycle_1.0.4    lubridate_1.9.4    snakecase_0.11.1   stringr_1.6.0     
## [37] car_3.1-3          ragg_1.5.0         pkgconfig_2.0.3    pillar_1.11.1     
## [41] bslib_0.9.0        gtable_0.3.6       glue_1.8.0         Rcpp_1.1.0        
## [45] systemfonts_1.3.1  xfun_0.54          tibble_3.3.0       tidyselect_1.2.1  
## [49] knitr_1.50         farver_2.1.2       htmltools_0.5.9    labeling_0.4.3    
## [53] rmarkdown_2.30     carData_3.0-5      compiler_4.5.1     S7_0.2.1