Data processing pipeline for Experiment 99 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("Exp010099_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] 24
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"
temp <- subset(PS4, PS4$month == "05")
min(temp$day)
## [1] "28"
temp <- subset(temp, temp$day == "28")
min(temp$hour)
## [1] "21"
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}
}
PS4

so first day of the experiment is May 28th and the measurements are starting around 21:00.

Let’s calculate Time of Experiment (TOE).

PS4$TOE <- (as.numeric(as.character(PS4$day)) - 28)*24 + (PS4$cum.days*24) + (as.numeric(as.character(PS4$hour)) - 21)
unique(PS4$TOE)
##  [1]  54  58  72 156 160 168 174 178 192 198   0 202 216  16  20  24  30  36  39
## [20]  48  17 157 228 144 206  40  59 179  37 132  14 232  55 169 175 193 199 233
## [39]  31  49 158  15 234  25 135 161  18  21 162 138 207  41  60  38 170 180 194
## [58]  56 176 200  32  50 159  26  19  22 163
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] "34811" "34812" "34813" "34814" "34815" "34816" "34817" "34818" "34819"
## [10] "34820" "34821" "34822" "34823" "34824" "34825" "34826" "34827" "34828"
## [19] "34829" "34830" "34831" "34832" "34833" "34834"
write.table(PS4, file = "Exp00099_PS2_Analysis_new.TXT", sep="\t", row.names = F)

Data visualization

#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("Exp00099_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