Data processing pipeline for Experiment 98 data collected on Crop Reporter camera within BTI’s PhenoSight facility.
#install.packages("data.table")
library(data.table)
## Warning: package 'data.table' was built under R version 4.3.3
data <- fread("Exp010098_PS2_Analysis_clean.TXT", sep = "\t")
data
#colnames(data)
PS <- subset(data, data$Obj.No == "All")
PS
PS1 <- subset(PS, PS$nTmPam == 1)
PS2 <- subset(PS, PS$nTmPam == 2)
PS1
PS2
PS1 <- PS1[,c(1:4, 6, 9)]
PS1
PS2 <- PS2[,c(1:4, 6, 11, 13, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37)]
PS2
PS_extra <- subset(PS, PS$nTmPam > 2)
PS_extra <- PS_extra[,c(1:6, 9, 11, 13, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37)]
PS_extra <- PS_extra[,c(1:7)]
PS_extra
PS_melt <- melt(PS_extra, id.vars = c("File", "Date", "Time", "Obj.No", "Obj.Size", "nTmPam"))
PS_melt
PS_cast <- dcast(PS_melt, File + Date + Time + Obj.No + Obj.Size ~ variable + nTmPam)
PS_cast
PS3 <- merge(PS1, PS_cast, by = c("File", "Date", "Time", "Obj.No", "Obj.Size"))
PS4 <- merge(PS3, PS2, by = c("File", "Date", "Time", "Obj.No", "Obj.Size"))
PS4
for(i in 1:nrow(PS4)){
PS4$PhenoTray.ID[i] <- strsplit(PS4$File[i], "_")[[1]][3]
}
length(unique(PS4$PhenoTray.ID))
## [1] 4
for(i in 1:nrow(PS4)){
PS4$month <- substr(PS4$Date, 5, 6)
PS4$day <- substr(PS4$Date, 7, 8)
PS4$hour <- substr(PS4$Time, 1, 2)
}
PS4
unique(PS4$month)
## [1] "05" "06" "07"
temp <- subset(PS4, PS4$month == "05")
min(temp$day)
## [1] "23"
temp <- subset(temp, temp$day == "23")
min(temp$hour)
## [1] "15"
PS4$cum.days <- 0
for(i in 1:nrow(PS4)){
if(PS4$month[i] == "05"){
PS4$cum.days[i] <- 0}
if(PS4$month[i] == "06"){
PS4$cum.days[i] <- 31}
if(PS4$month[i] == "07"){
PS4$cum.days[i] <- 61}
}
PS4
so first day of the experiment is May 23rd and the measurements are starting around 15:00.
Let’s calculate Time of Experiment (TOE).
PS4$TOE <- (as.numeric(as.character(PS4$day)) - 23)*24 + (PS4$cum.days*24) + (as.numeric(as.character(PS4$hour)) - 15)
unique(PS4$TOE)
## [1] 51 57 114 115 123 142 145 148 153 159 1 171 177 183 195
## [16] 266 267 282 291 297 303 315 321 327 339 387 394 408 3 432
## [31] 442 466 501 514 529 547 556 579 9 586 591 600 610 625 634
## [46] 663 668 674 696 15 720 744 787 812 819 843 890 908 915 940
## [61] 27 963 987 1022 1074 1106 33 39 0 285 1092 909 941 1108 117
## [76] 530 548 580 788 1119
PS4
PS4 <- PS4[,c(1:4, 24, 29, 5:23)]
PS4
There are still some odd things in the column names - that I would like to straighten out:
colnames(PS4)[8] <- "Fv.Fm"
colnames(PS4)[9] <- "Fv.Fm.3"
colnames(PS4)[10] <- "Fv.Fm.4"
colnames(PS4)[11] <- "Fv.Fm.5"
colnames(PS4)[12] <- "Fv.Fm.6"
colnames(PS4)[13] <- "Fq.Fm"
colnames(PS4)[20] <- "phi.no"
colnames(PS4)[21] <- "phi.npq"
colnames(PS4)[22] <- "npq.t"
PS4
PS4 <- na.omit(PS4)
unique(PS4$PhenoTray.ID)
## [1] "34807" "34808" "34809" "34810"
write.table(PS4, file = "Exp00098_PS2_Analysis_new.TXT", sep="\t", row.names = F)
#install.packages("ggplot2")
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
FvFm_graph <- ggplot(data=PS4, aes(x= TOE, y=Fv.Fm, group = PhenoTray.ID))
FvFm_graph <- FvFm_graph + geom_line(alpha = 0.7)
FvFm_graph <- FvFm_graph + ylab("Fv/Fm") + xlab("Hours of Imaging")
FvFm_graph
FqFm_graph <- ggplot(data=PS4, aes(x= TOE, y=Fq.Fm, group = PhenoTray.ID))
FqFm_graph <- FqFm_graph + geom_line(alpha = 0.7)
FqFm_graph <- FqFm_graph + ylab("Fq/Fm") + xlab("Hours of Imaging")
FqFm_graph
ChlIdx_graph <- ggplot(data=PS4, aes(x= TOE, y=ChlIdx, group = PhenoTray.ID))
ChlIdx_graph <- ChlIdx_graph + geom_line(alpha = 0.7)
ChlIdx_graph <- ChlIdx_graph + ylab("ChlIdx") + xlab("Hours of Imaging")
ChlIdx_graph
AriIdx_graph <- ggplot(data=PS4, aes(x= TOE, y=AriIdx, group = PhenoTray.ID))
AriIdx_graph <- AriIdx_graph + geom_line(alpha = 0.7)
AriIdx_graph <- AriIdx_graph + ylab("AriIdx") + xlab("Hours of Imaging")
AriIdx_graph
NDVI_graph <- ggplot(data=PS4, aes(x= TOE, y=NDVI, group = PhenoTray.ID))
NDVI_graph <- NDVI_graph + geom_line(alpha = 0.7)
NDVI_graph <- NDVI_graph + ylab("NDVI") + xlab("Hours of Imaging")
NDVI_graph
library(cowplot)
pdf("Exp00098_plots.pdf", height = 10, width = 7)
plot_grid(FvFm_graph, FqFm_graph, NDVI_graph, AriIdx_graph, ChlIdx_graph, labels = "AUTO", ncol = 2)
dev.off()
## quartz_off_screen
## 2