The four colonies on one dish share medium, bacterium, handling and photograph; they are not independent replicates. Treating them as such (pseudoreplication, Hurlbert 1984) inflates the evidence. This function therefore fits a linear mixed model with a random intercept per plate (lme4), or, if lme4 is not installed or the design has too few plates, analyses plate means with Welch's t-test / one-way ANOVA.

compare_melanization(
  colonies,
  response = "MI_mean",
  group = "treatment",
  plate = "plate_id",
  reference = NULL,
  method = c("auto", "mixed", "plate_means")
)

Arguments

colonies

Colony table (e.g. out$colonies from analyze_plates()) containing the response, the group variable and plate_id.

response

Response column (default "MI_mean").

group

Treatment column.

plate

Plate identifier column.

reference

Optional reference level of group (e.g. "control").

method

"auto", "mixed" or "plate_means".

Value

A list with the fitted model, a coefficient table with 95 % CIs, the intra-plate correlation (ICC) and per-group descriptive statistics.

Examples

set.seed(1)
d <- data.frame(plate_id = rep(sprintf("p%02d", 1:10), each = 4),
                treatment = rep(c("control", "bacteria"), each = 20))
d$MI_mean <- 50 + 3 * (d$treatment == "bacteria") +
  rep(rnorm(10, 0, 1.5), each = 4) + rnorm(40, 0, 1)
compare_melanization(d, group = "treatment", reference = "control")
#> $method
#> [1] "linear mixed model: response ~ group + (1 | plate)"
#> 
#> $coefficients
#>          term  estimate        se          t    lower     upper df_approx
#> 1 (Intercept) 50.251491 0.4780187 105.124533 49.31459 51.188390         8
#> 2    bacteria  3.078646 0.6760205   4.554072  1.75367  4.403622         8
#>       p_value
#> 1 7.48952e-14
#> 2 1.86437e-03
#> 
#> $icc
#> [1] 0.5861397
#> 
#> $descriptives
#>             group n_plates n_colonies     mean sd_between_plates
#> control   control       10         20 50.25149                NA
#> bacteria bacteria       10         20 53.33014                NA
#>          sd_within_plates
#> control         0.9828557
#> bacteria        0.6366542
#> 
#> $model
#> Linear mixed model fit by REML ['lmerMod']
#> Formula: .y ~ .g + (1 | .p)
#>    Data: df
#> REML criterion at convergence: 114.6661
#> Random effects:
#>  Groups   Name        Std.Dev.
#>  .p       (Intercept) 0.9854  
#>  Residual             0.8281  
#> Number of obs: 40, groups:  .p, 10
#> Fixed Effects:
#> (Intercept)   .gbacteria  
#>      50.251        3.079  
#> 
#> $note
#> [1] "p-values use a conservative between-plate df approximation (n_plates - n_groups)."
#>