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

list.files()
##  [1] "Exp00089_ExpDesign.tsv"            "Exp00089_Pipeline.html"           
##  [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_Pipeline.html"            "Exp00092_Pipeline.Rmd"            
## [11] "Exp00092_plots.pdf"                "Exp00092_PS_analysis_new.TXT"     
## [13] "Exp00092_PS_analysis.TXT"          "Exp00092_PS2_Analysis_new.TXT"    
## [15] "Exp00094_ExpDesign.tsv"            "Exp00094_Pipeline.html"           
## [17] "Exp00094_Pipeline.Rmd"             "Exp00094_plots.pdf"               
## [19] "Exp00094_PS2_Analysis_clean.TXT"   "Exp00094_PS2_Analysis_new.TXT"    
## [21] "Exp00095_ExpDesign.tsv"            "Exp00095_PS2_Analysis_clean.TXT"  
## [23] "Exp00096_ExpDesign.tsv"            "Exp00096_Pipeline.html"           
## [25] "Exp00096_Pipeline.Rmd"             "Exp00096_plots.pdf"               
## [27] "Exp00096_PS2_Analysis_clean.TXT"   "Exp00096_PS2_Analysis_new.TXT"    
## [29] "Exp010098_ExpDesign.tsv"           "Exp010098_Pipeline.html"          
## [31] "Exp010098_Pipeline.Rmd"            "Exp010098_plots.pdf"              
## [33] "Exp010098_PS2_Analysis_clean.TXT"  "Exp010098_PS2_Analysis_new.TXT"   
## [35] "Exp010099_ExpDesign.tsv"           "Exp010099_Pipeline.html"          
## [37] "Exp010099_Pipeline.Rmd"            "Exp010099_plots.pdf"              
## [39] "Exp010099_PS2_Analysis_clean.TXT"  "Exp010099_PS2_Analysis_new.TXT"   
## [41] "Exp010100_ExpDesign.tsv"           "Exp010100_Pipeline.html"          
## [43] "Exp010100_Pipeline.Rmd"            "Exp010100_plots.pdf"              
## [45] "Exp010100_PS2_Analysis_clean.TXT"  "Exp010100_PS2_Analysis_new.TXT"   
## [47] "Exp010102_ExpDesign.tsv"           "Exp010102_Pipeline.html"          
## [49] "Exp010102_Pipeline.Rmd"            "Exp010102_plots.pdf"              
## [51] "Exp010102_PS2_Analysis_clean.TXT"  "Exp010102_PS2_Analysis_new.TXT"   
## [53] "Exp010103_ExpDesign.tsv"           "Exp010103_Pipeline.Rmd"           
## [55] "Exp010103_plots.pdf"               "Exp010103_PS2_Analysis_clean.TXT" 
## [57] "Exp010103_PS2_Analysis_new.TXT"    "Exp010104_ExpDesign.tsv"          
## [59] "Exp010104_PS2_Analysis_clean.TXT"  "Exp010105_ExpDesign.tsv"          
## [61] "Exp010105_PS2_Analysis_clean.TXT"  "Exp010108_ExpDesign.tsv"          
## [63] "Exp010108_PS2_Analysis_clean.TXT"  "Exp010109_ExpDesign.tsv"          
## [65] "Exp010109_PS2_Analysis_clean.TXT"  "Exp010111_PS2_Analysis_clean.TXT" 
## [67] "Exp010113_PS2_Analysis.TXT"        "Exp010134_ExpDesign.tsv"          
## [69] "Exp010134_PS2_Analysis.TXT"        "Exp010136_ExpDesign.tsv"          
## [71] "Exp010136_PS2_Analysis.TXT"        "Exp010190A_PS2_Analysis_clean.TXT"
## [73] "Exp010190B_PS2_Analysis.TXT"       "Exp010190C_PS2_Analysis_clean.TXT"
## [75] "Exp010191_ExpDesign.txt"           "Exp010191_PS2_Analysis_new.TXT"   
## [77] "Exp10214_PS2_Analysis_clean.TXT"   "Exp10215_PS2_Analysis_clean.TXT"  
## [79] "Exp10217_PS2_Analysis.TXT"         "Exp10218_PS2_Analysis.TXT"        
## [81] "rsconnect"
#install.packages("data.table")
library(data.table)
## Warning: package 'data.table' was built under R version 4.3.3
data <- fread("Exp010103_PS2_Analysis_clean.TXT", sep = "\t")
data
colnames(data)
##  [1] "File"           "Date"           "Time"           "Obj.No"        
##  [5] "nTmPam"         "Obj.Size"       "Obj.Xc"         "Obj.Yc"        
##  [9] "Fv/Fm"          "s.d."           "Fq'/Fm'"        "s.d."          
## [13] "NPQ"            "s.d."           "F0'"            "s.d."          
## [17] "qP"             "s.d."           "qN"             "s.d."          
## [21] "qL"             "s.d."           "qE"             "s.d."          
## [25] "qI"             "s.d."           "фno"            "s.d."          
## [29] "фnpq"           "s.d."           "npq(t)"         "s.d."          
## [33] "ChlIdx"         "s.d."           "AriIdx"         "s.d."          
## [37] "NDVI"           "s.d."           "Border"         "Mask/Border"   
## [41] "Points"         "Area (CH)"      "Mask/Area (CH)" "X-Centre"      
## [45] "Y-Centre"       "Radius"         "Area (MC)"      "Mask/Area (MC)"
## [49] "Width"          "Height"         "Area (MR)"      "Mask/Area (MR)"
## [53] "Alpha"          "Size (SK)"      "Junction (SK)"  "Endpoint (SK)" 
## [57] "Path (SK)"      "V58"
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] 36
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] "06"
temp <- subset(PS4, PS4$month == "06")
min(temp$day)
## [1] "10"
temp <- subset(temp, temp$day == "10")
min(temp$hour)
## [1] "17"
PS4$cum.days <- 0
for(i in 1:nrow(PS4)){
  if(PS4$month[i] == "06"){
    PS4$cum.days[i] <- 0}
}
PS4

so first day of the experiment is June 10 and the measurements are starting around 17:00.

Let’s calculate Time of Experiment (TOE).

PS4$TOE <- (as.numeric(as.character(PS4$day)) - 10)*24 + (PS4$cum.days*24) + (as.numeric(as.character(PS4$hour)) - 17)
unique(PS4$TOE)
##   [1]  96 114 122 146 153 158 168 188 212 227   0 232 237 259 265 269 277 289
##  [19] 301 313  10  24  34  44  68  82 123 186 209 215 229 234 256 263 267 275
##  [37] 287 299 311 211 217   1 231 236 258 268 300 312  72  97 147 189 213 228
##  [55] 266 270 278 290 302 314 187 210 216 230 235 257 159  45 117 190  11  35
##  [73]  83 238 260  25 148 154 264 276 288 118 124   2  73 233  98 155 160  46
##  [91]  12  36  84 156  26 137 149   4  65 119 144  66  74   5 112 113 145 157
## [109] 161  13  37  85 150  27 120  67  75   6
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] "34877" "34878" "34879" "34880" "34881" "34882" "34883" "34884" "34885"
## [10] "34886" "34887" "34888" "34889" "34890" "34891" "34892" "34893" "34894"
## [19] "34895" "34896" "34897" "34898" "34899" "34900" "34901" "34902" "34903"
## [28] "34904" "34905" "34906" "34907" "34908" "34909" "34910" "34911" "34912"
write.table(PS4, file = "Exp010103_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("Exp010103_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