A pipeline for evaluating the PS2 data from Sarah Kezar’s experiment This is a part of a series of experiments on Parthenium sp. from various locations.

PS2 data loading

OK - now let’s explore whats happening in the PS2 data!

Because the original output file is having some nonsense lines as we export it from the PS2 analyzer - we need to remove them:

PS2a <- read.csv("Batch.04.PS2.csv")
PS2b <- read.csv("Batch.03.2.PS2.csv")
colnames(PS2a)
##  [1] "File"           "Date"           "Time"           "Obj.No"        
##  [5] "nTmPam"         "Obj.Size"       "Obj.Xc"         "Obj.Yc"        
##  [9] "Fv.Fm"          "s.d."           "Fq..Fm."        "s.d..1"        
## [13] "NPQ"            "s.d..2"         "F0."            "s.d..3"        
## [17] "qP"             "s.d..4"         "qN"             "s.d..5"        
## [21] "qL"             "s.d..6"         "qE"             "s.d..7"        
## [25] "qI"             "s.d..8"         "X.Ñno"          "s.d..9"        
## [29] "X.Ñnpq"         "s.d..10"        "npq.t."         "s.d..11"       
## [33] "ChlIdx"         "s.d..12"        "AriIdx"         "s.d..13"       
## [37] "NDVI"           "s.d..14"        "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."
colnames(PS2b)
##  [1] "File"           "Date"           "Time"           "Obj.No"        
##  [5] "nTmPam"         "Obj.Size"       "Obj.Xc"         "Obj.Yc"        
##  [9] "Fv.Fm"          "s.d."           "Fq..Fm."        "s.d..1"        
## [13] "NPQ"            "s.d..2"         "F0."            "s.d..3"        
## [17] "qP"             "s.d..4"         "qN"             "s.d..5"        
## [21] "qL"             "s.d..6"         "qE"             "s.d..7"        
## [25] "qI"             "s.d..8"         "X.Ñno"          "s.d..9"        
## [29] "X.Ñnpq"         "s.d..10"        "npq.t."         "s.d..11"       
## [33] "ChlIdx"         "s.d..12"        "AriIdx"         "s.d..13"       
## [37] "NDVI"           "s.d..14"        "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."
PS2 <- rbind(PS2a, PS2b)
PS2

For this specific experiment - in order to analyze the results per OVERALL canopy - let’s keep ONLY “all”

PS3 <- subset(PS2, PS2$Obj.No == "All")
PS3

get only the columns that are informative biologically (for now):

colnames(PS3)
##  [1] "File"           "Date"           "Time"           "Obj.No"        
##  [5] "nTmPam"         "Obj.Size"       "Obj.Xc"         "Obj.Yc"        
##  [9] "Fv.Fm"          "s.d."           "Fq..Fm."        "s.d..1"        
## [13] "NPQ"            "s.d..2"         "F0."            "s.d..3"        
## [17] "qP"             "s.d..4"         "qN"             "s.d..5"        
## [21] "qL"             "s.d..6"         "qE"             "s.d..7"        
## [25] "qI"             "s.d..8"         "X.Ñno"          "s.d..9"        
## [29] "X.Ñnpq"         "s.d..10"        "npq.t."         "s.d..11"       
## [33] "ChlIdx"         "s.d..12"        "AriIdx"         "s.d..13"       
## [37] "NDVI"           "s.d..14"        "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."
PS4 <- PS3[,c(1:3, 6, 9, 11, 13, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37)]
PS4
library(ggplot2)
library(ggpubr)
PS4$Date <- as.factor(PS4$Date)
lgraph <- ggplot(data=PS4, aes(x= Date, y=ChlIdx)) 
lgraph <- lgraph + geom_point(alpha = 0.7) + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
lgraph <- lgraph + ylab("Chlorophylll Index") + xlab("days after stress")
lgraph

OK - so this dataset contains actually three experiments - batch 04 from Sarah’s experiment from March 18th to 31st - then batch 03.2 from Sarah’s experiment from March 31st to April 09

Let’s isolate only the measurement from batch 04:

want <- c("20250318", "20250319", "20250320", "20250321", "20250322", "20250323", "20250324", "20250325", "20250326", "20250327", "20250328", "20250329", "20250330", "20250331")

PS4 <- subset(PS4, PS4$Date %in% want)

lgraph <- ggplot(data=PS4, aes(x= Date, y=ChlIdx)) 
lgraph <- lgraph + geom_point(alpha = 0.7) + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
lgraph <- lgraph + ylab("Chlorophylll Index") + xlab("days after stress")
lgraph

This is great start, but lets isolate the measurement per tray ID - which is the third item in the File name (HDR_ExpID_TrayID_roundID.INF)

How do we get there?

strsplit(PS4$File[1], "_")[[1]][3]
## [1] "40352"

Now - lets isolate it for the entire data sheet:

for(i in 1:nrow(PS4)){
  PS4$tray.ID[i] <- strsplit(PS4$File[i], "_")[[1]][3]
}
length(unique(PS4$tray.ID))
## [1] 60
unique(PS4$Date)
##  [1] 20250322 20250323 20250324 20250325 20250326 20250318 20250319 20250320
##  [9] 20250321 20250327 20250328 20250329 20250330 20250331
## 22 Levels: 20250318 20250319 20250320 20250321 20250322 20250323 ... 20250409

Let’s transfer date and time into TOE.

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

Trays were loaded on March 18th at around 9:00

PS4$TOE <- (as.numeric(as.character(PS4$day)) - 18)*24 + (as.numeric(as.character(PS4$hour)) - 9)
unique(PS4$TOE)
##   [1] 106 118 130 142 154 166 178 190   2  22  34  46  58  70  82  94   3 107
##  [19] 119 131 143 155 167 179 191  23  35  47  59  83  95  71  48   4  24 120
##  [37] 132 144 156 168 180 192  36  60  84 108   7  72  96   8  49   9 109 133
##  [55] 145 157 169 181 193  25  37  85 121  61  73  97 202 214 226 238 250 262
##  [73] 274 286 298 310 314 319 320 315 215 227 239 251 263 275 287 299 311 203
##  [91] 321 322 204 228 240 252 264 276 288 312 216 300 316 229 241 253 265 277
## [109] 313 205 217 289 301 317 318
PS4 <- subset(PS4, PS4$TOE < 314)
PS4

OK - then we have an issue with the FvFm being correct for one set of the data - and the other traits (FqFm and such) for other row. We need to correct it first:

# Get data containing right measurements into two separate datasets:
FvFm_data <- subset(PS4, PS4$Fv.Fm > 0)
notFvFm_data <- subset(PS4, PS4$Fv.Fm < 0)
# Get rid of collumns containing nonsense
FvFm_data <- FvFm_data[,c(1:5)]
notFvFm_data <- notFvFm_data[,c(1:4,6:23)]
FvFm_data
notFvFm_data

Now - let’s merge them together:

PS5 <- merge(FvFm_data, notFvFm_data, by =c("File", "Date", "Time", "Obj.Size"))
PS5

Before moving forward - let’s decode the data:

decode <- read.csv("20250312_SarahK_Batch4_coding.csv")
decode
decode <- decode[,c(2,7,3,6)]
colnames(decode)[1] <- "tray.ID"
decode

OK cool cool - now let’s fuse it with the PS2 data based on the tray.ID

unique(PS5$tray.ID)
##  [1] "40352" "40353" "40354" "40355" "40356" "40357" "40358" "40359" "40360"
## [10] "40361" "40362" "40363" "40364" "40365" "40366" "40367" "40368" "40369"
## [19] "40370" "40371" "40372" "40373" "40374" "40375" "40376" "40377" "40378"
## [28] "40379" "40380" "40381" "40382" "40383" "40384" "40385" "40386" "40387"
## [37] "40388" "40389" "40390" "40391" "40392" "40393" "40394" "40395" "40396"
## [46] "40397" "40398" "40399" "40400" "40401" "40402" "40403" "40404" "40405"
## [55] "40406" "40407" "40408" "40409" "40410" "40411"
PS6 <- merge(PS5, decode, by= "tray.ID", all=T)
PS6

Lets have a look at how the data looks like now:

lgraph <- ggplot(data=PS6, aes(x= TOE, y=Fv.Fm, group = tray.ID)) 
lgraph <- lgraph + geom_line(alpha = 0.7) 
lgraph <- lgraph + ylab("Maximum Quantum Yield (Fv/Fm)") + xlab("Hours of Imaging")
lgraph

lets add more info to the graph:

FvFm_graph <- ggplot(data=PS6, aes(x= TOE, y=Fv.Fm, group = tray.ID, color = TrayInfo)) 
FvFm_graph <- FvFm_graph + geom_line(alpha = 0.7) 
FvFm_graph <- FvFm_graph + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group= TrayInfo), alpha=0.3)
FvFm_graph <- FvFm_graph + stat_summary(fun=mean, aes(group= TrayInfo),  size=0.7, geom="line", linetype = "dashed")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
FvFm_graph <- FvFm_graph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = TRUE)
FvFm_graph <- FvFm_graph + ylab("Fv/Fm (a.u.)") + xlab("Time of imaging (h)")
FvFm_graph
## Warning: Computation failed in `stat_compare_means()`.
## Caused by error in `mutate()`:
## ℹ In argument: `p = purrr::map(...)`.
## Caused by error in `purrr::map()`:
## ℹ In index: 80.
## ℹ With name: x.8.
## Caused by error in `t.test.default()`:
## ! not enough 'x' observations
## Warning: Removed 25 rows containing missing values or values outside the scale range
## (`geom_ribbon()`).

As you can see - there are some lines that are not exactly the same timepoints - so we will get in trouble when calculating averages. Therefore - we need to do splines!

But before we get there - let’s also separate the data into day / night measurements - since we clearly see diurnal changes in Fv/Fm and other traits!

unique(as.numeric(as.character(PS6$TOE)))
##   [1] 106 118 130 142 154 166 178 190 202 214   2 226 238 250 262 274 286 298
##  [19] 310  22  34  46  58  70  82  94   3 107 119 131 143 155 167 179 191 215
##  [37] 227 239 251 263 275 287 299 311  23  35  47  59  83  95 203  71  48   4
##  [55]  24 120 132 144 156 168 180 192 204 228 240 252 276 288 312  36  60  84
##  [73] 108 216   7 264 300  72  96   8  49   9 109 133 145 157 169 181 193 229
##  [91] 241 253 265 277 313  25  37  85 121 205 217 289  61  73 301  97

I feel a bit thick - but I translated all of the TOE into Time of Day (TOD) in excell - to know whether that time is in the morning imaging round or in the evening. Now - let’s merge it with the data:

TOD <- read.csv("Batch04.TOE_to_TOD.csv")
TOD
PS7 <- merge(PS6, TOD, by = "TOE", all = T)
PS7
PS_AM <- subset(PS7, PS7$TOD == "AM")
PS_PM <- subset(PS7, PS7$TOD == "PM")

AM_lgraph <- ggplot(data=PS_AM, aes(x= TOE, y=Fv.Fm, group = tray.ID)) 
AM_lgraph <- AM_lgraph + geom_line(alpha = 0.7) 
AM_lgraph <- AM_lgraph + ylab("Maximum Quantum Yield (Fv/Fm)") + xlab("Hours of Imaging")
AM_lgraph

PM_lgraph <- ggplot(data=PS_PM, aes(x= TOE, y=Fv.Fm, group = tray.ID)) 
PM_lgraph <- PM_lgraph + geom_line(alpha = 0.7) 
PM_lgraph <- PM_lgraph + ylab("Maximum Quantum Yield (Fv/Fm)") + xlab("Hours of Imaging")
PM_lgraph

OK this doesnt change anything - ok let’s continue as before!

Splines for ALL PS2 traits

So - let’s first isolate one plant to establish our spline calculations

max(PS6$TOE)
## [1] 313
hours <- seq(0, 312, by = 12)
hours
##  [1]   0  12  24  36  48  60  72  84  96 108 120 132 144 156 168 180 192 204 216
## [20] 228 240 252 264 276 288 300 312
length(hours)
## [1] 27
temp <- subset(PS6, PS6$tray.ID == unique(PS6$tray.ID)[1])
temp$TOE <- as.numeric(as.character(temp$TOE))
temp <- temp[order(temp$TOE, decreasing = F),]
temp$TOE
##  [1]   2  22  34  46  58  70  82  94 106 118 130 142 154 166 178 190 202 214 226
## [20] 238 250 262 274 286 298 310

Fv/Fm

plot.spl <- with(temp, smooth.spline(TOE, Fv.Fm, df = 25))
plot(Fv.Fm ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

Fq/Fm

plot.spl <- with(temp, smooth.spline(TOE, Fq..Fm., df = 25))
plot(Fq..Fm. ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

NPQ

plot.spl <- with(temp, smooth.spline(TOE, NPQ, df = 25))
plot(NPQ ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

qP

plot.spl <- with(temp, smooth.spline(TOE, qP, df = 25))
plot(qP ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

qN

plot.spl <- with(temp, smooth.spline(TOE, qN, df = 25))
plot(qN ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

qL

plot.spl <- with(temp, smooth.spline(TOE, qL, df = 25))
plot(qL ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

qE

plot.spl <- with(temp, smooth.spline(TOE, qE, df = 25))
plot(qE ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

qI

plot.spl <- with(temp, smooth.spline(TOE, qI, df = 25))
plot(qI ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

фno

temp
plot.spl <- with(temp, smooth.spline(TOE, X.Ñno, df = 25))
plot(X.Ñno ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

фnpq

plot.spl <- with(temp, smooth.spline(TOE, X.Ñnpq, df = 25))
plot(X.Ñnpq ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

npq(t)

plot.spl <- with(temp, smooth.spline(TOE, npq.t., df = 25))
plot(npq.t. ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

ChlIdx

plot.spl <- with(temp, smooth.spline(TOE, ChlIdx, df = 25))
plot(ChlIdx ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

AriIdx

plot.spl <- with(temp, smooth.spline(TOE, AriIdx, df = 25))
plot(AriIdx ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

NDVI

plot.spl <- with(temp, smooth.spline(TOE, NDVI, df = 25))
plot(NDVI ~ TOE, data = temp)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, hours), col = "red")

Then - let’s save all of the information into one file

PS6
# CHANGE last thing into trait name
names <- c(text = "tray.ID", "TOE", "Fv.Fm", "Fq.Fm", "NPQ", "qP", "qN", "qL", "qE", "qI", "phiNO", "phiNPQ", "npq.t", "ChlIdx", "AriIdx", "NDVI")
spline_data <- data.frame()
for (k in names) {
  spline_data[[k]] <- as.character()}
pred_temp <- predict(plot.spl, hours)
length(pred_temp$x)
## [1] 27
spline_data[1:27,1] <- temp$tray.ID[1]
spline_data[1:27,2] <- pred_temp$x
plot.spl <- with(temp, smooth.spline(TOE, Fv.Fm, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,3] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, Fq..Fm., df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,4] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, NPQ, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,5] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, qP, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,6] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, qN, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,7] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, qL, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,8] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, qE, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,9] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, qI, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,10] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, X.Ñno, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,11] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, X.Ñnpq, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,12] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, npq.t., df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,13] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, ChlIdx, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,14] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, AriIdx, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,15] <- pred_temp$y
plot.spl <- with(temp, smooth.spline(TOE, NDVI, df = 25))
pred_temp <- predict(plot.spl, hours)
spline_data[1:27,16] <- pred_temp$y

final_spline <- spline_data
final_spline
all_plants <- unique(PS5$tray.ID)
all_plants
##  [1] "40352" "40353" "40354" "40355" "40356" "40357" "40358" "40359" "40360"
## [10] "40361" "40362" "40363" "40364" "40365" "40366" "40367" "40368" "40369"
## [19] "40370" "40371" "40372" "40373" "40374" "40375" "40376" "40377" "40378"
## [28] "40379" "40380" "40381" "40382" "40383" "40384" "40385" "40386" "40387"
## [37] "40388" "40389" "40390" "40391" "40392" "40393" "40394" "40395" "40396"
## [46] "40397" "40398" "40399" "40400" "40401" "40402" "40403" "40404" "40405"
## [55] "40406" "40407" "40408" "40409" "40410" "40411"
for(i in 2:60){
    temp <- subset(PS6, PS6$tray.ID == unique(PS6$tray.ID)[i])

   if (dim(temp)[1] > 3) {
        temp$TOE <- as.numeric(as.character(temp$TOE))
        temp <- temp[order(temp$TOE, decreasing = F),]
        spline_data[1:27,1] <- temp$tray.ID[1]
        spline_data[1:27,2] <- pred_temp$x
        plot.spl <- with(temp, smooth.spline(TOE, Fv.Fm, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,3] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, Fq..Fm., df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,4] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, NPQ, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,5] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, qP, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,6] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, qN, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,7] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, qL, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,8] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, qE, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,9] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, qI, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,10] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, X.Ñno, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,11] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, X.Ñnpq, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,12] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, npq.t., df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,13] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, ChlIdx, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,14] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, AriIdx, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,15] <- pred_temp$y
        plot.spl <- with(temp, smooth.spline(TOE, NDVI, df = 25))
        pred_temp <- predict(plot.spl, hours)
        spline_data[1:27,16] <- pred_temp$y
        final_spline <- rbind(final_spline, spline_data)
  } else {
        spline_data[1:27,1] <- temp$tray.ID[1]
        spline_data[1:27,2] <- hours
        spline_data[1:27,3] <- 0
        spline_data[1:27,4] <- 0
        spline_data[1:27,5] <- 0
        spline_data[1:27,6] <- 0
        spline_data[1:27,7] <- 0
        spline_data[1:27,8] <- 0
        spline_data[1:27,9] <- 0
        spline_data[1:27,10] <- 0
        spline_data[1:27,11] <- 0
        spline_data[1:27,12] <- 0
        spline_data[1:27,13] <- 0
        spline_data[1:27,14] <- 0
        spline_data[1:27,15] <- 0
        spline_data[1:27,16] <- 0
        final_spline <- rbind(final_spline, spline_data)
  }}
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 22
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 23
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fv.Fm, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, Fq..Fm., df = 25): not using invalid df; must
## have 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NPQ, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qP, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qN, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qL, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qE, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, qI, df = 25): not using invalid df; must have 1 <
## df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñno, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, X.Ñnpq, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, npq.t., df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, ChlIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, AriIdx, df = 25): not using invalid df; must have
## 1 < df <= n := #{unique x} = 24
## Warning in smooth.spline(TOE, NDVI, df = 25): not using invalid df; must have 1
## < df <= n := #{unique x} = 24
final_spline

Let’s change the collumns also to numeric - otherwise it will be tought to plot this:

final_spline2 <- final_spline
final_spline2[2:16] <- sapply(final_spline2[2:16],as.numeric)
final_spline2

Decode

Now - let’s decode all of the information into individual experiments and TrayInfos:

final_spline3 <- merge(final_spline2, decode, by = "tray.ID")
final_spline3
unique(final_spline3$TrayInfo)
## [1] "Control" "Drought"
unique(final_spline3$PlantID)
##  [1] "Tray01_Control_A1_Australia" "Tray02_Control_A1_Mexico"   
##  [3] "Tray03_Control_A1_Pakistan"  "Tray04_Control_A1_S.Africa" 
##  [5] "Tray05_Control_A1_Texas"     "Tray06_Control_A1_Vietnam"  
##  [7] "Tray07_Drought_A1_Mexico"    "Tray08_Drought_A1_Vietnam"  
##  [9] "Tray09_Control_A1_S.Africa"  "Tray10_Control_A1_Mexico"   
## [11] "Tray11_Drought_A1_Texas"     "Tray12_Control_A1_Vietnam"  
## [13] "Tray13_Drought_A1_S.Africa"  "Tray14_Control_A1_Pakistan" 
## [15] "Tray15_Drought_A1_Australia" "Tray16_Control_A1_Texas"    
## [17] "Tray17_Drought_A1_Australia" "Tray18_Drought_A1_Pakistan" 
## [19] "Tray19_Drought_A1_Vietnam"   "Tray20_Drought_A1_Mexico"   
## [21] "Tray21_Drought_A1_Texas"     "Tray22_Control_A1_S.Africa" 
## [23] "Tray23_Control_A1_Australia" "Tray24_Drought_A1_Pakistan" 
## [25] "Tray25_Control_A1_Mexico"    "Tray26_Control_A1_Pakistan" 
## [27] "Tray27_Drought_A1_Australia" "Tray28_Drought_A1_Vietnam"  
## [29] "Tray29_Drought_A1_S.Africa"  "Tray30_Drought_A1_Texas"    
## [31] "Tray31_Control_A1_Mexico"    "Tray32_Drought_A1_Australia"
## [33] "Tray33_Drought_A1_Vietnam"   "Tray34_Drought_A1_S.Africa" 
## [35] "Tray35_Control_A1_Australia" "Tray36_Control_A1_Texas"    
## [37] "Tray37_Control_A1_S.Africa"  "Tray38_Drought_A1_Mexico"   
## [39] "Tray39_Drought_A1_Texas"     "Tray40_Drought_A1_Pakistan" 
## [41] "Tray41_Control_A1_Texas"     "Tray42_Drought_A1_Vietnam"  
## [43] "Tray43_Drought_A1_S.Africa"  "Tray44_Control_A1_Australia"
## [45] "Tray45_Drought_A1_Texas"     "Tray46_Drought_A1_Pakistan" 
## [47] "Tray47_Drought_A1_S.Africa"  "Tray48_Drought_A1_Mexico"   
## [49] "Tray49_Control_A1_Vietnam"   "Tray50_Control_A1_Pakistan" 
## [51] "Tray51_Control_A1_Vietnam"   "Tray52_Control_A1_Australia"
## [53] "Tray53_Drought_A1_Mexico"    "Tray54_Control_A1_Vietnam"  
## [55] "Tray55_Control_A1_S.Africa"  "Tray56_Drought_A1_Pakistan" 
## [57] "Tray57_Control_A1_Pakistan"  "Tray58_Control_A1_Texas"    
## [59] "Tray59_Control_A1_Mexico"    "Tray60_Drought_A1_Australia"

Also - since none of the recorded values are supposed to be negative - let’s clean it up:

final_spline3 <- subset(final_spline3, final_spline3$Fv.Fm > 0)
final_spline3 <- subset(final_spline3, final_spline3$Fq.Fm > 0)
final_spline3 <- subset(final_spline3, final_spline3$NPQ > 0)
final_spline3 <- subset(final_spline3, final_spline3$qP > 0)
final_spline3 <- subset(final_spline3, final_spline3$qN > 0)
final_spline3 <- subset(final_spline3, final_spline3$qL > 0)
final_spline3 <- subset(final_spline3, final_spline3$qI > 0)
final_spline3 <- subset(final_spline3, final_spline3$phiNO > 0)
final_spline3 <- subset(final_spline3, final_spline3$phiNPQ > 0)
final_spline3 <- subset(final_spline3, final_spline3$npq.t > 0)
final_spline3 <- subset(final_spline3, final_spline3$ChlIdx > 0)
final_spline3 <- subset(final_spline3, final_spline3$AriIdx > 0)
final_spline3 <- subset(final_spline3, final_spline3$NDVI > 0)

Plotting PS2 data

Fv/Fm

library(ggsci)

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = Fv.Fm, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "Fv/Fm (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Maximum Quantum Yield of Photosystem II")
C1_lgraph
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

library("dplyr")
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(cowplot)
## 
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggpubr':
## 
##     get_legend
get_p_value <- function(final_spline3) {
  t.test(Fv.Fm ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## Warning: There was 1 warning in `summarise()`.
## ℹ In argument: `p_value = get_p_value(cur_data())`.
## ℹ In group 1: `TOE = 0` `PlantName = "Australia"`.
## Caused by warning:
## ! `cur_data()` was deprecated in dplyr 1.1.0.
## ℹ Please use `pick()` instead.
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_FvFm.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
dev.off()
## quartz_off_screen 
##                 2

Fq/Fm

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = Fq.Fm, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "Fq'/Fm'") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Quantum Yield of Photosystem II in light adapted state")
get_p_value <- function(final_spline3) {
  t.test(Fq.Fm ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_FqFm.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
dev.off()
## quartz_off_screen 
##                 2

NPQ

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = NPQ, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "NPQ (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Non-photochemical Quenching [(Fm-Fm’)/Fm’]")
get_p_value <- function(final_spline3) {
    t.test(NPQ ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_NPQ.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Non-photochemical Quenching [(Fm-Fm’)/Fm’]' in 'mbcsToSbcs': ' substituted
## for ’ (U+2019)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Non-photochemical Quenching [(Fm-Fm’)/Fm’]' in 'mbcsToSbcs': ' substituted
## for ’ (U+2019)
dev.off()
## quartz_off_screen 
##                 2

qP

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = qP, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "qP (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Fraction of Open Reaction Centers (puddle mode) / photochemical quenching [(Fm’ – Fs’)/(Fm’ – F0’)]")
get_p_value <- function(final_spline3) {
    t.test(qP ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_qP.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Fraction of Open Reaction Centers (puddle mode) / photochemical quenching
## [(Fm’ – Fs’)/(Fm’ – F0’)]' in 'mbcsToSbcs': ' substituted for ’ (U+2019)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Fraction of Open Reaction Centers (puddle mode) / photochemical quenching
## [(Fm’ – Fs’)/(Fm’ – F0’)]' in 'mbcsToSbcs': - substituted for – (U+2013)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Fraction of Open Reaction Centers (puddle mode) / photochemical quenching
## [(Fm’ – Fs’)/(Fm’ – F0’)]' in 'mbcsToSbcs': ' substituted for ’ (U+2019)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Fraction of Open Reaction Centers (puddle mode) / photochemical quenching
## [(Fm’ – Fs’)/(Fm’ – F0’)]' in 'mbcsToSbcs': ' substituted for ’ (U+2019)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Fraction of Open Reaction Centers (puddle mode) / photochemical quenching
## [(Fm’ – Fs’)/(Fm’ – F0’)]' in 'mbcsToSbcs': - substituted for – (U+2013)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Fraction of Open Reaction Centers (puddle mode) / photochemical quenching
## [(Fm’ – Fs’)/(Fm’ – F0’)]' in 'mbcsToSbcs': ' substituted for ’ (U+2019)
dev.off()
## quartz_off_screen 
##                 2

qN

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = qN, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "qN (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Non-photochemical Quenching [1 – (Fm’ – F0’)/(Fm-F0)]")
get_p_value <- function(final_spline3) {
    t.test(qN ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_qN.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Non-photochemical Quenching [1 – (Fm’ – F0’)/(Fm-F0)]' in 'mbcsToSbcs': -
## substituted for – (U+2013)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Non-photochemical Quenching [1 – (Fm’ – F0’)/(Fm-F0)]' in 'mbcsToSbcs': '
## substituted for ’ (U+2019)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Non-photochemical Quenching [1 – (Fm’ – F0’)/(Fm-F0)]' in 'mbcsToSbcs': -
## substituted for – (U+2013)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Non-photochemical Quenching [1 – (Fm’ – F0’)/(Fm-F0)]' in 'mbcsToSbcs': '
## substituted for ’ (U+2019)
dev.off()
## quartz_off_screen 
##                 2

qL

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = qL, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "qL (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Fraction of Open Reaction Centers (lake mode) / photochemical quenching (qP*F0’/Fs’)")
get_p_value <- function(final_spline3) {
    t.test(qL ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_qL.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Fraction of Open Reaction Centers (lake mode) / photochemical quenching
## (qP*F0’/Fs’)' in 'mbcsToSbcs': ' substituted for ’ (U+2019)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Fraction of Open Reaction Centers (lake mode) / photochemical quenching
## (qP*F0’/Fs’)' in 'mbcsToSbcs': ' substituted for ’ (U+2019)
dev.off()
## quartz_off_screen 
##                 2

qE

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = qE, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "qE (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("fast relaxing component of NPQ (Fm*(Fm''-Fm’)/(Fm''*Fm’)")
get_p_value <- function(final_spline3) {
    t.test(qE ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Removed 162 rows containing missing values or values outside the scale range
## (`geom_line()`).

pdf("Batch04_PS2_qE.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Removed 162 rows containing missing values or values outside the scale range
## (`geom_line()`).
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'fast relaxing component of NPQ (Fm*(Fm''-Fm’)/(Fm''*Fm’)' in 'mbcsToSbcs':
## ' substituted for ’ (U+2019)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'fast relaxing component of NPQ (Fm*(Fm''-Fm’)/(Fm''*Fm’)' in 'mbcsToSbcs':
## ' substituted for ’ (U+2019)
dev.off()
## quartz_off_screen 
##                 2

qI

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = qI, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "qI (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Slow relaxing component of NPQ [(Fm-Fm'')/Fm'']")
get_p_value <- function(final_spline3) {
    t.test(qI ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_qI.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
dev.off()
## quartz_off_screen 
##                 2

PhiNO

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = phiNO, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "ɸNO (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Quantum Yield of non-regulated energy dissipation [1/(NPQ+1+qI*Fm/F0)]")
get_p_value <- function(final_spline3) {
    t.test(phiNO ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_phiNO.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## conversion failure on 'ɸNO (a.u.)' in 'mbcsToSbcs': for ɸ (U+0278)
dev.off()
## quartz_off_screen 
##                 2

PhiNPQ

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = phiNPQ, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "ɸNPQ (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Quantum Yield of NPQ (regulated energy dissipation) (1-Fq’/Fm’- ɸNO)")
get_p_value <- function(final_spline3) {
    t.test(phiNPQ ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_phiNPQ.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## conversion failure on 'ɸNPQ (a.u.)' in 'mbcsToSbcs': for ɸ (U+0278)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Quantum Yield of NPQ (regulated energy dissipation) (1-Fq’/Fm’- ɸNO)' in
## 'mbcsToSbcs': ' substituted for ’ (U+2019)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Quantum Yield of NPQ (regulated energy dissipation) (1-Fq’/Fm’- ɸNO)' in
## 'mbcsToSbcs': ' substituted for ’ (U+2019)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## conversion failure on 'Quantum Yield of NPQ (regulated energy dissipation)
## (1-Fq’/Fm’- ɸNO)' in 'mbcsToSbcs': for ɸ (U+0278)
dev.off()
## quartz_off_screen 
##                 2

NPQ(t)

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = npq.t, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "NPQ(t) (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Fast NPQ  4.88/(Fm’/F0’-1)-1")
get_p_value <- function(final_spline3) {
# CHANGE
    t.test(npq.t ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_NPQ(t).pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Fast NPQ 4.88/(Fm’/F0’-1)-1' in 'mbcsToSbcs': ' substituted for ’ (U+2019)
## Warning in grid.Call.graphics(C_text, as.graphicsAnnot(x$label), x$x, x$y, :
## for 'Fast NPQ 4.88/(Fm’/F0’-1)-1' in 'mbcsToSbcs': ' substituted for ’ (U+2019)
dev.off()
## quartz_off_screen 
##                 2

ChlIdx

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = ChlIdx, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "ChlIdx (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Chlorophyll Index")
get_p_value <- function(final_spline3) {
    t.test(ChlIdx ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_ChlIdx.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
dev.off()
## quartz_off_screen 
##                 2

AriIdx

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = AriIdx, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "AriIdx (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Anthocyanin Reflectance Index")
get_p_value <- function(final_spline3) {
    t.test(AriIdx ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

# CHANGE
pdf("Batch04_PS2_AriIdx.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
dev.off()
## quartz_off_screen 
##                 2

NDVI

C1_lgraph <- ggplot(data = final_spline3, aes(x = TOE, y = NDVI, group = tray.ID, color = TrayInfo)) 
C1_lgraph <- C1_lgraph + geom_line(alpha = 0.1) + facet_wrap(~ PlantName, ncol = 6)
C1_lgraph <- C1_lgraph + stat_summary(fun.data = mean_se, geom = "ribbon", linetype = 0, aes(group = TrayInfo), alpha = 0.3) 
C1_lgraph <- C1_lgraph + stat_summary(fun = mean, aes(group = TrayInfo), size = 0.7, geom = "line", linetype = "dashed") 
C1_lgraph <- C1_lgraph + stat_compare_means(aes(group = TrayInfo), label = "p.signif", method = "t.test", hide.ns = F) 
C1_lgraph <- C1_lgraph + labs(x = "", y = "NDVI (a.u.)") + scale_color_d3("category10") + theme(legend.position = "top") + ggtitle("Normalized Difference Vegetation Index")
get_p_value <- function(final_spline3) {
    t.test(NDVI ~ TrayInfo, data = final_spline3)$p.value
}
p_values <- final_spline3 %>%
  group_by(TOE, PlantName) %>%
  summarise(p_value = get_p_value(cur_data())) %>%
  ungroup()
## `summarise()` has grouped output by 'TOE'. You can override using the `.groups`
## argument.
p_values$LOD <- -log10(p_values$p_value)

C1_pplot <- ggplot(p_values, aes(x = TOE, y = LOD)) 
C1_pplot <- C1_pplot + geom_line() + geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") + facet_wrap(~ PlantName, ncol = 6)
C1_pplot <- C1_pplot + labs(x = "Hours Of Imaging", y = "-log10(p-value)") 
C1_pplot <- C1_pplot + theme_minimal() + theme_bw() + theme(strip.text = element_blank(), strip.background = element_blank()) 

plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle

pdf("Batch04_PS2_NDVI.pdf", height = 5, width = 20)
plot_grid(C1_lgraph, C1_pplot, rel_heights = c(4,1), ncol = 1, align = "v", axis = "l")
## Warning: Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Computation failed in `stat_compare_means()`.
## Caused by error in `purrr::map()`:
## ℹ In index: 1.
## Caused by error in `.check_npc_coord()`:
## ! '*.npc coord for x axis should be either a numeric value in [0-1] or a character strings including one of right, left, center, centre, middle
dev.off()
## quartz_off_screen 
##                 2

OK - that’s all - but just before we finish this - let’s save all of the data:

write.csv(final_spline3, "Final_Batch.04.PS2.csv", row.names = F)