#===============================================================================
# Draw the plot if data follow a normal distribution
#===============================================================================
plot_normal <- function(df, my_colours, my_summary) {
p<-ggplot(data = df, aes(x=Line, y=FvFm)) +
geom_quasirandom(dodge.width=0.8,alpha = 0.6, colour = COLOUR)+
geom_pointrange(data = my_summary, aes(ymin=FvFm-ci, ymax=FvFm+ci, color=Line), position=position_dodge(width=0.8))+
scale_colour_manual(values=my_colours)+
scale_y_continuous(breaks=seq(0,0.8,0.2), limits=c(0,0.95),expand = c(0, 0))+
facet_wrap(~Treatment, strip.position = "bottom", scales = "free_x") +
theme_classic() +
theme(panel.spacing = unit(0, "lines"),
strip.background = element_blank(),
strip.placement = "outside")+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
print(p)
}
#===============================================================================
# Draw the plot if data do not follow a normal distribution
#===============================================================================
plot_not_normal <- function(df, my_colours, conf_int) {
p<-ggplot(data=df, aes(x=Line, y=FvFm)) +
geom_quasirandom(dodge.width=0.8,alpha = 0.6, colour = COLOUR)+
geom_linerange(data = booted_summary, aes(ymin=lower_ci_perc, ymax=upper_ci_perc, color=Line), position = position_dodge(width=0.8))+
geom_point(data=booted_summary, aes(y=FvFm, color=Line), size = 2,
position=position_dodge(width=0.8))+
scale_colour_manual(values=my_colours)+
scale_y_continuous(breaks=seq(0,0.8,0.2), limits=c(0,0.95),expand = c(0, 0))+
facet_wrap(~Treatment, strip.position = "bottom", scales = "free_x") +
theme_classic() +
theme(panel.spacing = unit(0, "lines"),
strip.background = element_blank(),
strip.placement = "outside")+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
print(p)
}
#===============================================================================
# Check normality of the data. Exit the loop if one set of data doesn't follow a
# normal distribution.
# Return TRUE if all data follow a normal distribution
#===============================================================================
check_normality <- function(shapiro_df) {
# Data are supposed to follow normal distribution
flag_normal <- TRUE
for (i in 1 : nrow(shapiro_df)) {
if(shapiro_df[i, 4] > 0.05) {
} else {
flag_normal <- FALSE
break
}
}
return(flag_normal)
}
#===============================================================================
#Function to calculate the median (for bootstrapping)
#===============================================================================
samplemedian <- function(d, i) {
median(d[i])
}
#===============================================================================
#Function for Dunn test
#===============================================================================
test_dunn <- function() {
pval <- as.data.frame(df %>% group_by(Treatment) %>% dunn_test(FvFm ~ Line, p.adjust.method = "BY"))
print(df %>% group_by(Treatment) %>% dunn_test(FvFm ~ Line, p.adjust.method = "BY"))
return(pval)
}