1

The intent is to combine the numerical variables on a sigle plot of 2 by 2 or a single stack, with the x-axis being the "Treatments" factor. Each treatment in the barchart represents the different periods. Since there will be letters indicating significant difference on Periods, i've been trying to carryout a t-test on the Periods, Treatment-wise, for each numerical variable case; but how?

Here's how the data is structured:

CAT SOD GSH MDA Treatments  Period
2.06    5.18    8.12    2.5 CFP0    Pre-challenge
2.02    5.14    8.18    2.7 CFP0    Pre-challenge
2.68    5.11    8.01    3.12    CFP1    Pre-challenge
2.66    6.15    8.21    3.53    CFP1    Pre-challenge
2.7 5.84    8   4.3 CFP2    Pre-challenge
2.76    5.86    8.2 4.27    CFP2    Pre-challenge
2.92    6.35    7.14    4.79    CFP3    Pre-challenge
2.72    6.35    7.1 4.83    CFP3    Pre-challenge
3.01    7.19    6.36    5   CFP4    Pre-challenge
2.81    7.17    6.42    5.02    CFP4    Pre-challenge
3   8.29    5.13    6.5 CFP5    Pre-challenge
3.2 9.87    5.17    6.58    CFP5    Pre-challenge
5.58    7.12    8.52    7.6 CFP0    Post-challenge
5.4 7.14    8.58    9.2 CFP0    Post-challenge
3.93    4.2 7.4 4.04    CFP1    Post-challenge
3.77    4.5 7.8 4.03    CFP1    Post-challenge
3.81    4.6 7.1 4.2 CFP2    Post-challenge
3.95    4.26    7.86    4.7 CFP2    Post-challenge
3.81    4.68    7.2 4.6 CFP3    Post-challenge
4.2 4.58    7.41    4.7 CFP3    Post-challenge
4.6 6.18    8.3 7.6 CFP4    Post-challenge
4.9 6.09    8.4 7.9 CFP4    Post-challenge
4.9 6.2 8.2 8.96    CFP5    Post-challenge
4.8 6.16    7.9 9.02    CFP5    Post-challenge

I visualized this barplot with the following code but still unsure about implementing t.test():

library(readxl)
library(ggpubr)
immun <- read_excel("P_II.xlsx", sheet = "imm_data")
summary(immun)

immun$Period <- as.factor(immun$Period)
immun$Treatments <- as.factor(immun$Treatments)

imm <- ggbarplot(immun, x = "Treatments", y = c("Lysozyme"), combine = TRUE, color = "Period", width = 0.5,add = "mean_se", error.plot = "errorbar", palette = c("#585858","#c6c6c6"), fill = "Period", position = position_dodge(0.6))
ggpar(imm, ylim = c(120, 190), ylab = "Lysozyme (pg/mL)", title = "Lysozyme")

Better view of sample dataset

  • The first piece of advice is that you should not be doing t-tests for this type of design because it inflates your Type I Error. If I understand your experiment, you have something that resembles a special case of a randomized block design with an ordering in your `Treatments` variable. This would require a linear models approach, such as a modification of a two-way ANOVA. If you discover differences, then you can consider doing multiple pairwise comparisons while adjusting for an experiment-wise alpha (not `t.test()` but `multcomp`. – David Jun 20 '23 at 20:50
  • To your question about visualization, you could potentially do something like this: https://stackoverflow.com/questions/34140476/two-sided-bar-plot-ordered-by-date?rq=2 . In your case, you could show Pre on the positive Y axis and Post on the negative Y axis, grouped by `Treatments` and with the `CAT`, `SOD` and so on as a within-Treatments variable. You would have to reformat your data a bit to do this type of plot. – David Jun 20 '23 at 21:01
  • Thanks, @David, I will explore this option. – Muhammad Bello Jun 21 '23 at 07:19

0 Answers0