# Pairwise comparisons for complex
comparisons_complex <- list(c("low", "medium"), c("low", "high"), c("medium", "high"))
# Observed richness
p1 <- ggplot(alpha_div, aes(x = complex, y = observed, fill = complex)) +
geom_boxplot(outlier.shape = NA, alpha = 0.7) +
geom_jitter(width = 0.2, size = 2, alpha = 0.6) +
scale_fill_manual(values = complex_colors) +
stat_compare_means(method = "kruskal.test", label.x = 1.5, label.y = max(alpha_div$observed) * 1.1) +
stat_compare_means(comparisons = comparisons_complex, method = "wilcox.test",
label = "p.signif", hide.ns = TRUE) +
labs(x = "Complex", y = "Observed Species", title = "Observed Richness") +
theme_publication +
theme(legend.position = "none")
# Shannon
p2 <- ggplot(alpha_div, aes(x = complex, y = shannon, fill = complex)) +
geom_boxplot(outlier.shape = NA, alpha = 0.7) +
geom_jitter(width = 0.2, size = 2, alpha = 0.6) +
scale_fill_manual(values = complex_colors) +
stat_compare_means(method = "kruskal.test", label.x = 1.5, label.y = max(alpha_div$shannon) * 1.1) +
stat_compare_means(comparisons = comparisons_complex, method = "wilcox.test",
label = "p.signif", hide.ns = TRUE) +
labs(x = "Complex", y = "Shannon Index", title = "Shannon Diversity") +
theme_publication +
theme(legend.position = "none")
# Simpson
p3 <- ggplot(alpha_div, aes(x = complex, y = simpson, fill = complex)) +
geom_boxplot(outlier.shape = NA, alpha = 0.7) +
geom_jitter(width = 0.2, size = 2, alpha = 0.6) +
scale_fill_manual(values = complex_colors) +
stat_compare_means(method = "kruskal.test", label.x = 1.5, label.y = max(alpha_div$simpson) * 1.05) +
stat_compare_means(comparisons = comparisons_complex, method = "wilcox.test",
label = "p.signif", hide.ns = TRUE) +
labs(x = "Complex", y = "Simpson Index", title = "Simpson Diversity") +
theme_publication +
theme(legend.position = "none")
# Inverse Simpson
p4 <- ggplot(alpha_div, aes(x = complex, y = invsimpson, fill = complex)) +
geom_boxplot(outlier.shape = NA, alpha = 0.7) +
geom_jitter(width = 0.2, size = 2, alpha = 0.6) +
scale_fill_manual(values = complex_colors) +
stat_compare_means(method = "kruskal.test", label.x = 1.5, label.y = max(alpha_div$invsimpson) * 1.1) +
stat_compare_means(comparisons = comparisons_complex, method = "wilcox.test",
label = "p.signif", hide.ns = TRUE) +
labs(x = "Complex", y = "Inverse Simpson", title = "Inverse Simpson") +
theme_publication +
theme(legend.position = "none")
# Chao1
p5 <- ggplot(alpha_div, aes(x = complex, y = chao1, fill = complex)) +
geom_boxplot(outlier.shape = NA, alpha = 0.7) +
geom_jitter(width = 0.2, size = 2, alpha = 0.6) +
scale_fill_manual(values = complex_colors) +
stat_compare_means(method = "kruskal.test", label.x = 1.5, label.y = max(alpha_div$chao1) * 1.1) +
stat_compare_means(comparisons = comparisons_complex, method = "wilcox.test",
label = "p.signif", hide.ns = TRUE) +
labs(x = "Complex", y = "Chao1 Index", title = "Chao1 Richness") +
theme_publication +
theme(legend.position = "none")
# Pielou evenness
p6 <- ggplot(alpha_div, aes(x = complex, y = pielou, fill = complex)) +
geom_boxplot(outlier.shape = NA, alpha = 0.7) +
geom_jitter(width = 0.2, size = 2, alpha = 0.6) +
scale_fill_manual(values = complex_colors) +
stat_compare_means(method = "kruskal.test", label.x = 1.5, label.y = max(alpha_div$pielou, na.rm = TRUE) * 1.05) +
stat_compare_means(comparisons = comparisons_complex, method = "wilcox.test",
label = "p.signif", hide.ns = TRUE) +
labs(x = "Complex", y = "Pielou's Evenness", title = "Pielou Evenness") +
theme_publication +
theme(legend.position = "none")
# Combine plots
(p1 | p2 | p3) / (p4 | p5 | p6) +
plot_annotation(title = "Alpha Diversity by Diet Complexity",
theme = theme(plot.title = element_text(hjust = 0.5, face = "bold", size = 16)))