Data processing pipeline for Experiment 92 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("Exp00092_PS_analysis_new.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")
PS1 <- subset(PS, PS$nTmPam == 1)
PS2 <- subset(PS, PS$nTmPam == 2)
PS1
PS2
PS1 <- PS1[,c(1:6, 9, 11, 13, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37)]
PS2 <- PS2[,c(1:6, 9, 11, 13, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37)]
PS1
PS2
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, 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] 3
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] "04" "02" "03"
temp <- subset(PS4, PS4$month == "02")
min(temp$day)
## [1] "02"
temp <- subset(temp, temp$day == "02")
min(temp$hour)
## [1] "11"
so first day of the experiment is February 2nd and the measurements are starting around 11: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] == "02"){
PS4$cum.days[i] <- 0}
if(PS4$month[i] == "03"){
PS4$cum.days[i] <- 29}
if(PS4$month[i] == "04"){
PS4$cum.days[i] <- 60}
}
PS4
PS4$TOE <- (as.numeric(as.character(PS4$day)) - 2)*24 + (PS4$cum.days*24) + (as.numeric(as.character(PS4$hour)) - 11)
unique(PS4$TOE)
## [1] 1511 47 582 587 594 599 606 611 618 623 630 635 54 642 647
## [16] 654 659 666 671 678 683 690 695 59 702 707 714 719 726 731
## [31] 738 743 750 755 66 821 824 826 829 830 831 832 71 834 835
## [46] 837 839 846 851 858 863 870 875 78 882 887 894 899 906 911
## [61] 918 923 930 935 83 942 947 954 959 990 992 995 90 1002 1007
## [76] 1014 1019 1026 1031 1038 1043 1050 1055 95 1062 1067 1074 1079 1086 1091
## [91] 1098 1103 1110 1115 102 1122 1127 1151 1152 1153 1154 1159 1163 1226 1227
## [106] 0 107 1231 1234 1235 1238 1239 1242 1243 1246 1247 114 1250 1251 1254
## [121] 1259 1266 1271 1301 1422 1427 1434 119 1439 1446 1451 1468 1486 1499 1519
## [136] 126 131 138 143 150 155 162 6 167 174 179 186 191 198 203
## [151] 210 215 222 11 227 235 239 246 251 258 263 339 340 18 342
## [166] 345 347 350 352 353 23 355 356 357 359 366 371 378 383 390
## [181] 395 30 402 407 414 419 426 431 438 443 450 455 35 462 467
## [196] 474 479 486 491 498 503 510 515 42 522 527 534 539 546 551
## [211] 558 563 570 575 827 1228 1230 1232 1240 1491 234 236 264 348
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
PS4 <- subset(PS4, PS4$PhenoTray.ID != "92")
unique(PS4$PhenoTray.ID)
## [1] "24681" "24682"
write.table(PS4, file = "Exp00092_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
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("Exp00092_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