Clean up the environment
rm(list = ls())
Load necessary libraries for data reading, plotting, and statistical
analysis
library(readxl) # For reading Excel files
library(ggpubr) # For creating publication-ready plots
library(dplyr) # For data manipulation
library(ggh4x) # For advanced faceting 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
# Load cytokine measurements and pig information
Cytokines <- read_excel("Data/Data.xlsx", sheet = "Nec_serum_cytokines")
PigInfo <- read_excel("Data/Data.xlsx", sheet = "PigInfo")
Plotting IFN-gamma levels
Fig <- Cytokines %>% inner_join(PigInfo, by = "PigID") %>%
rename(IFNgamma =`IFN-gamma`) %>%
select(Diet, IFNgamma) %>%
mutate(TimePoint = "Day 16") %>%
ggerrorplot(x = "TimePoint", y = "IFNgamma", color = "Diet",
palette = c("turquoise3","purple", "orange"),
na.rm = TRUE, xlab = "",
ylab ="IFN-gamma (ug/L)", add = "mean_se", position = position_dodge(0.6)) +
facet_nested(.~ TimePoint , scales = "free", space = "free_x") +
theme_classic() +
theme(axis.text.x = element_blank(), axis.ticks.x = element_blank())
Fig

# Save the figure in pdf format
ggsave(plot=Fig, height=4, width=3.3, dpi=300, filename="Figure 6/Fig6B.pdf", useDingbats=FALSE)
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