This notebook contains code for the EVT, FW, DW, WC analysis of cowpea phenotyping screen #5.

list.files(pattern = ".csv")
## [1] "exp5_EVT.csv"       "exp5_FW_DW_WC.csv"  "exp5_photosynq.csv"
## [4] "exp5_pot_geno.csv"
EVT_exp5 <- read.csv("exp5_EVT.CSV")
EVT_exp5
library("ggplot2")
library("reshape2")
library("cowplot")
library("ggpubr")
## 
## Attaching package: 'ggpubr'
## The following object is masked from 'package:cowplot':
## 
##     get_legend
melt5_EVT <- melt(EVT_exp5, id.vars = c("Pot.number", "Genotype", "Treatment"))

colnames(melt5_EVT)[4] <- "Day"
colnames(melt5_EVT)[5] <- "Evapotranspiration"
melt5_EVT$Day <- gsub("X", "", melt5_EVT$Day)
melt5_EVT$Day <- as.numeric(melt5_EVT$Day)
unique(melt5_EVT$Treatment)
## [1] "Control " "Drought"  "Control"
melt5_EVT$Treatment <- gsub("Control ", "Control", melt5_EVT$Treatment)
melt5_EVT$Evapotranspiration <- as.numeric(melt5_EVT$Evapotranspiration)

melt5_EVTb <- na.omit(melt5_EVT, c("Evapotranspiration"))
melt5_EVTb
melt5_EVTc <- subset(melt5_EVTb, melt5_EVTb$Evapotranspiration >= 0)
melt5_EVTc
#write.csv(melt5_EVTc, "EVT_exp5_melted.csv", row.names = TRUE)

###Plotting of EVT over time

melt5_EVTc$Pot.number <- as.numeric(melt5_EVTc$Pot.number)

EVT5_over_time <- ggplot(data = melt5_EVTc, aes(x = Day, y = Evapotranspiration, group = Pot.number, colour = Treatment), na.rm = TRUE) + theme_classic() + ylim(0, NA)
EVT5_over_time <- EVT5_over_time + geom_line(alpha = 0.1)
EVT5_over_time <- EVT5_over_time + stat_summary(fun.data = mean_se, linetype = 0, aes(group = Treatment), alpha = 0.3) + stat_summary(fun = mean, aes(group = Treatment), size = 0.7, geom = "line", linetype = "dashed")
EVT5_over_time <- EVT5_over_time + facet_wrap(~ Treatment)
EVT5_over_time <- EVT5_over_time + ylab("Evapotranspiration (g)") + xlab("Day") + rremove("legend")
EVT5_over_time

melt5_EVTc$Day <- as.factor(melt5_EVTc$Day)

EVT5_graph_cd <- ggplot(data = melt5_EVTc, aes(x = Day, y = Evapotranspiration, group = Pot.number, colour = Treatment), na.rm = TRUE) + theme_classic() + ylim(0, NA)
EVT5_graph_cd <- EVT5_graph_cd + geom_line(alpha = 0.1)
EVT5_graph_cd <- EVT5_graph_cd + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = Treatment), alpha = 0.1) + stat_summary(fun = mean, aes(group = Treatment), size = 0.7, geom = "line", linetype = "dashed")
EVT5_graph_cd <- EVT5_graph_cd + stat_compare_means(aes(group = Treatment), label = "p.signif", method = "t.test", hide.ns = TRUE)
EVT5_graph_cd <- EVT5_graph_cd + scale_color_manual(labels=c("Control", "Drought"), values=c("blue", "red"))
EVT5_graph_cd <- EVT5_graph_cd + ylab("Evapotranspiration (g)") + xlab("Day")
EVT5_graph_cd

###FW_DW_WC boxplots

list.files(pattern = ".csv")
## [1] "exp5_EVT.csv"       "exp5_FW_DW_WC.csv"  "exp5_photosynq.csv"
## [4] "exp5_pot_geno.csv"
FW_DW_WC5 <- read.csv("exp5_FW_DW_WC.csv")
FW_DW_WC5$FW <- as.numeric(FW_DW_WC5$FW)
FW_DW_WC5$DW <- as.numeric(FW_DW_WC5$DW)
FW_DW_WC5$WC <- as.numeric(FW_DW_WC5$WC)
FW5_by_treatment <- ggboxplot(FW_DW_WC5, x="Treatment", y="FW", add="jitter")
FW5_by_treatment <- FW5_by_treatment + theme(axis.text.x = element_text(angle = 90))
FW5_by_treatment

DW5_by_treatment <- ggboxplot(FW_DW_WC5, x="Treatment", y="DW", add="jitter")
DW5_by_treatment <- DW5_by_treatment + theme(axis.text.x = element_text(angle = 90))
DW5_by_treatment

WC5_by_treatment <- ggboxplot(FW_DW_WC5, x="Treatment", y="WC", add="jitter")
WC5_by_treatment <- WC5_by_treatment + theme(axis.text.x = element_text(angle = 90))
WC5_by_treatment