what statistical test is needed for multiple boxplot graph

I want to perform a statistical test for individual grouped data (Line aka Legend F1) to compare the difference between each boxplot. does anyone know the statistical method for this?

data and graph are both included below

thanks

image

Parent Line log
Mock M1 8.055155783
Mock M1 6.173051289
Mock M1 6.838547899
Mock M1 7.051532265
Mock M1 6.890318194
Mock M1 6.341863188
Mock M1 5.959270051
Mock M1 6.815049617
Mock M1 6.082606218
Mock M1 6.864741933
Mock M1 6.795590584
Mock M2 7.984846313
Mock M2 6.250502269
Mock M2 6.401850846
Mock M2 7.043015595
Mock M2 6.494560588
Mock M2 6.714226935
Mock M2 6.792170872
Mock M2 6.795590584
Mock M3 5.599318096
Mock M3 7.43209122
Mock M3 6.795590584
Mock M3 7.211245462
Mock M3 7.969408029
Mock M3 6.507725058
Mock M3 5.693530593
Mock M3 6.670651848
Mock M3 6.850727571
Mock M3 6.781576222
Mock M3 6.733121216
Mock M3 5.909212475
Mock M3 6.099987271
Mock M4 5.730938813
Mock M4 7.864741933
Mock M4 6.930274078
Mock M4 6.480546227
Mock M4 6.83574596
Mock M4 6.193530593
Mock M4 6.221983018
Mock M4 7.030731499
Mock M4 6.225759587
Mock M4 6.369621852
Pst I Pst-I-1 7.773276591
Pst I Pst-I-1 6.670651848
Pst I Pst-I-1 6.409212475
Pst I Pst-I-1 7.43209122
Pst I Pst-I-1 5.617316922
Pst I Pst-I-1 5.082606218
Pst I Pst-I-1 5.983422391
Pst I Pst-I-1 5.693530593
Pst I Pst-I-1 6.255456413
Pst I Pst-I-1 4.554847554
Pst I Pst-I-1 6.933893282
Pst I Pst-I-2 4.35587755
Pst I Pst-I-2 4.724256832
Pst I Pst-I-2 7.556180064
Pst I Pst-I-2 6.723879513
Pst I Pst-I-2 5.642893184
Pst I Pst-I-2 5.714226935
Pst I Pst-I-2 6.189143631
Pst I Pst-I-2 6.821166845
Pst I Pst-I-2 5.714226935
Pst I Pst-I-2 5.795047036
Pst I Pst-I-2 6.933893282
Pst I Pst-I-3 6.901017267
Pst I Pst-I-3 7.834331315
Pst I Pst-I-3 5.316286927
Pst I Pst-I-3 6.631061225
Pst I Pst-I-3 5.253817558
Pst I Pst-I-3 6.746285685
Pst I Pst-I-3 5.971681843
Pst I Pst-I-3 6.631061225
Pst I Pst-I-3 7.403095247
Pst I Pst-I-3 7.005155238
Pst I Pst-I-4 6.532334069
Pst I Pst-I-4 5.505155238
Pst I Pst-I-4 5.082606218
Pst I Pst-I-4 6.522536291
Pst I Pst-I-4 6.582606218
Pst I Pst-I-4 5.567624606
Pst I Pst-I-4 6.381819071
Pst I Pst-I-4 7.568591856
Pst I Pst-I-4 5.99779361
Pst I Pst-I-4 4.573741835
Pst II Pst-II-1 7.706695062
Pst II Pst-II-1 7.001242569
Pst II Pst-II-1 3.209275221
Pst II Pst-II-1 5.011272466
Pst II Pst-II-1 6.155670236
Pst II Pst-II-1 6.43209122
Pst II Pst-II-1 5.218139604
Pst II Pst-II-1 6.067624606
Pst II Pst-II-1 5.306185234
Pst II Pst-II-1 5.847064568
Pst II Pst-II-1 3.161078569
Pst II Pst-II-2 4.76783192
Pst II Pst-II-2 5.779832058
Pst II Pst-II-2 5.247135578
Pst II Pst-II-2 6.145075586
Pst II Pst-II-2 5.645075586
Pst II Pst-II-2 6.741985599
Pst II Pst-II-2 6.145075586
Pst II Pst-II-2 6.821166845
Pst II Pst-II-2 7.179516231
Pst II Pst-II-2 6.583328838
Pst II Pst-II-2 5.535953274
Pst II Pst-II-3 7.178936398
Pst II Pst-II-3 4.806185234
Pst II Pst-II-3 5.272711839
Pst II Pst-II-3 7.014019622
Pst II Pst-II-3 5.722743605
Pst II Pst-II-3 4.904332556
Pst II Pst-II-3 6.93209122
Pst II Pst-II-3 5.909212475
Pst II Pst-II-3 7.679516231
Pst II Pst-II-3 6.917109608
Pst II Pst-II-4 6.02013685
Pst II Pst-II-4 3.058760223
Pst II Pst-II-4 6.284452387
Pst II Pst-II-4 6.214226935
Pst II Pst-II-4 6.182392395
Pst II Pst-II-4 3.698680571
Pst II Pst-II-4 6.155670236
Pst II Pst-II-4 6.051532265
Pst II Pst-II-4 6.218139604
Pst II Pst-II-4 5.816779883
Pst III Pst-III-1 7.182392395
Pst III Pst-III-1 7.05257374
Pst III Pst-III-1 4.757730227
Pst III Pst-III-1 5.952787563
Pst III Pst-III-1 6.155670236
Pst III Pst-III-1 5.905971411
Pst III Pst-III-1 6.52013685
Pst III Pst-III-1 6.821166845
Pst III Pst-III-1 5.883636214
Pst III Pst-III-1 5.903673535
Pst III Pst-III-1 4.573741835
Pst III Pst-III-2 5.118301719
Pst III Pst-III-2 4.503411074
Pst III Pst-III-2 5.645075586
Pst III Pst-III-2 6.838547899
Pst III Pst-III-2 6.043015595
Pst III Pst-III-2 2.758967537
Pst III Pst-III-2 5.559727473
Pst III Pst-III-2 5.901017267
Pst III Pst-III-2 5.766594611
Pst III Pst-III-2 5.6269695
Pst III Pst-III-2 6.272711839
Pst III Pst-III-3 6.210242471
Pst III Pst-III-3 6.034151212
Pst III Pst-III-3 2.786726201
Pst III Pst-III-3 6.255456413
Pst III Pst-III-3 3.068861916
Pst III Pst-III-3 6.184666209
Pst III Pst-III-3 6.353603736
Pst III Pst-III-3 4.59662058
Pst III Pst-III-3 6.903095247
Pst III Pst-III-3 5.335181207
Pst III Pst-III-4 6.682849067
Pst III Pst-III-4 7.599987271
Pst III Pst-III-4 5.743715865
Pst III Pst-III-4 6.582606218
Pst III Pst-III-4 5.561330043
Pst III Pst-III-4 5.645075586
Pst III Pst-III-4 6.480546227
Pst III Pst-III-4 3.640511289
Pst III Pst-III-4 6.608182479
Pst III Pst-III-4 5.816779883
1 Like

Hi, It seems you could conduct 2-way analysis of variance model or quantile regression model.

See the FAQ: How to do a minimal reproducible example reprex for beginners. It's not difficult to convert the table to a data frame but the unnecessary effort is an impediment to receiving answers.

The following example has been derived from [this post]((ANOVA in R - Stats and R) using your data and should be studied using that link.

suppressPackageStartupMessages({
  library(car)
  library(dplyr)
  library(ggplot2)
  library(ggpubr)
  library(multcomp)
  library(palmerpenguins)
  library(patchwork)
})

dat <- data.frame(
  Parent =
    as.factor(c("Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Mock", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_I", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_II", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III", "Pst_III")),
  Line =
    as.factor(c("M1", "M1", "M1", "M1", "M1", "M1", "M1", "M1", "M1", "M1", "M1", "M2", "M2", "M2", "M2", "M2", "M2", "M2", "M2", "M3", "M3", "M3", "M3", "M3", "M3", "M3", "M3", "M3", "M3", "M3", "M3", "M3", "M4", "M4", "M4", "M4", "M4", "M4", "M4", "M4", "M4", "M4", "Pst_I_1", "Pst_I_1", "Pst_I_1", "Pst_I_1", "Pst_I_1", "Pst_I_1", "Pst_I_1", "Pst_I_1", "Pst_I_1", "Pst_I_1", "Pst_I_1", "Pst_I_2", "Pst_I_2", "Pst_I_2", "Pst_I_2", "Pst_I_2", "Pst_I_2", "Pst_I_2", "Pst_I_2", "Pst_I_2", "Pst_I_2", "Pst_I_2", "Pst_I_3", "Pst_I_3", "Pst_I_3", "Pst_I_3", "Pst_I_3", "Pst_I_3", "Pst_I_3", "Pst_I_3", "Pst_I_3", "Pst_I_3", "Pst_I_4", "Pst_I_4", "Pst_I_4", "Pst_I_4", "Pst_I_4", "Pst_I_4", "Pst_I_4", "Pst_I_4", "Pst_I_4", "Pst_I_4", "Pst_II_1", "Pst_II_1", "Pst_II_1", "Pst_II_1", "Pst_II_1", "Pst_II_1", "Pst_II_1", "Pst_II_1", "Pst_II_1", "Pst_II_1", "Pst_II_1", "Pst_II_2", "Pst_II_2", "Pst_II_2", "Pst_II_2", "Pst_II_2", "Pst_II_2", "Pst_II_2", "Pst_II_2", "Pst_II_2", "Pst_II_2", "Pst_II_2", "Pst_II_3", "Pst_II_3", "Pst_II_3", "Pst_II_3", "Pst_II_3", "Pst_II_3", "Pst_II_3", "Pst_II_3", "Pst_II_3", "Pst_II_3", "Pst_II_4", "Pst_II_4", "Pst_II_4", "Pst_II_4", "Pst_II_4", "Pst_II_4", "Pst_II_4", "Pst_II_4", "Pst_II_4", "Pst_II_4", "Pst_III_1", "Pst_III_1", "Pst_III_1", "Pst_III_1", "Pst_III_1", "Pst_III_1", "Pst_III_1", "Pst_III_1", "Pst_III_1", "Pst_III_1", "Pst_III_1", "Pst_III_2", "Pst_III_2", "Pst_III_2", "Pst_III_2", "Pst_III_2", "Pst_III_2", "Pst_III_2", "Pst_III_2", "Pst_III_2", "Pst_III_2", "Pst_III_2", "Pst_III_3", "Pst_III_3", "Pst_III_3", "Pst_III_3", "Pst_III_3", "Pst_III_3", "Pst_III_3", "Pst_III_3", "Pst_III_3", "Pst_III_3", "Pst_III_4", "Pst_III_4", "Pst_III_4", "Pst_III_4", "Pst_III_4", "Pst_III_4", "Pst_III_4", "Pst_III_4", "Pst_III_4", "Pst_III_4")),
  Log =
    c(8.055155783, 6.173051289, 6.838547899, 7.051532265, 6.890318194, 6.341863188, 5.959270051, 6.815049617, 6.082606218, 6.864741933, 6.795590584, 7.984846313, 6.250502269, 6.401850846, 7.043015595, 6.494560588, 6.714226935, 6.792170872, 6.795590584, 5.599318096, 7.43209122, 6.795590584, 7.211245462, 7.969408029, 6.507725058, 5.693530593, 6.670651848, 6.850727571, 6.781576222, 6.733121216, 5.909212475, 6.099987271, 5.730938813, 7.864741933, 6.930274078, 6.480546227, 6.83574596, 6.193530593, 6.221983018, 7.030731499, 6.225759587, 6.369621852, 7.773276591, 6.670651848, 6.409212475, 7.43209122, 5.617316922, 5.082606218, 5.983422391, 5.693530593, 6.255456413, 4.554847554, 6.933893282, 4.35587755, 4.724256832, 7.556180064, 6.723879513, 5.642893184, 5.714226935, 6.189143631, 6.821166845, 5.714226935, 5.795047036, 6.933893282, 6.901017267, 7.834331315, 5.316286927, 6.631061225, 5.253817558, 6.746285685, 5.971681843, 6.631061225, 7.403095247, 7.005155238, 6.532334069, 5.505155238, 5.082606218, 6.522536291, 6.582606218, 5.567624606, 6.381819071, 7.568591856, 5.99779361, 4.573741835, 7.706695062, 7.001242569, 3.209275221, 5.011272466, 6.155670236, 6.43209122, 5.218139604, 6.067624606, 5.306185234, 5.847064568, 3.161078569, 4.76783192, 5.779832058, 5.247135578, 6.145075586, 5.645075586, 6.741985599, 6.145075586, 6.821166845, 7.179516231, 6.583328838, 5.535953274, 7.178936398, 4.806185234, 5.272711839, 7.014019622, 5.722743605, 4.904332556, 6.93209122, 5.909212475, 7.679516231, 6.917109608, 6.02013685, 3.058760223, 6.284452387, 6.214226935, 6.182392395, 3.698680571, 6.155670236, 6.051532265, 6.218139604, 5.816779883, 7.182392395, 7.05257374, 4.757730227, 5.952787563, 6.155670236, 5.905971411, 6.52013685, 6.821166845, 5.883636214, 5.903673535, 4.573741835, 5.118301719, 4.503411074, 5.645075586, 6.838547899, 6.043015595, 2.758967537, 5.559727473, 5.901017267, 5.766594611, 5.6269695, 6.272711839, 6.210242471, 6.034151212, 2.786726201, 6.255456413, 3.068861916, 6.184666209, 6.353603736, 4.59662058, 6.903095247, 5.335181207, 6.682849067, 7.599987271, 5.743715865, 6.582606218, 5.561330043, 5.645075586, 6.480546227, 3.640511289, 6.608182479, 5.816779883))

# use only one parent line, to simplify illustration

# mocks <- dat[which(dat[,1] == "Mock"),]

summary(dat)
#>      Parent         Line          Log       
#>  Mock   :42   M3      : 13   Min.   :2.759  
#>  Pst_I  :42   M1      : 11   1st Qu.:5.681  
#>  Pst_II :42   Pst_I_1 : 11   Median :6.212  
#>  Pst_III:42   Pst_I_2 : 11   Mean   :6.117  
#>               Pst_II_1: 11   3rd Qu.:6.800  
#>               Pst_II_2: 11   Max.   :8.055  
#>               (Other) :100

p1 <- ggplot(dat) +
  aes(x = Parent, y = Log, color = Parent) +
  geom_jitter() +
  theme(legend.position = "none") +
  theme_minimal()

p2 <- ggplot(dat) +
  aes(x = Parent, y = Log, color = Parent) +
  geom_boxplot() +
  theme(legend.position = "none") +
  theme_minimal()

p3 <- ggplot(dat) +
  aes(Log, fill = Parent) +
  geom_dotplot(method = "histodot", binwidth = 1.5) +
  theme(legend.position = "none") +
  theme_minimal()

p1 + p2 + p3

res_aov <- aov(Log ~ Parent, data = dat)

resids <- data.frame(.resid = res_aov$residuals)

# histogram
p4 <- ggplot(resids, aes(.resid)) +
  geom_histogram(color = "black", fill = "grey") +
  theme_minimal()

p5 <- ggplot(resids, aes(sample = .resid)) +
  stat_qq() +
  stat_qq_line() +
  theme_minimal()

p4 + p5
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

shapiro.test(res_aov$residuals)
#> 
#>  Shapiro-Wilk normality test
#> 
#> data:  res_aov$residuals
#> W = 0.95189, p-value = 1.663e-05

leveneTest(Log ~ Parent, data = dat)
#> Levene's Test for Homogeneity of Variance (center = median)
#>        Df F value  Pr(>F)  
#> group   3  2.6809 0.04866 *
#>       164                  
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

aggregate(Log ~ Parent,
          data = dat,
          function(x) round(c(mean = mean(x), sd = sd(x)), 2)
)
#>    Parent Log.mean Log.sd
#> 1    Mock     6.68   0.60
#> 2   Pst_I     6.20   0.91
#> 3  Pst_II     5.85   1.12
#> 4 Pst_III     5.73   1.12

group_by(dat, Parent) %>%
  summarise(
    mean = mean(Log, na.rm = TRUE),
    sd = sd(Log, na.rm = TRUE)
  )
#> # A tibble: 4 x 3
#>   Parent   mean    sd
#>   <fct>   <dbl> <dbl>
#> 1 Mock     6.68 0.596
#> 2 Pst_I    6.20 0.907
#> 3 Pst_II   5.85 1.12 
#> 4 Pst_III  5.73 1.12

oneway.test(Log ~ Parent,
            data = dat,
            var.equal = TRUE # assuming equal variances
)
#> 
#>  One-way analysis of means
#> 
#> data:  Log and Parent
#> F = 8.2319, num df = 3, denom df = 164, p-value = 3.899e-05

res_aov <- aov(Log ~ Parent,
               data = dat
)

summary(res_aov)
#>              Df Sum Sq Mean Sq F value  Pr(>F)    
#> Parent        3  22.67   7.558   8.232 3.9e-05 ***
#> Residuals   164 150.57   0.918                    
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

oneway.test(Log ~ Parent,
            data = dat,
            var.equal = FALSE # assuming unequal variances
)
#> 
#>  One-way analysis of means (not assuming equal variances)
#> 
#> data:  Log and Parent
#> F = 11.43, num df = 3.00, denom df = 87.72, p-value = 2.13e-06

post_test <- glht(res_aov,
                  linfct = mcp(Parent = "Tukey")
)

summary(post_test)
#> 
#>   Simultaneous Tests for General Linear Hypotheses
#> 
#> Multiple Comparisons of Means: Tukey Contrasts
#> 
#> 
#> Fit: aov(formula = Log ~ Parent, data = dat)
#> 
#> Linear Hypotheses:
#>                       Estimate Std. Error t value Pr(>|t|)    
#> Pst_I - Mock == 0      -0.4737     0.2091  -2.266    0.110    
#> Pst_II - Mock == 0     -0.8271     0.2091  -3.956   <0.001 ***
#> Pst_III - Mock == 0    -0.9440     0.2091  -4.515   <0.001 ***
#> Pst_II - Pst_I == 0    -0.3533     0.2091  -1.690    0.332    
#> Pst_III - Pst_I == 0   -0.4703     0.2091  -2.249    0.115    
#> Pst_III - Pst_II == 0  -0.1170     0.2091  -0.559    0.944    
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> (Adjusted p values reported -- single-step method)

par(mar = c(3, 8, 3, 3))
plot(post_test)

TukeyHSD(res_aov)
#>   Tukey multiple comparisons of means
#>     95% family-wise confidence level
#> 
#> Fit: aov(formula = Log ~ Parent, data = dat)
#> 
#> $Parent
#>                      diff        lwr         upr     p adj
#> Pst_I-Mock     -0.4737345 -1.0164396  0.06897055 0.1104074
#> Pst_II-Mock    -0.8270620 -1.3697671 -0.28435691 0.0006507
#> Pst_III-Mock   -0.9440129 -1.4867179 -0.40130778 0.0000707
#> Pst_II-Pst_I   -0.3533275 -0.8960325  0.18937762 0.3323298
#> Pst_III-Pst_I  -0.4702783 -1.0129834  0.07242675 0.1145360
#> Pst_III-Pst_II -0.1169509 -0.6596560  0.42575421 0.9438792

plot(TukeyHSD(res_aov))

# Dunnett's test:
post_test <- glht(res_aov,
                  linfct = mcp(species = "Dunnett")
)
#> Error in mcp2matrix(model, linfct = linfct): Variable(s) 'species' have been specified in 'linfct' but cannot be found in 'model'!

summary(post_test)
#> 
#>   Simultaneous Tests for General Linear Hypotheses
#> 
#> Multiple Comparisons of Means: Tukey Contrasts
#> 
#> 
#> Fit: aov(formula = Log ~ Parent, data = dat)
#> 
#> Linear Hypotheses:
#>                       Estimate Std. Error t value Pr(>|t|)    
#> Pst_I - Mock == 0      -0.4737     0.2091  -2.266    0.110    
#> Pst_II - Mock == 0     -0.8271     0.2091  -3.956   <0.001 ***
#> Pst_III - Mock == 0    -0.9440     0.2091  -4.515   <0.001 ***
#> Pst_II - Pst_I == 0    -0.3533     0.2091  -1.690    0.332    
#> Pst_III - Pst_I == 0   -0.4703     0.2091  -2.249    0.115    
#> Pst_III - Pst_II == 0  -0.1170     0.2091  -0.559    0.944    
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> (Adjusted p values reported -- single-step method)

par(mar = c(3, 8, 3, 3))
plot(post_test)

dat$Parent <- relevel(dat$Parent, ref = "Mock")

res_aov2 <- aov(Log ~ Parent,
                data = dat
)

# Dunnett's test:
post_test <- glht(res_aov2,
                  linfct = mcp(Parent = "Dunnett")
)

summary(post_test)
#> 
#>   Simultaneous Tests for General Linear Hypotheses
#> 
#> Multiple Comparisons of Means: Dunnett Contrasts
#> 
#> 
#> Fit: aov(formula = Log ~ Parent, data = dat)
#> 
#> Linear Hypotheses:
#>                     Estimate Std. Error t value Pr(>|t|)    
#> Pst_I - Mock == 0    -0.4737     0.2091  -2.266   0.0647 .  
#> Pst_II - Mock == 0   -0.8271     0.2091  -3.956   <0.001 ***
#> Pst_III - Mock == 0  -0.9440     0.2091  -4.515   <0.001 ***
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> (Adjusted p values reported -- single-step method)

par(mar = c(3, 8, 3, 3))
plot(post_test)

pairwise.t.test(dat$Log, dat$Parent,
                p.adjust.method = "holm"
)
#> 
#>  Pairwise comparisons using t tests with pooled SD 
#> 
#> data:  dat$Log and dat$Parent 
#> 
#>         Mock    Pst_I   Pst_II 
#> Pst_I   0.09911 -       -      
#> Pst_II  0.00057 0.18592 -      
#> Pst_III 7.2e-05 0.09911 0.57670
#> 
#> P value adjustment method: holm

x <- which(names(dat) == "Parent") # name of grouping variable
y <- which(
  names(dat) == "Log" # names of variables to test
)
method1 <- "anova" # one of "anova" or "kruskal.test"
method2 <- "t.test" # one of "wilcox.test" or "t.test"
my_comparisons <- list(c("Mock", "Pst_I"), c("Pst_I", "Pst_II"), c("Pst_II", "Pst_III")) # comparisons for post-hoc tests

for (i in y) {
  for (j in x) {
    p <- ggboxplot(dat,
      x = colnames(dat[j]), y = colnames(dat[i]),
      color = colnames(dat[j]),
      legend = "none",
      palette = "npg",
      add = "jitter"
    )
    print(
      p + stat_compare_means(aes(label = paste0(..method.., ", p-value = ", ..p.format..)),
        method = method1, label.y = max(dat[, i], na.rm = TRUE)
      )
      + stat_compare_means(comparisons = my_comparisons, method = method2, label = "p.format") # remove if p-value of ANOVA or Kruskal-Wallis test >= alpha
    )
  }
}

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.