This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code. This notebook contains code for the EVT, FW, DW, WC analysis of cowpea phenotyping #2.
#install.packages(c("ggplot2", "ggpubr", "cowplot", "reshape2"))
library("ggplot2")
library("cowplot")
library("ggpubr")
##
## Attaching package: 'ggpubr'
## The following object is masked from 'package:cowplot':
##
## get_legend
library("reshape2")
#load CSV file
getwd()
## [1] "C:/Users/J Lab/Box/Plant Architecture Lab/Hayley/Cowpea/Cowpea_screen_02_20220407-21/Cowpea_Phenotype_exp2_analysis"
list.files(pattern=".csv")
## [1] "EVT_exp2.csv" "FW_DW.csv" "Photosynq_exp2.csv"
## [4] "Pot_Geno.csv"
evt2exp <- read.csv("EVT_exp2.csv")
head(evt2exp)
#reshape the data to make it workable
melted_2EVT <- melt(evt2exp, id.vars = c("Pot.number", "Genotype", "Treatment"))
colnames(melted_2EVT)[4] <- "Day"
colnames(melted_2EVT)[5] <- "Evapotranspiration"
melted_2EVT$Day <- gsub("Day", "", melted_2EVT$Day)
melted_2EVT$Day <- as.numeric(melted_2EVT$Day)
melted_2EVT$Pot.number <- as.factor(melted_2EVT$Pot.number)
unique(melted_2EVT$Treatment)
## [1] "Control " "Drought" "Control"
melted_2EVT$Treatment <- gsub("Control ", "Control", melted_2EVT$Treatment)
melted_2EVTb <- na.omit(melted_2EVT, c("Evapotranspiration"))
#write.csv(melted_2EVTb, "EVT_exp2_melted.csv", row.names = TRUE)
###Plotting EVT thorugh time
melted_2EVTb$Pot.number <- as.factor(melted_2EVTb$Pot.number)
EVT2_over_time <- ggplot(data = melted_2EVTb, aes(x = Day, y = Evapotranspiration, group = Pot.number, colour = Treatment), na.rm = TRUE) + theme_classic() + ylim(0, NA)
EVT2_over_time <- EVT2_over_time + geom_line(alpha = 0.1)
EVT2_over_time <- EVT2_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")
EVT2_over_time <- EVT2_over_time + facet_wrap(~ Treatment)
EVT2_over_time <- EVT2_over_time + ylab("Evapotranspiration (g)") + xlab("Day") + rremove("legend")
EVT2_over_time
melted_2EVTb$Day <- as.factor(melted_2EVTb$Day)
EVT2_graph_cd <- ggplot(data = melted_2EVTb, aes(x = Day, y = Evapotranspiration, group = Pot.number, colour = Treatment), na.rm = TRUE) + theme_classic() + ylim(0, NA)
EVT2_graph_cd <- EVT2_graph_cd + geom_line(alpha = 0.1)
EVT2_graph_cd <- EVT2_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")
EVT2_graph_cd <- EVT2_graph_cd + stat_compare_means(aes(group = Treatment), label = "p.signif", method = "t.test", hide.ns = TRUE)
EVT2_graph_cd <- EVT2_graph_cd + scale_color_manual(labels=c("Control", "Drought"), values=c("blue", "red"))
EVT2_graph_cd <- EVT2_graph_cd + ylab("Evapotranspiration (g)") + xlab("Day")
EVT2_graph_cd
#install.packages("plotly")
#library(plotly)
#ggplotly(EVT2_graph)
list.files(pattern=".csv")
## [1] "EVT_exp2.csv" "FW_DW.csv" "Photosynq_exp2.csv"
## [4] "Pot_Geno.csv"
FW_DW2 <- read.csv("FW_DW.csv")
head(FW_DW2)
#boxplot of fresh weight by Treatment
FW_by_Treatment2 <- ggboxplot(FW_DW2, x="Treatment", y="FW..g.", add="jitter")
FW_by_Treatment2 <- FW_by_Treatment2 + theme(axis.text.x = element_text(angle = 90))
FW_by_Treatment2
#FW_by_Treatment2_genotype <- ggboxplot(FW_DW2, x="Treatment", y="FW..g.", add="jitter")
#FW_by_Treatment2_genotype <- FW_by_Treatment2_genotype + facet_grid(. ~genotype)
#FW_by_Treatment2_genotype <- FW_by_Treatment2_genotype + theme(axis.text.x = element_text(angle = 90))
#FW_by_Treatment2_genotype
#boxplot of dry weight by Treatment
DW_by_Treatment2 <- ggboxplot(FW_DW2, x="Treatment", y="DW..g.", add="jitter")
DW_by_Treatment2 <- DW_by_Treatment2 + theme(axis.text.x = element_text(angle = 90))
DW_by_Treatment2
#boxplot of water content by Treatment
WC_by_Treatment2 <- ggboxplot(FW_DW2, x="Treatment", y="WC", add="jitter")
WC_by_Treatment2 <- WC_by_Treatment2 + theme(axis.text.x = element_text(angle = 90))
WC_by_Treatment2