Clean up the environment
rm(list = ls())
Load required libraries for data reading, plotting, and data
manipulation
library(readxl) # For reading Excel files
library(ggpubr) # For creating publication-ready plots
library(dplyr) # For data manipulation
library(ggh4x) # For advanced facet functions in ggplot2
library(rstatix) # For statistical tests and adding significance markers
library(knitr) # For displaying tibbles in a nice table format
library(kableExtra) # For enhancing table formatting
Load data
# Dietary composition
DietComp <- read_excel("Data/Data.xlsx", sheet = "DietComp")
# Serum, liver and brain metabolome data
Serum <- read_excel("Data/Data.xlsx", sheet = "Nec_serum_targeted")
Liver <- read_excel("Data/Data.xlsx", sheet = "Liver_targeted")
Brain <- read_excel("Data/Data.xlsx", sheet = "Brain_targeted")
# Pig info
PigInfo <- read_excel("Data/Data.xlsx", sheet = "PigInfo")
# Metadata related to necropsy, including feed intake information
Nec_metadata <- read_excel("Data/Data.xlsx", sheet = "Nec_metadata")
Data organization
Data.diet <- DietComp %>% filter(Variable %in% c("Tryptophan:LNAA")) %>%
select(Diet, Value) %>%
mutate(Diet = case_when(
Diet == "ALAC diet" ~ "ALAC",
Diet == "WPI diet" ~ "WPI",
Diet == "Sow milk" ~ "SF")) %>%
rename(Trp_to_LNAA = Value) %>%
mutate(Region = "Diet") %>%
relocate(Region, .before = Trp_to_LNAA)
Data.serum <- Serum %>%
mutate(Trp_to_LNAA = Tryptophan / rowSums(across(c(Isoleucine, Leucine, Valine, Phenylalanine, Tyrosine)), na.rm = FALSE)) %>%
mutate(Region = "Serum") %>%
select(PigID, Region, Trp_to_LNAA)
Data.liver <- Liver %>%
mutate(Trp_to_LNAA = Tryptophan / rowSums(across(c(Isoleucine, Leucine, Valine, Phenylalanine, Tyrosine)), na.rm = FALSE)) %>%
mutate(Region = "Liver") %>%
select(PigID, Region, Trp_to_LNAA)
Data.brain <- Brain %>% mutate(Trp_to_LNAA = Tryptophan / rowSums(across(c(Isoleucine, Leucine, Valine, Phenylalanine, Tyrosine)), na.rm = FALSE)) %>%
select(PigID, Region, Trp_to_LNAA) %>%
na.omit()
Plotting data
Fig <- bind_rows(Data.serum, Data.liver, Data.brain) %>%
inner_join(PigInfo, by = "PigID") %>%
select(Diet, Region, Trp_to_LNAA) %>%
bind_rows(Data.diet) %>% # add the diet data
mutate(Diet = factor(Diet, levels = c("ALAC", "WPI", "SF"))) %>%
mutate(Region = factor(Region, levels = c("Diet", "Serum", "Liver", "Hippocampus", "Hypothalamus", "PFC", "Striatum"))) %>%
ggerrorplot(x = "Region", y = "Trp_to_LNAA", color = "Diet",
palette = c("turquoise3","purple", "orange"),
na.rm = TRUE, xlab = "",
ylab ="Tryptophan:LNAA", add = "mean_se", size = 0.6,
position = position_dodge(0.8)) +
facet_grid2(.~Region, scales = "free") + # Use facet_grid2 to display regions separately
theme(strip.background = element_blank(), strip.text.x = element_blank())
Fig
## Warning: Removed 3 rows containing missing values or values outside the scale range
## (`geom_segment()`).

# Save the figure in pdf format:
ggsave(plot=Fig, height=5, width=8.5, dpi=300, filename="Figure 3/Fig3C.pdf", useDingbats=FALSE)
## Warning: Removed 3 rows containing missing values or values outside the scale range
## (`geom_segment()`).
Statistical analysis
bind_rows(Data.serum, Data.liver, Data.brain) %>%
inner_join(PigInfo, by = "PigID") %>%
select(Diet, Region, Trp_to_LNAA) %>%
group_by(Region) %>%
wilcox_test(Trp_to_LNAA ~ Diet, paired = FALSE, p.adjust.method = "none") %>% # Perform Mann-whitney U test (Wilcox test)
select(-p.adj, -p.adj.signif) %>%
add_significance(cutpoints = c(0, 0.05, 0.1, 1), symbols = c("*", "#", "ns")) %>%
filter(p.signif != "ns") %>%
kable() %>% # Print the tibble in a nice table format
kable_styling(bootstrap_options = c("striped", "hover")) # Enhance table formatting
Region
|
.y.
|
group1
|
group2
|
n1
|
n2
|
statistic
|
p
|
p.signif
|
Hippocampus
|
Trp_to_LNAA
|
ALAC
|
WPI
|
11
|
12
|
95
|
0.079000
|
#
|
Hippocampus
|
Trp_to_LNAA
|
SF
|
WPI
|
6
|
12
|
55
|
0.083000
|
#
|
Hypothalamus
|
Trp_to_LNAA
|
ALAC
|
WPI
|
10
|
10
|
82
|
0.015000
|
|
Hypothalamus
|
Trp_to_LNAA
|
SF
|
WPI
|
6
|
10
|
50
|
0.031000
|
|
Liver
|
Trp_to_LNAA
|
ALAC
|
WPI
|
11
|
12
|
111
|
0.004000
|
|
Liver
|
Trp_to_LNAA
|
SF
|
WPI
|
6
|
12
|
64
|
0.007000
|
|
PFC
|
Trp_to_LNAA
|
SF
|
WPI
|
6
|
12
|
62
|
0.014000
|
|
Serum
|
Trp_to_LNAA
|
ALAC
|
SF
|
11
|
6
|
0
|
0.000162
|
|
Serum
|
Trp_to_LNAA
|
SF
|
WPI
|
6
|
12
|
72
|
0.000108
|
|
Striatum
|
Trp_to_LNAA
|
SF
|
WPI
|
6
|
12
|
64
|
0.007000
|
|
sessionInfo()
## R version 4.2.2 (2022-10-31)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur ... 10.16
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] kableExtra_1.3.4 knitr_1.45 rstatix_0.7.2 ggh4x_0.2.6
## [5] dplyr_1.1.3 ggpubr_0.6.0 ggplot2_3.5.1 readxl_1.4.3
##
## loaded via a namespace (and not attached):
## [1] tidyselect_1.2.0 xfun_0.40 bslib_0.5.1 purrr_1.0.2
## [5] carData_3.0-5 colorspace_2.1-0 vctrs_0.6.5 generics_0.1.3
## [9] viridisLite_0.4.2 htmltools_0.5.6.1 yaml_2.3.7 utf8_1.2.4
## [13] rlang_1.1.2 jquerylib_0.1.4 pillar_1.9.0 glue_1.6.2
## [17] withr_3.0.1 lifecycle_1.0.4 stringr_1.5.1 munsell_0.5.1
## [21] ggsignif_0.6.4 gtable_0.3.5 cellranger_1.1.0 ragg_1.2.6
## [25] rvest_1.0.3 evaluate_1.0.1 labeling_0.4.3 fastmap_1.1.1
## [29] fansi_1.0.6 highr_0.10 broom_1.0.5 scales_1.3.0
## [33] backports_1.4.1 cachem_1.0.8 webshot_0.5.5 jsonlite_1.8.8
## [37] abind_1.4-5 farver_2.1.1 systemfonts_1.0.5 textshaping_0.3.7
## [41] digest_0.6.33 stringi_1.7.12 grid_4.2.2 cli_3.6.2
## [45] tools_4.2.2 magrittr_2.0.3 sass_0.4.7 tibble_3.2.1
## [49] tidyr_1.3.0 car_3.1-2 pkgconfig_2.0.3 xml2_1.3.5
## [53] rmarkdown_2.28 svglite_2.1.2 httr_1.4.7 rstudioapi_0.15.0
## [57] R6_2.5.1 compiler_4.2.2