rm(list = ls())
library(readxl) # For reading Excel files
library(ggpubr) # For creating publication-ready plots
library(dplyr) # For data manipulation
# Targeted MS data
PP.targeted.serum <- read_excel("Data/Data.xlsx", sheet = "PP_serum_MS")
# Pig info and postprandial metadata
PigInfo <- read_excel("Data/Data.xlsx", sheet = "PigInfo")
PP_metadata <- read_excel("Data/Data.xlsx", sheet = "PP_metadata")
PP_Feed.intake <- PP_metadata %>% select(PigID, PPfeedIntake.g)
# Calculate tryptophan intake (in mg) for each pig based on their diet
Trp.intake <- PP_metadata %>% inner_join(PigInfo, by = "PigID") %>%
mutate(Trp_intake = if_else(Diet == "ALAC", PPfeedIntake.g * 1.03, PPfeedIntake.g * 0.89)) %>% # Calculate tryptophan intake based on the assigned diet
select(PigID, Trp_intake)
# Filter data for the 120-minute time point, join with tryptophan intake data, and create scatter plot
Fig <- PP.targeted.serum %>% inner_join(PigInfo, by = "PigID") %>%
filter(TimePoint == "120 min") %>%
select(PigID, Diet, Tryptophan) %>%
inner_join(Trp.intake, by = "PigID") %>%
ggscatter(x = "Tryptophan", y = "Trp_intake",
xlab = "Serum tryptophan at 120 min post-meal (uM)", ylab = "Tryptophan intake from formula (mg)",
palette = c("turquoise3","purple"), add = "reg.line") + stat_cor(method = "pearson", label.x = 120)
# Save the figure as a pdf file
ggsave(plot=Fig, height=5, width=5.5, dpi=300, filename="Figure 2/Fig2G.pdf", useDingbats=FALSE)
Fig
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] 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] splines_4.2.2 lattice_0.20-45 carData_3.0-5 colorspace_2.1-0
## [9] vctrs_0.6.5 generics_0.1.3 htmltools_0.5.6.1 yaml_2.3.7
## [13] mgcv_1.8-41 utf8_1.2.4 rlang_1.1.2 jquerylib_0.1.4
## [17] pillar_1.9.0 glue_1.6.2 withr_3.0.1 lifecycle_1.0.4
## [21] munsell_0.5.1 ggsignif_0.6.4 gtable_0.3.5 cellranger_1.1.0
## [25] ragg_1.2.6 evaluate_1.0.1 labeling_0.4.3 knitr_1.45
## [29] fastmap_1.1.1 fansi_1.0.6 highr_0.10 broom_1.0.5
## [33] scales_1.3.0 backports_1.4.1 cachem_1.0.8 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 rstatix_0.7.2 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 Matrix_1.5-4.1
## [53] rmarkdown_2.28 rstudioapi_0.15.0 R6_2.5.1 nlme_3.1-163
## [57] compiler_4.2.2