Data organization
Fig1 <- PP.targeted.serum %>%
inner_join(PigInfo, by = "PigID") %>%
select(PigID, Diet, TimePoint, Tryptophan) %>%
# Filter to keep only pigs with 4 time points and calculate baseline tryptophan
group_by(PigID) %>%
filter(n() == 4) %>%
mutate(Baseline.Trp = Tryptophan[TimePoint == "baseline"]) %>%
ungroup() %>%
# Calculate adjusted tryptophan values
mutate(Adjusted.Trp = Tryptophan - Baseline.Trp,
TimePoint = factor(TimePoint, levels = c("baseline", "30 min", "60 min", "120 min")),
Diet = factor(Diet, levels = c("ALAC", "WPI")),
PigID = factor(PigID)) %>%
# Plot the results
ggplot(aes(x = TimePoint, y = Adjusted.Trp, group = PigID, color = Diet)) +
geom_point(size = 1.2, position = position_dodge(width = 0.2)) +
geom_line(linewidth = 0.7, position = position_dodge(width = 0.2)) +
scale_color_manual(values = c("turquoise3", "purple")) +
geom_hline(yintercept = 0, linetype = "dashed", color = "black") +
labs(y = "Baseline adjusted tryptophan (uM)", x = "") +
theme_classic2()
# save the figure to a pdf file:
ggsave(plot=Fig1, height=5, width=6, dpi=300, filename="Figure 2/Fig2F_left.pdf", useDingbats=FALSE)
Fig1

Below is used as a color guide for PigID
PP.targeted.serum %>%
inner_join(PigInfo, by = "PigID") %>%
select(PigID, Diet, TimePoint, Tryptophan) %>%
# Filter to keep only pigs with 4 time points and calculate baseline tryptophan
group_by(PigID) %>%
filter(n() == 4) %>%
mutate(Baseline.Trp = Tryptophan[TimePoint == "baseline"]) %>%
ungroup() %>%
# Calculate adjusted tryptophan values
mutate(Adjusted.Trp = Tryptophan - Baseline.Trp,
TimePoint = factor(TimePoint, levels = c("baseline", "30 min", "60 min", "120 min")),
Diet = factor(Diet, levels = c("ALAC", "WPI")),
PigID = factor(PigID)) %>%
# Plot the results
ggplot(aes(x = TimePoint, y = Adjusted.Trp, group = PigID, color = PigID)) +
geom_point(size = 1.2, position = position_dodge(width = 0.2)) +
geom_line(linewidth = 0.7, position = position_dodge(width = 0.2)) +
geom_hline(yintercept = 0, linetype = "dashed", color = "black") +
labs(y = "Baseline adjusted tryptophan (uM)", x = "") +
theme_classic2()

Fig2 <- PP_metadata %>% filter(PigID %in% c(25, 28, 12, 6, 1)) %>%
select(PigID, PPfeedIntake.g) %>%
ggdotchart(x = "PigID", y = "PPfeedIntake.g",
sorting = "descending", add = "segments", rotate = TRUE,
dot.size = 8, color = "#00AFBB", ylab = "Formula intake (g)")
# Save the figure to a pdf file:
ggsave(plot=Fig2, height=5, width=3, dpi=300, filename="Figure 2/Fig2F_right.pdf", useDingbats=FALSE)
Fig2

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] highr_0.10 cellranger_1.1.0 bslib_0.5.1 compiler_4.2.2
## [5] pillar_1.9.0 jquerylib_0.1.4 tools_4.2.2 digest_0.6.33
## [9] jsonlite_1.8.8 evaluate_1.0.1 lifecycle_1.0.4 tibble_3.2.1
## [13] gtable_0.3.5 pkgconfig_2.0.3 rlang_1.1.2 cli_3.6.2
## [17] rstudioapi_0.15.0 yaml_2.3.7 xfun_0.40 fastmap_1.1.1
## [21] withr_3.0.1 knitr_1.45 systemfonts_1.0.5 generics_0.1.3
## [25] sass_0.4.7 vctrs_0.6.5 grid_4.2.2 tidyselect_1.2.0
## [29] glue_1.6.2 R6_2.5.1 textshaping_0.3.7 rstatix_0.7.2
## [33] fansi_1.0.6 rmarkdown_2.28 carData_3.0-5 farver_2.1.1
## [37] car_3.1-2 tidyr_1.3.0 purrr_1.0.2 magrittr_2.0.3
## [41] backports_1.4.1 scales_1.3.0 htmltools_0.5.6.1 abind_1.4-5
## [45] colorspace_2.1-0 ggsignif_0.6.4 labeling_0.4.3 ragg_1.2.6
## [49] utf8_1.2.4 munsell_0.5.1 broom_1.0.5 cachem_1.0.8