Data processing pipeline for Experiment 89 data collected on Crop Reporter camera within BTI’s PhenoSight facility.

list.files()
##  [1] "Exp00089_Decode.tsv"               "Exp00089_ExpDesign.tsv"           
##  [3] "Exp00089_Pipeline.nb.html"         "Exp00089_Pipeline.Rmd"            
##  [5] "Exp00089_plots.pdf"                "Exp00089_PS2_Analysis_new.TXT"    
##  [7] "Exp00089_PS2_Analysis.TXT"         "Exp00092_ExpDesign.tsv"           
##  [9] "Exp00092_PS2_Analysis_new.TXT"     "Exp00094_ExpDesign.tsv"           
## [11] "Exp00094_PS2_Analysis_new.TXT"     "Exp00095_ExpDesign.tsv"           
## [13] "Exp00095_PS2_Analysis_new.TXT"     "Exp00096_ExpDesign.tsv"           
## [15] "Exp00096_PS2_Analysis_new.TXT"     "Exp010098_ExpDesign.tsv"          
## [17] "Exp010098_PS2_Analysis_new.TXT"    "Exp010099_ExpDesign.tsv"          
## [19] "Exp010099_PS2_Analysis_new.TXT"    "Exp010100_ExpDesign.tsv"          
## [21] "Exp010100_PS2_Analysis_new.TXT"    "Exp010102_ExpDesign.tsv"          
## [23] "Exp010102_PS2_Analysis_new.TXT"    "Exp010103_ExpDesign.tsv"          
## [25] "Exp010103_PS2_Analysis_new.TXT"    "Exp010104_ExpDesign.tsv"          
## [27] "Exp010104_PS2_Analysis_new.TXT"    "Exp010105_ExpDesign.tsv"          
## [29] "Exp010105_PS2_Analysis_new.TXT"    "Exp010108_ExpDesign.tsv"          
## [31] "Exp010108_PS2_Analysis_new.TXT"    "Exp010109_ExpDesign.tsv"          
## [33] "Exp010109_PS2_Analysis_new.TXT"    "Exp010111_PS2_Analysis_clean.TXT" 
## [35] "Exp010112_PS2_Analysis_new.TXT"    "Exp010113_PS2_Analysis.TXT"       
## [37] "Exp010134_ExpDesign.tsv"           "Exp010134_PS2_Analysis.TXT"       
## [39] "Exp010136_ExpDesign.tsv"           "Exp010136_PS2_Analysis.TXT"       
## [41] "Exp010190A_PS2_Analysis_clean.TXT" "Exp010190B_PS2_Analysis.TXT"      
## [43] "Exp010190C_PS2_Analysis_clean.TXT" "Exp010191_ExpDesign.txt"          
## [45] "Exp010191_PS2_Analysis_new.TXT"    "Exp10214_PS2_Analysis_clean.TXT"  
## [47] "Exp10215_PS2_Analysis_clean.TXT"   "Exp10217_PS2_Analysis.TXT"        
## [49] "Exp10218_PS2_Analysis.TXT"
#install.packages("data.table")
library(data.table)
## Warning: package 'data.table' was built under R version 4.3.3
data <- fread("Exp00089_PS2_Analysis.TXT", sep = "\t")
data
colnames(data)
##   [1] "File"             "Date"             "Time"            
##   [4] "Obj.No"           "nTmPam"           "Obj.Size"        
##   [7] "Obj.Xc"           "Obj.Yc"           "dFv/Fm"          
##  [10] "s.d."             "F0"               "s.d."            
##  [13] "Fj"               "s.d."             "Fi"              
##  [16] "s.d."             "Fm"               "s.d."            
##  [19] "1-Fj/Fm"          "s.d."             "1-Fi/Fm"         
##  [22] "s.d."             "Fv/Fm"            "s.d."            
##  [25] "IC-Area"          "s.d."             "IC-Area/Fv"      
##  [28] "s.d."             "PI"               "s.d."            
##  [31] "dFq/Fm"           "s.d."             "Fs'"             
##  [34] "s.d."             "Fm'"              "s.d."            
##  [37] "Fq'/Fm'"          "s.d."             "rETR"            
##  [40] "s.d."             "Fq'/fm' I (px)"   "Fq'/fm' I (%)"   
##  [43] "Fq'/fm' II (px)"  "Fq'/fm' II (%)"   "Fq'/fm' III (px)"
##  [46] "Fq'/fm' III (%)"  "Fq'/fm' IV (px)"  "Fq'/fm' IV (%)"  
##  [49] "Fq'/fm' V (px)"   "Fq'/fm' V (%)"    "Etr I (px)"      
##  [52] "Etr I (%)"        "Etr II (px)"      "Etr II (%)"      
##  [55] "Etr III (px)"     "Etr III (%)"      "Etr IV (px)"     
##  [58] "Etr IV (%)"       "Etr V (px)"       "Etr V (%)"       
##  [61] "dRfd"             "s.d."             "RfdFm"           
##  [64] "s.d."             "RfdFt"            "s.d."            
##  [67] "Rfd"              "s.d."             "Rfd I (px)"      
##  [70] "Rfd I (%)"        "Rfd II (px)"      "Rfd II (%)"      
##  [73] "Rfd III (px)"     "Rfd III (%)"      "Rfd IV (px)"     
##  [76] "Rfd IV (%)"       "Rfd V (px)"       "Rfd V (%)"       
##  [79] "NPQ"              "s.d."             "F0'"             
##  [82] "s.d."             "qP"               "s.d."            
##  [85] "qN"               "s.d."             "qL"              
##  [88] "s.d."             "qE"               "s.d."            
##  [91] "qI"               "s.d."             "фno"             
##  [94] "s.d."             "фnpq"             "s.d."            
##  [97] "npq(t)"           "s.d."             "Npq I (px)"      
## [100] "Npq I (%)"        "Npq II (px)"      "Npq II (%)"      
## [103] "Npq III (px)"     "Npq III (%)"      "Npq IV (px)"     
## [106] "Npq IV (%)"       "Npq V (px)"       "Npq V (%)"       
## [109] "Red"              "s.d."             "Green"           
## [112] "s.d."             "Blue"             "s.d."            
## [115] "Hue"              "s.d."             "Saturation"      
## [118] "s.d."             "Value"            "s.d."            
## [121] "SpcGrn"           "s.d."             "FarRed"          
## [124] "s.d."             "Nir"              "s.d."            
## [127] "ChlIdx"           "s.d."             "AriIdx"          
## [130] "s.d."             "NDVI"             "s.d."            
## [133] "dGfp"             "s.d."             "Gfp"             
## [136] "s.d."             "Auto"             "s.d."            
## [139] "cGfp"             "s.d."             "MaskGfp"         
## [142] "nObjGfp"          "nObjSize"         "s.d."            
## [145] "Gfp I (px)"       "Gfp I (%)"        "Gfp II (px)"     
## [148] "Gfp II (%)"       "Gfp III (px)"     "Gfp III (%)"     
## [151] "Gfp IV (px)"      "Gfp IV (%)"       "Gfp V (px)"      
## [154] "Gfp V (%)"        "dRfp"             "s.d."            
## [157] "Rfp"              "s.d."             "MaskRfp"         
## [160] "nObjRfp"          "nObjSize"         "s.d."            
## [163] "Rfp I (px)"       "Rfp I (%)"        "Rfp II (px)"     
## [166] "Rfp II (%)"       "Rfp III (px)"     "Rfp III (%)"     
## [169] "Rfp IV (px)"      "Rfp IV (%)"       "Rfp V (px)"      
## [172] "Rfp V (%)"        "dChl"             "s.d."            
## [175] "Chl"              "s.d."             "aRed"            
## [178] "s.d."             "aFarRed"          "s.d."            
## [181] "Alpha"            "s.d."             "Border"          
## [184] "Mask/Border"      "Points"           "Area (CH)"       
## [187] "Mask/Area (CH)"   "X-Centre"         "Y-Centre"        
## [190] "Radius"           "Area (MC)"        "Mask/Area (MC)"  
## [193] "Width"            "Height"           "Area (MR)"       
## [196] "Mask/Area (MR)"   "Alpha"            "Size (SK)"       
## [199] "Junction (SK)"    "Endpoint (SK)"    "Path (SK)"       
## [202] "V202"
PS <- subset(data, data$Obj.No == "All")
PS1 <- subset(PS, PS$nTmPam == 1)
PS2 <- subset(PS, PS$nTmPam == 2)
PS1
PS2
PS1 <- PS1[,c(1:6, 23, 37, 79, 83, 85, 87, 89, 91, 93, 95, 97, 127,129, 131)]
PS2 <- PS2[,c(1:6, 23, 37, 79, 83, 85, 87, 89, 91, 93, 95, 97, 127,129, 131)]
PS1 <- PS1[,c(1:4, 6:7)]
PS2 <- PS2[,c(1:4, 6, 8:20)]
PS_extra <- subset(PS, PS$nTmPam > 2)
PS_extra <- PS_extra[,c(1:6, 23, 37, 79, 83, 85, 87, 89, 91, 93, 95, 97, 127,129, 131)]
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] 6
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] "01" "03" "04" "02"
temp <- subset(PS4, PS4$month == "01")
temp <- subset(temp, temp$day == "25")
min(temp$hour)
## [1] "23"

so first day of the experiment is January 25th and the measurements are starting around 23:00.

Let’s calculate Time of Experiment (TOE).

As we need to correct for different days being in different months… we need to add to each month the cummulative.days that we need to get for that specific month:

PS4$cum.days <- 0
for(i in 1:nrow(PS4)){
  if(PS4$month[i] == "01"){
    PS4$cum.days[i] <- 0}
  if(PS4$month[i] == "02"){
    PS4$cum.days[i] <- 31}
  if(PS4$month[i] == "03"){
    PS4$cum.days[i] <- 60}
  if(PS4$month[i] == "04"){
    PS4$cum.days[i] <- 91}
  if(PS4$month[i] == "05"){
    PS4$cum.days[i] <- 120}
}
PS4
PS4$TOE <- (as.numeric(as.character(PS4$day)) - 25)*24 + (PS4$cum.days*24) + (as.numeric(as.character(PS4$hour)) - 17)
unique(PS4$TOE)
##   [1]  102 1182 1194 1206 1218 1230 1242 1254 1266 1278 1290  114 1302 1335 1338
##  [16] 1340 1414 1418 1422 1430 1434  126 1438 1446 1458 1614 1628 1648 1655 1704
##  [31] 1841 1858  138 1861 1866 1878 1890 1902 1914 1926 1938 1950 1962  150 1974
##  [46] 1986 2009 2015 2022 2036 2046 2058  162 2070 2082 2094 2106 2118 2160 2202
##  [61] 2204 2207 2209  179 2211 2212 2214 2226 2238 2250  187  198  210    6  222
##  [76]  234  246  258  270  282  294  306  318  330   18  342  354  366  378  390
##  [91]  402  420  426  438  523   30  526  529  532  534  537  539  542  546  558
## [106]  570   42  582  594  606  618  630  642  654  666  678  690   54  702  714
## [121]  726  738  750  762  774  786  798  810   66  822  834  846  858  870  882
## [136]  894  906  918  930   78  942 1008 1010 1013 1016 1018 1021 1026 1038 1050
## [151]   90 1062 1074 1086 1098 1110 1122 1134 1146 1176 1179 1341 1426 1857 1860
## [166] 2014 2034 2159 2201 2203  180 2210 1011 1177 1629 1350  524 1019  527 1022
## [181]  421  540
PS4

There are still some odd things in the column names - that I would like to straighten out:

colnames(PS4)[6] <- "Fv.Fm"
colnames(PS4)[7] <- "Fv.Fm.3"
colnames(PS4)[8] <- "Fv.Fm.4"
colnames(PS4)[9] <- "Fv.Fm.5"
colnames(PS4)[10] <- "Fv.Fm.6"
colnames(PS4)[11] <- "Fq.Fm"
colnames(PS4)[18] <- "phi.no"
colnames(PS4)[19] <- "phi.npq"
colnames(PS4)[20] <- "npq.t"
PS4 <- PS4[,c(1:4, 24, 29, 5:23)]
PS4
unique(PS4$PhenoTray.ID)
## [1] "24115" "24116" "24117" "24118" "24119" "24120"
write.table(PS4, file = "Exp00089_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

FvFm3_graph <- ggplot(data=PS4, aes(x= TOE, y=Fv.Fm.3, group = PhenoTray.ID)) 
FvFm3_graph <- FvFm3_graph + geom_line(alpha = 0.7) 
FvFm3_graph <- FvFm3_graph + ylab("Fv/Fm3") + xlab("Hours of Imaging")
FvFm3_graph

FvFm4_graph <- ggplot(data=PS4, aes(x= TOE, y=Fv.Fm.4, group = PhenoTray.ID)) 
FvFm4_graph <- FvFm4_graph + geom_line(alpha = 0.7) 
FvFm4_graph <- FvFm4_graph + ylab("Fv/Fm4") + xlab("Hours of Imaging")
FvFm4_graph

FvFm5_graph <- ggplot(data=PS4, aes(x= TOE, y=Fv.Fm.5, group = PhenoTray.ID)) 
FvFm5_graph <- FvFm5_graph + geom_line(alpha = 0.7) 
FvFm5_graph <- FvFm5_graph + ylab("Fv/Fm5") + xlab("Hours of Imaging")
FvFm5_graph

FvFm6_graph <- ggplot(data=PS4, aes(x= TOE, y=Fv.Fm.6, group = PhenoTray.ID)) 
FvFm6_graph <- FvFm6_graph + geom_line(alpha = 0.7) 
FvFm6_graph <- FvFm6_graph + ylab("Fv/Fm6") + xlab("Hours of Imaging")
FvFm6_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

NPQ_graph <- ggplot(data=PS4, aes(x= TOE, y=NPQ, group = PhenoTray.ID)) 
NPQ_graph <- NPQ_graph + geom_line(alpha = 0.7) 
NPQ_graph <- NPQ_graph + ylab("NPQ") + xlab("Hours of Imaging")
NPQ_graph

qP_graph <- ggplot(data=PS4, aes(x= TOE, y=qP, group = PhenoTray.ID)) 
qP_graph <- qP_graph + geom_line(alpha = 0.7) 
qP_graph <- qP_graph + ylab("qP") + xlab("Hours of Imaging")
qP_graph

qN_graph <- ggplot(data=PS4, aes(x= TOE, y=qN, group = PhenoTray.ID)) 
qN_graph <- qN_graph + geom_line(alpha = 0.7) 
qN_graph <- qN_graph + ylab("qN") + xlab("Hours of Imaging")
qN_graph

qL_graph <- ggplot(data=PS4, aes(x= TOE, y=qL, group = PhenoTray.ID)) 
qL_graph <- qL_graph + geom_line(alpha = 0.7) 
qL_graph <- qL_graph + ylab("qL") + xlab("Hours of Imaging")
qL_graph

qE_graph <- ggplot(data=PS4, aes(x= TOE, y=qE, group = PhenoTray.ID)) 
qE_graph <- qE_graph + geom_line(alpha = 0.7) 
qE_graph <- qE_graph + ylab("qE") + xlab("Hours of Imaging")
qE_graph

qI_graph <- ggplot(data=PS4, aes(x= TOE, y=qI, group = PhenoTray.ID)) 
qI_graph <- qI_graph + geom_line(alpha = 0.7) 
qI_graph <- qI_graph + ylab("qI") + xlab("Hours of Imaging")
qI_graph

phi.no_graph <- ggplot(data=PS4, aes(x= TOE, y=phi.no, group = PhenoTray.ID)) 
phi.no_graph <- phi.no_graph + geom_line(alpha = 0.7) 
phi.no_graph <- phi.no_graph + ylab("phi.no") + xlab("Hours of Imaging")
phi.no_graph

phi.npq_graph <- ggplot(data=PS4, aes(x= TOE, y=phi.npq, group = PhenoTray.ID)) 
phi.npq_graph <- phi.npq_graph + geom_line(alpha = 0.7) 
phi.npq_graph <- phi.npq_graph + ylab("phi.npq") + xlab("Hours of Imaging")
phi.npq_graph

npq.t_graph <- ggplot(data=PS4, aes(x= TOE, y=npq.t, group = PhenoTray.ID)) 
npq.t_graph <- npq.t_graph + geom_line(alpha = 0.7) 
npq.t_graph <- npq.t_graph + ylab("npq(t)") + xlab("Hours of Imaging")
npq.t_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("Exp00089_plots.pdf", height = 10, width = 7)
plot_grid(FvFm_graph, FqFm_graph, npq.t_graph, NPQ_graph, NDVI_graph, AriIdx_graph, ChlIdx_graph, labels = "AUTO", ncol = 2)
dev.off()
## quartz_off_screen 
##                 2