###Cleaning Experiment-S magnus### # Data type: presence (1) - absence (0) #Packages: library(plyr) library(dplyr) library(ggplot2) library(vegan) library(multcomp) library(ggplot2) library(tidyverse) library(ggthemes) library(multcompView) ##############Data preparation------- SM<-read.csv2("Sm_results.csv") percent<-read.csv2("Sm_results_percent.csv") plot(Chae~Name,data=SM) SM$Name<-as.factor(SM$Name) ### Stats in Plot #### ## Source: Rosane Rech ## https://statdoe.com/cld-customisation/#adding-the-letters-indicating-significant-differences ## https://www.youtube.com/watch?v=Uyof3S1gx3M # analysis of variance anova <- aov(Chae ~ Name, data = SM) anova summary(anova) # Tukey's test tukey <- TukeyHSD(anova) tukey # compact letter display cld <- multcompLetters4(anova, tukey) cld # table with factors and 3rd quantile dt <- group_by(percent, Name) %>% #summarise(cg=mean(percent$Chae_detection), sd = sd(percent$Chae_detection)) %>% arrange(desc(percent$Chae_detection)) # extracting the compact letter display and adding to the Tk table cld <- as.data.frame.list(cld$Name) dt$cld <- cld$Letters print(dt$cld) print(dt) Chae_detection_grey <- ggplot(dt, aes(x = reorder(Name, - Chae_detection), y = Chae_detection), fill = type)+ geom_bar(stat = "identity", color="black", fill="White", show.legend = FALSE) + #geom_errorbar(aes(ymin = Chae-sd, ymax=Chae+sd), width = 0.2) + labs(x = "Method", y = expression(paste(italic("Chaetomium" )," detection %"))) + geom_text(aes(label = cld), vjust = -0.5) + ylim(0,100) + theme(axis.title.y = element_text(size = 14), axis.text.y = element_text(size = 12), axis.title.x = element_text(size = 14), axis.text.x = element_text("Name", angle = 45, size = 12, hjust = 1, vjust = 1)) Chae_detection_grey ggsave("Chae_detection_grey.png", width = 190, height = 160, units = "mm", plot = Chae_detection_grey ) ##Plectus detection #### SM <- read.csv2("Sm_results.csv") plec<-read.csv2("Sm_results_plec.csv") SM$Name<-as.factor(SM$Name) ## Plectus detection stats #### # analysis of variance anova_plec <- aov(Plec ~ Name, data = SM) anova_plec summary(anova_plec) # Tukey's test tukey_plec <- TukeyHSD(anova_plec) tukey_plec # compact letter display cld_plec <- multcompLetters4(anova_plec, tukey_plec) cld_plec # table with factors and 3rd quantile dt <- group_by(plec, Name) %>% #summarise(cg=mean(percent$Chae_detection), sd = sd(percent$Chae_detection)) %>% arrange(desc(plec$Plec_detection)) # extracting the compact letter display and adding to the Tk table cld_plec <- as.data.frame.list(cld_plec$Name) dt$cld_plec <- cld_plec$Letters print(dt$cld_plec) print(dt) Plec_detection <- ggplot(dt, aes(x = reorder(Name, - Plec_detection), y = Plec_detection), fill = type)+ geom_bar(stat = "identity", color="black", fill="White", show.legend = FALSE) + #geom_errorbar(aes(ymin = Chae-sd, ymax=Chae+sd), width = 0.2) + labs(x = "Method", y = expression(paste(italic("Plectus" )," sp. detection %"))) + geom_text(aes(label = cld_plec), vjust = -0.5) + ylim(0,60) + theme(axis.title.y = element_text(size = 14), axis.text.y = element_text(size = 12), axis.title.x = element_text(size = 14), axis.text.x = element_text("Name", angle = 45, size = 12, hjust = 1, vjust = 1)) #theme_bw() #theme_few() Plec_detection ggsave("Plectus_detection.png", width = 190, height = 160, units = "mm", plot = Plec_detection )