This experiment is done in September 2023 with 5 Arabidopsis genotypes for DUF247 project. In brief, seeds were germinate in 1/2 MS media for one week, and then trasplanted to the soil with 100% WHC for one more week until the soil reached 50% WHC, then salt stress was applied by soaking pots in 200 mM NaCl, resulting in final concentration of 100 mM NaCl. The shoot growth was measure over the period of 12 days, by measuring growth rate for 3 days before stress exposure and 9 days of stress exposure.

getwd()
## [1] "C:/Users/Julkowska Lab/Desktop/R codes by Maryam/20240307_At_5geno_soil_phenorigs_experiment_shoot_growth"
#Let’s import ALL the files with data:

my_files <- list.files(pattern="-single-value-traits.csv")
my_files
## [1] "raspiK_cameraA_KA.result.csv-single-value-traits.csv"
## [2] "raspiM_cameraA-single-value-traits.csv"              
## [3] "raspiM_cameraB-single-value-traits.csv"              
## [4] "raspiT_cameraA-single-value-traits.csv"              
## [5] "raspiT_cameraB-single-value-traits.csv"              
## [6] "raspiU_cameraA-single-value-traits.csv"              
## [7] "raspiU_cameraB-single-value-traits.csv"              
## [8] "raspiV_cameraA_VA.result.csv-single-value-traits.csv"
## [9] "raspiV_cameraB_VB.result.csv-single-value-traits.csv"

Let’s import ALL the data as one dataset:

M_A <- read.csv("raspiM_cameraA-single-value-traits.csv" )
M_B <- read.csv("raspiM_cameraB-single-value-traits.csv" )
T_A <- read.csv("raspiT_cameraA-single-value-traits.csv"  )
T_B <- read.csv("raspiT_cameraB-single-value-traits.csv"  )
V_A <- read.csv("raspiV_cameraA_VA.result.csv-single-value-traits.csv")
V_B <- read.csv("raspiV_cameraB_VB.result.csv-single-value-traits.csv")
U_A <- read.csv("raspiU_cameraA-single-value-traits.csv"   )
U_B <- read.csv("raspiU_cameraB-single-value-traits.csv"  )

colnames(M_A) %in% colnames(M_B)
##  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [31] TRUE
all_data <- rbind(M_A, M_B)
all_data <- rbind(all_data, T_A)
all_data <- rbind(all_data, T_B)
all_data <- rbind(all_data, V_A)
all_data <- rbind(all_data, V_B)
all_data <- rbind(all_data, U_A)
all_data <- rbind(all_data, U_B)

Let’s remove the columns we are not using anyways:

colnames(all_data)
##  [1] "camera"               "imgtype"              "zoom"                
##  [4] "exposure"             "gain"                 "frame"               
##  [7] "lifter"               "timestamp"            "id"                  
## [10] "plantbarcode"         "treatment"            "cartag"              
## [13] "measurementlabel"     "other"                "image"               
## [16] "sample"               "in_bounds"            "area"                
## [19] "convex_hull_area"     "solidity"             "perimeter"           
## [22] "width"                "height"               "longest_path"        
## [25] "convex_hull_vertices" "object_in_frame"      "ellipse_major_axis"  
## [28] "ellipse_minor_axis"   "ellipse_angle"        "ellipse_eccentricity"
## [31] "plantID"
all_data2 <- all_data[,c(31,18:30)]
all_data2

Let’s get all of the mega-data isolated from our PlantID - so we can fuse it with the identifying information - to look at differences between treatments + genotypes:

all_data2$info <- strsplit(all_data2$plantID, "_")
all_data2$info[1]
## [[1]]
## [1] "raspiM"                      "cameraA.2023.10.12-11.00.01"
## [3] "11"
all_data2$info[1][[1]][1]
## [1] "raspiM"
all_data2$info[1][[1]][3]
## [1] "11"
all_data2$info[2][[1]][1]
## [1] "raspiM"
all_data2$info[2][[1]][3]
## [1] "6"

We can extract Raspi info and Position info from here

for(i in 1:nrow(all_data2)){
  all_data2$RasPi[i] <- all_data2$info[i][[1]][1]
  all_data2$Position[i] <- all_data2$info[i][[1]][3]
  all_data2$info2[i] <- all_data2$info[i][[1]][2]
}
all_data2

Now - let’s isolate TIME by strsplitting on dash:

all_data2$info3 <- strsplit(all_data2$info2, "-")
all_data2$info3[1]
## [[1]]
## [1] "cameraA.2023.10.12" "11.00.01"
for(i in 1:nrow(all_data2)){
  all_data2$time[i] <- all_data2$info3[i][[1]][2]
  all_data2$info4[i] <- all_data2$info3[i][[1]][1]
}

then - let’s isolate Camera info and Date info:

all_data2$info4 <- gsub(".2023", "-2023", all_data2$info4)
all_data2$info5 <- strsplit(all_data2$info4, "-")
all_data2$info5[2]
## [[1]]
## [1] "cameraA"    "2023.10.04"
for(i in 1:nrow(all_data2)){
  all_data2$cameraID[i] <- all_data2$info5[i][[1]][1]
  all_data2$Date[i] <- all_data2$info5[i][[1]][2]
}

all_data2

Let’s re-shape the dataframe once again:

colnames(all_data2)
##  [1] "plantID"              "area"                 "convex_hull_area"    
##  [4] "solidity"             "perimeter"            "width"               
##  [7] "height"               "longest_path"         "convex_hull_vertices"
## [10] "object_in_frame"      "ellipse_major_axis"   "ellipse_minor_axis"  
## [13] "ellipse_angle"        "ellipse_eccentricity" "info"                
## [16] "RasPi"                "Position"             "info2"               
## [19] "info3"                "time"                 "info4"               
## [22] "info5"                "cameraID"             "Date"
data <- all_data2[,c(1,16,23,24,20,17,2:14)]
head(data)

In order to fuse this with our decoding file - we need to create unique plantID by fusing RasPi, CameraID and position:

data$ID <- paste(data$RasPi, data$cameraID, data$Position, sep="_")
data

now - to decode - let;s upload our decoding file:

list.files(pattern = ".csv")
##  [1] "raspiK_cameraA_KA.result.csv-single-value-traits.csv"
##  [2] "raspiM_cameraA-single-value-traits.csv"              
##  [3] "raspiM_cameraB-single-value-traits.csv"              
##  [4] "raspiT_cameraA-single-value-traits.csv"              
##  [5] "raspiT_cameraB-single-value-traits.csv"              
##  [6] "raspiU_cameraA-single-value-traits.csv"              
##  [7] "raspiU_cameraB-single-value-traits.csv"              
##  [8] "raspiV_cameraA_VA.result.csv-single-value-traits.csv"
##  [9] "raspiV_cameraB_VB.result.csv-single-value-traits.csv"
## [10] "soil_decoding_file.csv"                              
## [11] "soil_decoding_file_merge_all_controls.csv"
decoding <- read.csv("soil_decoding_file_merge_all_controls.csv")
decoding$ID <- paste(decoding$RasPi, decoding$Camera, decoding$position, sep="_")
decoding

let;s merge the files:

# to check if it will merge OK
decoding$ID %in% data$ID
##   [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
##  [16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
##  [31] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
##  [46] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
##  [61] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
##  [76] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
##  [91] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [106] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
#data$ID %in% decoding$ID
library(reshape2)
deco_data <- merge(data, decoding, by = "ID", all = TRUE)
deco_data
unique(deco_data$RasPi.x)
## [1] "raspiM" "raspiT" "raspiU" "raspiV"
unique(deco_data$Date)
##  [1] "2023.10.11" "2023.10.05" "2023.10.03" "2023.10.06" "2023.10.14"
##  [6] "2023.10.10" "2023.10.07" "2023.10.04" "2023.10.13" "2023.10.08"
## [11] "2023.10.09" "2023.10.12"
temp <- subset(deco_data, deco_data$Date == "2023.10.03")
unique(temp$time)
##  [1] "16.30.01" "21.00.01" "22.00.02" "20.30.01" "19.00.01" "19.30.01"
##  [7] "18.30.02" "21.30.01" "15.00.01" "17.00.01" "16.00.01" "20.00.01"
## [13] "17.30.02" "15.30.01" "18.00.01" "14.30.02" "14.00.01" "22.30.01"
## [19] "21.30.02" "17.30.01" "18.30.01" "22.00.01" "14.30.01"

OK - let’s calculate the time (in minutes) from the START of the experiment.

1st image is on 2023.10.03 and within that day - the 1st recorded image is taken at 14.00.01. So - we need to further split the time into hours and minutes and then calculate total minutes of experiment:

deco_data$Hour <- substr(deco_data$time, 1, 2)
deco_data$Minute <- substr(deco_data$time, 4, 5)
deco_data$DayOfExp <- deco_data$Date
deco_data$DayOfExp <- gsub("2023.10.03", "0", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.04", "1", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.05", "2", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.06", "3", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.07", "4", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.08", "5", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.09", "6", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.10", "7", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.11", "8", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.12", "9", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.13", "10", deco_data$DayOfExp)
deco_data$DayOfExp <- gsub("2023.10.14", "11", deco_data$DayOfExp)
deco_data$DayOfExp <- as.numeric(as.character(deco_data$DayOfExp))
deco_data$Minute <- as.numeric(as.character(deco_data$Minute))
deco_data$Hour <- as.numeric(as.character(deco_data$Hour))
deco_data$MinOfExp <- deco_data$Minute + (deco_data$Hour - 8)*60 + (deco_data$DayOfExp*24*60)

deco_data

Let’s see if it all makes sense now:

library(ggplot2)
library(ggpubr)
unique(deco_data$Treatment)
## [1] "Salt "   NA        "Control"
deco_data$Treatment <- gsub(" ", "", deco_data$Treatment)
want <- c("Control", "Salt")
deco_data2 <- subset(deco_data, deco_data$Treatment %in% want)
deco_data2
Area_graph <- ggplot(data=deco_data2, aes(x= MinOfExp, y=area, group = ID, color = Treatment)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
# Area_graph <- Area_graph + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group=treatment), alpha=0.3) + stat_summary(fun.y=mean, aes(group= Treatment),  size=0.7, geom="line", linetype = "dashed")
# Area_graph <- Area_graph + ggtitle("") + scale_colour_manual(values = c("dodgerblue3", "tomato1", "tomato4"))
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
#Area_graph <- Area_graph + stat_compare_means(aes(group = treatment), label = "p.signif", method = "t.test", hide.ns = T)
Area_graph

ok - there are still some odd things going on - but that’s why we need to curate the data

Curating the data: In order to avoid bias - lets make the subsets of all plants belonging to same genotype AND treatment - and remove the individuals that did not grow / were not detected correctly from the deco data.

We will save all the individuals (ID) to be deleted from curated datasets in “get_lost” list:

unique(deco_data2$Treatment)
## [1] "Salt"    "Control"
unique(deco_data2$Genotype)
## [1] "2xko-E" "wrky"   "duf"    "2xko-D" "col"
deco_data2$Genotype<- gsub("col", "Col-0", deco_data2$Genotype)
Control <- subset(deco_data2, deco_data2$Treatment == "Control")
CCol <- subset(Control, Control$Genotype == "Col-0")
Cduf <- subset(Control, Control$Genotype == "duf")
CW <- subset(Control, Control$Genotype == "wrky")
C2xD <- subset(Control, Control$Genotype == "2xko-D")
C2xE <- subset(Control, Control$Genotype == "2xko-E")

Stress <- subset(deco_data2, deco_data2$Treatment == "Salt")
SCol <- subset(Stress, Stress$Genotype == "Col-0")
Sduf <- subset(Stress, Stress$Genotype == "duf")
SW <- subset(Stress, Stress$Genotype == "wrky")
S2xD <- subset(Stress, Stress$Genotype == "2xko-D")
S2xE <- subset(Stress, Stress$Genotype == "2xko-E")

CCol
Cduf

Cool - now we can plot the data for each individual combination:

library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
Area_graph <- ggplot(data=CCol, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
unique(CCol$ID)
##  [1] "raspiT_cameraA_8"  "raspiT_cameraB_10" "raspiT_cameraB_13"
##  [4] "raspiT_cameraB_2"  "raspiT_cameraB_8"  "raspiT_cameraB_9" 
##  [7] "raspiV_cameraA_8"  "raspiV_cameraB_10" "raspiV_cameraB_13"
## [10] "raspiV_cameraB_2"  "raspiV_cameraB_8"  "raspiV_cameraB_9"
get_lost_CCol <- c("raspiV_cameraB_9" ,"raspiV_cameraB_10","raspiV_cameraB_2", "raspiV_cameraB_8", "raspiV_cameraA_8", "raspiV_cameraB_13", "raspiV_cameraA_8" )
CColClean <- subset(CCol, !(CCol$ID %in% get_lost_CCol))
Area_graph <- ggplot(data=CColClean, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
Area_graph <- ggplot(data=Cduf, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
unique(Cduf$ID)
##  [1] "raspiT_cameraA_10" "raspiT_cameraA_11" "raspiT_cameraA_12"
##  [4] "raspiT_cameraA_4"  "raspiT_cameraA_6"  "raspiT_cameraB_6" 
##  [7] "raspiV_cameraA_10" "raspiV_cameraA_11" "raspiV_cameraA_12"
## [10] "raspiV_cameraA_4"  "raspiV_cameraA_6"  "raspiV_cameraB_6"
get_lost_Cduf <- c("raspiV_cameraA_10", "raspiV_cameraA_12", "raspiV_cameraA_4", "raspiV_cameraB_6", "raspiV_cameraA_6")
CdClean <- subset(Cduf, !(Cduf$ID %in% get_lost_Cduf))
Area_graph <- ggplot(data=CdClean, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
Area_graph <- ggplot(data=CW, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
unique(CW$ID)
##  [1] "raspiT_cameraA_1"  "raspiT_cameraA_3"  "raspiT_cameraA_5" 
##  [4] "raspiT_cameraA_9"  "raspiT_cameraB_11" "raspiT_cameraB_5" 
##  [7] "raspiV_cameraA_1"  "raspiV_cameraA_3"  "raspiV_cameraA_5" 
## [10] "raspiV_cameraA_9"  "raspiV_cameraB_11" "raspiV_cameraB_5"
get_lost_CW <- c("raspiV_cameraA_3", "raspiV_cameraB_5" , "raspiV_cameraA_1", "raspiV_cameraA_5", "raspiV_cameraB_11", "raspiT_cameraB_5" ,"raspiV_cameraA_3","raspiT_cameraB_11", "raspiV_cameraA_9" )
CWClean <- subset(CW, !(CW$ID %in% get_lost_CW))
Area_graph <- ggplot(data=CWClean, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
Area_graph <- ggplot(data=C2xD , aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
unique(C2xD$ID)
##  [1] "raspiT_cameraA_14" "raspiT_cameraA_15" "raspiT_cameraB_1" 
##  [4] "raspiT_cameraB_3"  "raspiT_cameraB_4"  "raspiT_cameraB_7" 
##  [7] "raspiV_cameraA_14" "raspiV_cameraA_15" "raspiV_cameraB_1" 
## [10] "raspiV_cameraB_3"  "raspiV_cameraB_4"  "raspiV_cameraB_7"
get_lost_C2XD <- c("raspiV_cameraB_1", "raspiV_cameraA_14"  , "raspiV_cameraB_3", "raspiV_cameraB_7", "raspiT_cameraA_15", "raspiV_cameraA_15", "raspiT_cameraB_1" )
C2XDClean <- subset(C2xD, !(C2xD$ID %in% get_lost_C2XD))
Area_graph <- ggplot(data=C2XDClean, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
Area_graph <- ggplot(data=C2xE , aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
unique(C2xE$ID)
##  [1] "raspiT_cameraA_0"  "raspiT_cameraA_13" "raspiT_cameraA_2" 
##  [4] "raspiT_cameraA_7"  "raspiT_cameraB_0"  "raspiT_cameraB_12"
##  [7] "raspiV_cameraA_0"  "raspiV_cameraA_13" "raspiV_cameraA_2" 
## [10] "raspiV_cameraA_7"  "raspiV_cameraB_0"  "raspiV_cameraB_12"
get_lost_C2XE <- c("raspiT_cameraB_0", "raspiV_cameraB_12"  , "raspiV_cameraA_13", "raspiV_cameraB_0" , "raspiV_cameraA_0", "raspiT_cameraA_2" , "raspiV_cameraA_7" )
C2XEClean <- subset(C2xE, !(C2xE$ID %in% get_lost_C2XE))
Area_graph <- ggplot(data=C2XEClean, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
Area_graph <- ggplot(data=SCol , aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
Area_graph <- ggplot(data=Sduf, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
Area_graph <- ggplot(data=SW , aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
unique(SW$ID)
##  [1] "raspiM_cameraA_1"  "raspiM_cameraA_3"  "raspiM_cameraA_5" 
##  [4] "raspiM_cameraA_9"  "raspiM_cameraB_11" "raspiM_cameraB_5" 
##  [7] "raspiU_cameraA_1"  "raspiU_cameraA_3"  "raspiU_cameraA_5" 
## [10] "raspiU_cameraA_9"  "raspiU_cameraB_11" "raspiU_cameraB_5"
get_lost_SW <- c("raspiM_cameraA_1" )
SWClean <- subset(SW, !(SW$ID %in% get_lost_SW))
Area_graph <- ggplot(data=SWClean, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
Area_graph <- ggplot(data=S2xD, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
unique(S2xD$ID)
##  [1] "raspiM_cameraA_14" "raspiM_cameraA_15" "raspiM_cameraB_1" 
##  [4] "raspiM_cameraB_3"  "raspiM_cameraB_4"  "raspiM_cameraB_7" 
##  [7] "raspiU_cameraA_14" "raspiU_cameraA_15" "raspiU_cameraB_1" 
## [10] "raspiU_cameraB_3"  "raspiU_cameraB_4"  "raspiU_cameraB_7"
get_lost_S2xD <- c("raspiM_cameraA_14", "raspiM_cameraB_7")
S2xDClean <- subset(S2xD, !(S2xD$ID %in% get_lost_S2xD))
Area_graph <- ggplot(data=S2xDClean, aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
Area_graph <- ggplot(data=S2xE  , aes(x= MinOfExp, y=area, group = ID)) 
Area_graph <- Area_graph + geom_line(alpha = 0.1) 
Area_graph <- Area_graph + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
ggplotly(Area_graph)
get_lost <- c("raspiV_cameraB_9" ,"raspiV_cameraB_10","raspiV_cameraB_2", "raspiV_cameraB_8", "raspiV_cameraA_8", "raspiV_cameraB_13", "raspiV_cameraA_8", "raspiV_cameraA_10", "raspiV_cameraA_12", "raspiV_cameraA_4", "raspiV_cameraB_6", "raspiV_cameraA_6", "raspiV_cameraA_3", "raspiV_cameraB_5" , "raspiV_cameraA_1", "raspiV_cameraA_5", "raspiV_cameraB_11", "raspiT_cameraB_5" ,"raspiV_cameraA_3","raspiT_cameraB_11", "raspiV_cameraA_9", "raspiV_cameraB_1", "raspiV_cameraA_14"  , "raspiV_cameraB_3", "raspiV_cameraB_7", "raspiT_cameraA_15", "raspiV_cameraA_15", "raspiT_cameraB_1", "raspiT_cameraB_0", "raspiV_cameraB_12"  , "raspiV_cameraA_13", "raspiV_cameraB_0" , "raspiV_cameraA_0", "raspiT_cameraA_2" , "raspiV_cameraA_7", "raspiM_cameraA_1", "raspiM_cameraA_14", "raspiM_cameraB_7", "raspiM_cameraA_0")


data_curated <- subset(deco_data2, !(deco_data2$ID %in% get_lost))
unique(data_curated$Genotype)
## [1] "duf"    "2xko-E" "2xko-D" "wrky"   "Col-0"
length(unique(deco_data2$ID))
## [1] 120
length(unique(data_curated$ID))
## [1] 83
Area_graph2 <- ggplot(data=data_curated, aes(x= MinOfExp, y=area, group = ID, color = Treatment)) 
Area_graph2 <- Area_graph2 + geom_line(alpha = 0.1) 
#Area_graph <- Area_graph + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group=Treatment), alpha=0.3) + stat_summary(fun.y=mean, aes(group= Treatment),  size=0.7, geom="line", linetype = "dashed")
# Area_graph <- Area_graph + ggtitle("") + scale_colour_manual(values = c("dodgerblue3", "tomato1", "tomato4"))
Area_graph2 <- Area_graph2 + ylab("Rosette Area (pixels)") + xlab("Time (minutes)")
#Area_graph <- Area_graph + stat_compare_means(aes(group = treatment), label = "p.signif", method = "t.test", hide.ns = T)
ggplotly(Area_graph2)

The last thing I would like to do - to remove all of the funky timepoints - is to remove the subsequent timepoints that differ more than 1000 pixels from previous ones.

For this - let’s subset the data for one ID only:

temp_file <- subset(data_curated, data_curated$ID == unique(data_curated$ID)[1])
dim(temp_file)
## [1] 358  29
temp_file
plot(temp_file$area ~ temp_file$MinOfExp)

MinOfExp <- seq(0, 16710,by=30)
MinOfExp
##   [1]     0    30    60    90   120   150   180   210   240   270   300   330
##  [13]   360   390   420   450   480   510   540   570   600   630   660   690
##  [25]   720   750   780   810   840   870   900   930   960   990  1020  1050
##  [37]  1080  1110  1140  1170  1200  1230  1260  1290  1320  1350  1380  1410
##  [49]  1440  1470  1500  1530  1560  1590  1620  1650  1680  1710  1740  1770
##  [61]  1800  1830  1860  1890  1920  1950  1980  2010  2040  2070  2100  2130
##  [73]  2160  2190  2220  2250  2280  2310  2340  2370  2400  2430  2460  2490
##  [85]  2520  2550  2580  2610  2640  2670  2700  2730  2760  2790  2820  2850
##  [97]  2880  2910  2940  2970  3000  3030  3060  3090  3120  3150  3180  3210
## [109]  3240  3270  3300  3330  3360  3390  3420  3450  3480  3510  3540  3570
## [121]  3600  3630  3660  3690  3720  3750  3780  3810  3840  3870  3900  3930
## [133]  3960  3990  4020  4050  4080  4110  4140  4170  4200  4230  4260  4290
## [145]  4320  4350  4380  4410  4440  4470  4500  4530  4560  4590  4620  4650
## [157]  4680  4710  4740  4770  4800  4830  4860  4890  4920  4950  4980  5010
## [169]  5040  5070  5100  5130  5160  5190  5220  5250  5280  5310  5340  5370
## [181]  5400  5430  5460  5490  5520  5550  5580  5610  5640  5670  5700  5730
## [193]  5760  5790  5820  5850  5880  5910  5940  5970  6000  6030  6060  6090
## [205]  6120  6150  6180  6210  6240  6270  6300  6330  6360  6390  6420  6450
## [217]  6480  6510  6540  6570  6600  6630  6660  6690  6720  6750  6780  6810
## [229]  6840  6870  6900  6930  6960  6990  7020  7050  7080  7110  7140  7170
## [241]  7200  7230  7260  7290  7320  7350  7380  7410  7440  7470  7500  7530
## [253]  7560  7590  7620  7650  7680  7710  7740  7770  7800  7830  7860  7890
## [265]  7920  7950  7980  8010  8040  8070  8100  8130  8160  8190  8220  8250
## [277]  8280  8310  8340  8370  8400  8430  8460  8490  8520  8550  8580  8610
## [289]  8640  8670  8700  8730  8760  8790  8820  8850  8880  8910  8940  8970
## [301]  9000  9030  9060  9090  9120  9150  9180  9210  9240  9270  9300  9330
## [313]  9360  9390  9420  9450  9480  9510  9540  9570  9600  9630  9660  9690
## [325]  9720  9750  9780  9810  9840  9870  9900  9930  9960  9990 10020 10050
## [337] 10080 10110 10140 10170 10200 10230 10260 10290 10320 10350 10380 10410
## [349] 10440 10470 10500 10530 10560 10590 10620 10650 10680 10710 10740 10770
## [361] 10800 10830 10860 10890 10920 10950 10980 11010 11040 11070 11100 11130
## [373] 11160 11190 11220 11250 11280 11310 11340 11370 11400 11430 11460 11490
## [385] 11520 11550 11580 11610 11640 11670 11700 11730 11760 11790 11820 11850
## [397] 11880 11910 11940 11970 12000 12030 12060 12090 12120 12150 12180 12210
## [409] 12240 12270 12300 12330 12360 12390 12420 12450 12480 12510 12540 12570
## [421] 12600 12630 12660 12690 12720 12750 12780 12810 12840 12870 12900 12930
## [433] 12960 12990 13020 13050 13080 13110 13140 13170 13200 13230 13260 13290
## [445] 13320 13350 13380 13410 13440 13470 13500 13530 13560 13590 13620 13650
## [457] 13680 13710 13740 13770 13800 13830 13860 13890 13920 13950 13980 14010
## [469] 14040 14070 14100 14130 14160 14190 14220 14250 14280 14310 14340 14370
## [481] 14400 14430 14460 14490 14520 14550 14580 14610 14640 14670 14700 14730
## [493] 14760 14790 14820 14850 14880 14910 14940 14970 15000 15030 15060 15090
## [505] 15120 15150 15180 15210 15240 15270 15300 15330 15360 15390 15420 15450
## [517] 15480 15510 15540 15570 15600 15630 15660 15690 15720 15750 15780 15810
## [529] 15840 15870 15900 15930 15960 15990 16020 16050 16080 16110 16140 16170
## [541] 16200 16230 16260 16290 16320 16350 16380 16410 16440 16470 16500 16530
## [553] 16560 16590 16620 16650 16680 16710
length(MinOfExp)
## [1] 558
max(temp_file$MinOfExp)
## [1] 16710
plot.spl <- with(temp_file, smooth.spline(MinOfExp, area, df = 30))
plot(area ~ MinOfExp, data = temp_file)
lines(plot.spl, col = "blue")
lines(predict(plot.spl, MinOfExp), col="red")

temp_file
names <- c(text="plant.id", "Genotype", "Treatment", "MinOfExp", "Area")
spline_data <- data.frame()
for (k in names) spline_data[[k]] <- as.character()
spline_data
pred_temp <- predict(plot.spl, MinOfExp)
pred_temp
## $x
##   [1]     0    30    60    90   120   150   180   210   240   270   300   330
##  [13]   360   390   420   450   480   510   540   570   600   630   660   690
##  [25]   720   750   780   810   840   870   900   930   960   990  1020  1050
##  [37]  1080  1110  1140  1170  1200  1230  1260  1290  1320  1350  1380  1410
##  [49]  1440  1470  1500  1530  1560  1590  1620  1650  1680  1710  1740  1770
##  [61]  1800  1830  1860  1890  1920  1950  1980  2010  2040  2070  2100  2130
##  [73]  2160  2190  2220  2250  2280  2310  2340  2370  2400  2430  2460  2490
##  [85]  2520  2550  2580  2610  2640  2670  2700  2730  2760  2790  2820  2850
##  [97]  2880  2910  2940  2970  3000  3030  3060  3090  3120  3150  3180  3210
## [109]  3240  3270  3300  3330  3360  3390  3420  3450  3480  3510  3540  3570
## [121]  3600  3630  3660  3690  3720  3750  3780  3810  3840  3870  3900  3930
## [133]  3960  3990  4020  4050  4080  4110  4140  4170  4200  4230  4260  4290
## [145]  4320  4350  4380  4410  4440  4470  4500  4530  4560  4590  4620  4650
## [157]  4680  4710  4740  4770  4800  4830  4860  4890  4920  4950  4980  5010
## [169]  5040  5070  5100  5130  5160  5190  5220  5250  5280  5310  5340  5370
## [181]  5400  5430  5460  5490  5520  5550  5580  5610  5640  5670  5700  5730
## [193]  5760  5790  5820  5850  5880  5910  5940  5970  6000  6030  6060  6090
## [205]  6120  6150  6180  6210  6240  6270  6300  6330  6360  6390  6420  6450
## [217]  6480  6510  6540  6570  6600  6630  6660  6690  6720  6750  6780  6810
## [229]  6840  6870  6900  6930  6960  6990  7020  7050  7080  7110  7140  7170
## [241]  7200  7230  7260  7290  7320  7350  7380  7410  7440  7470  7500  7530
## [253]  7560  7590  7620  7650  7680  7710  7740  7770  7800  7830  7860  7890
## [265]  7920  7950  7980  8010  8040  8070  8100  8130  8160  8190  8220  8250
## [277]  8280  8310  8340  8370  8400  8430  8460  8490  8520  8550  8580  8610
## [289]  8640  8670  8700  8730  8760  8790  8820  8850  8880  8910  8940  8970
## [301]  9000  9030  9060  9090  9120  9150  9180  9210  9240  9270  9300  9330
## [313]  9360  9390  9420  9450  9480  9510  9540  9570  9600  9630  9660  9690
## [325]  9720  9750  9780  9810  9840  9870  9900  9930  9960  9990 10020 10050
## [337] 10080 10110 10140 10170 10200 10230 10260 10290 10320 10350 10380 10410
## [349] 10440 10470 10500 10530 10560 10590 10620 10650 10680 10710 10740 10770
## [361] 10800 10830 10860 10890 10920 10950 10980 11010 11040 11070 11100 11130
## [373] 11160 11190 11220 11250 11280 11310 11340 11370 11400 11430 11460 11490
## [385] 11520 11550 11580 11610 11640 11670 11700 11730 11760 11790 11820 11850
## [397] 11880 11910 11940 11970 12000 12030 12060 12090 12120 12150 12180 12210
## [409] 12240 12270 12300 12330 12360 12390 12420 12450 12480 12510 12540 12570
## [421] 12600 12630 12660 12690 12720 12750 12780 12810 12840 12870 12900 12930
## [433] 12960 12990 13020 13050 13080 13110 13140 13170 13200 13230 13260 13290
## [445] 13320 13350 13380 13410 13440 13470 13500 13530 13560 13590 13620 13650
## [457] 13680 13710 13740 13770 13800 13830 13860 13890 13920 13950 13980 14010
## [469] 14040 14070 14100 14130 14160 14190 14220 14250 14280 14310 14340 14370
## [481] 14400 14430 14460 14490 14520 14550 14580 14610 14640 14670 14700 14730
## [493] 14760 14790 14820 14850 14880 14910 14940 14970 15000 15030 15060 15090
## [505] 15120 15150 15180 15210 15240 15270 15300 15330 15360 15390 15420 15450
## [517] 15480 15510 15540 15570 15600 15630 15660 15690 15720 15750 15780 15810
## [529] 15840 15870 15900 15930 15960 15990 16020 16050 16080 16110 16140 16170
## [541] 16200 16230 16260 16290 16320 16350 16380 16410 16440 16470 16500 16530
## [553] 16560 16590 16620 16650 16680 16710
## 
## $y
##   [1]  2825.240  2842.968  2860.696  2878.423  2896.151  2913.878  2931.606
##   [8]  2949.334  2967.061  2984.789  3002.517  3020.244  3037.972  3055.675
##  [15]  3073.255  3090.601  3107.617  3124.254  3140.479  3156.268  3171.650
##  [22]  3186.663  3201.334  3215.636  3229.530  3242.975  3255.966  3268.636
##  [29]  3281.151  3293.656  3306.210  3318.846  3331.600  3344.508  3357.604
##  [36]  3370.923  3384.502  3398.375  3412.578  3427.145  3442.113  3457.515
##  [43]  3473.388  3489.766  3506.685  3524.181  3542.288  3561.041  3580.441
##  [50]  3600.352  3620.601  3641.016  3661.429  3681.681  3701.615  3721.086
##  [57]  3739.991  3758.236  3775.765  3792.661  3809.044  3825.036  3840.753
##  [64]  3856.306  3871.806  3887.359  3903.072  3919.049  3935.388  3952.155
##  [71]  3969.411  3987.184  4005.377  4023.865  4042.521  4061.242  4080.021
##  [78]  4098.878  4117.839  4136.970  4156.344  4176.038  4196.126  4216.682
##  [85]  4237.782  4259.500  4281.911  4305.089  4329.110  4354.048  4379.979
##  [92]  4406.976  4435.115  4464.470  4495.116  4527.128  4560.581  4595.423
##  [99]  4631.097  4666.920  4702.209  4736.357  4769.061  4800.096  4829.259
## [106]  4856.445  4881.572  4904.614  4925.751  4945.219  4963.254  4980.095
## [113]  4996.006  5011.252  5026.115  5040.929  5056.041  5071.775  5088.351
## [120]  5105.968  5124.821  5145.076  5166.773  5189.919  5214.532  5240.662
## [127]  5268.368  5297.709  5328.744  5361.531  5396.130  5432.600  5470.999
## [134]  5511.386  5553.820  5598.361  5645.066  5693.995  5745.207  5798.761
## [141]  5854.715  5913.129  5974.061  6037.480  6102.993  6170.119  6238.344
## [148]  6307.036  6375.532  6443.169  6509.286  6573.220  6634.308  6691.888
## [155]  6745.297  6794.081  6838.614  6879.481  6917.289  6952.751  6986.604
## [162]  7019.607  7052.603  7086.457  7122.035  7160.121  7201.176  7245.582
## [169]  7293.567  7344.753  7398.604  7454.656  7512.703  7572.609  7634.236
## [176]  7697.445  7762.100  7828.062  7895.194  7963.358  8032.416  8102.231
## [183]  8172.665  8243.579  8314.838  8386.302  8457.834  8529.296  8600.550
## [190]  8671.460  8741.886  8811.653  8880.422  8947.820  9013.475  9077.030
## [197]  9138.137  9196.484  9251.922  9304.339  9353.625  9399.726  9442.804
## [204]  9483.076  9520.768  9556.130  9589.423  9620.967  9651.331  9681.147
## [211]  9711.049  9741.681  9773.689  9807.720  9844.342  9883.817  9926.324
## [218]  9971.956 10020.436 10071.399 10124.520 10179.641 10236.649 10295.427
## [225] 10355.861 10417.835 10481.234 10545.944 10611.849 10678.834 10746.784
## [232] 10815.584 10885.119 10955.273 11025.932 11096.981 11168.304 11239.786
## [239] 11311.312 11382.767 11453.956 11524.359 11593.377 11660.459 11725.249
## [246] 11787.440 11846.785 11903.285 11957.003 12008.003 12056.397 12102.499
## [253] 12146.670 12189.274 12230.666 12271.204 12311.242 12351.127 12391.202
## [260] 12431.781 12473.049 12515.158 12558.261 12602.477 12647.784 12694.127
## [267] 12741.449 12789.685 12838.768 12888.649 12939.347 12990.902 13043.351
## [274] 13096.732 13151.082 13206.440 13262.844 13320.331 13378.939 13438.706
## [281] 13499.670 13561.868 13625.340 13690.122 13756.252 13823.769 13892.710
## [288] 13963.113 14035.016 14108.337 14182.514 14256.865 14330.705 14403.336
## [295] 14474.054 14542.239 14607.597 14669.916 14728.986 14784.657 14837.024
## [302] 14886.248 14932.540 14976.319 15018.058 15058.225 15097.279 15135.675
## [309] 15173.866 15212.268 15251.138 15290.693 15331.103 15372.345 15414.350
## [316] 15457.039 15500.299 15544.007 15588.068 15632.487 15677.292 15722.515
## [323] 15768.185 15814.333 15860.989 15908.182 15955.943 16004.302 16053.289
## [330] 16102.934 16153.267 16204.319 16256.119 16308.697 16362.083 16416.309
## [337] 16471.403 16527.396 16584.225 16641.461 16698.581 16755.138 16810.979
## [344] 16866.029 16920.236 16973.657 17026.374 17078.470 17130.017 17181.055
## [351] 17231.614 17281.755 17331.660 17381.538 17431.582 17481.893 17532.555
## [358] 17583.650 17635.244 17687.337 17739.912 17792.958 17846.468 17900.442
## [365] 17954.886 18009.826 18065.299 18121.338 18177.979 18235.256 18293.203
## [372] 18351.856 18411.250 18471.418 18532.396 18594.217 18656.918 18720.532
## [379] 18785.095 18850.640 18917.204 18984.819 19053.521 19123.345 19194.326
## [386] 19266.497 19339.894 19414.551 19490.504 19567.786 19646.433 19726.463
## [393] 19807.835 19890.490 19974.316 20058.983 20144.105 20229.312 20314.300
## [400] 20398.781 20482.543 20565.688 20648.395 20730.842 20813.226 20895.812
## [407] 20978.883 21062.702 21147.456 21233.311 21320.393 21408.674 21498.086
## [414] 21588.563 21680.009 21772.227 21864.991 21958.078 22051.262 22144.319
## [421] 22237.024 22329.153 22420.481 22510.784 22599.836 22687.414 22773.292
## [428] 22857.247 22939.052 23018.485 23095.320 23169.332 23240.297 23307.841
## [435] 23370.994 23428.636 23479.779 23523.966 23560.873 23590.176 23611.641
## [442] 23625.399 23631.674 23630.886 23624.254 23613.192 23599.241 23584.430
## [449] 23570.911 23560.737 23555.562 23556.939 23566.419 23585.374 23614.432
## [456] 23654.041 23704.306 23763.967 23831.420 23905.282 23985.032 24070.367
## [463] 24160.985 24256.583 24356.858 24461.508 24570.228 24682.717 24798.672
## [470] 24917.789 25039.767 25164.301 25291.090 25419.830 25550.219 25681.953
## [477] 25814.730 25948.247 26082.201 26216.263 26349.994 26482.932 26614.627
## [484] 26744.686 26872.733 26998.521 27122.332 27244.579 27365.673 27486.027
## [491] 27606.046 27726.137 27846.589 27967.222 28087.741 28207.966 28328.182
## [498] 28448.789 28570.189 28692.854 28817.536 28945.059 29076.144 29211.096
## [505] 29350.120 29493.287 29640.149 29790.129 29942.691 30097.465 30254.126
## [512] 30412.346 30571.799 30732.157 30893.094 31054.283 31215.397 31376.110
## [519] 31536.094 31695.023 31852.570 32008.408 32162.210 32313.650 32462.400
## [526] 32608.134 32750.525 32889.247 33023.836 33153.289 33276.466 33392.249
## [533] 33499.601 33597.507 33684.986 33761.185 33825.285 33876.468 33914.101
## [540] 33938.303 33949.379 33948.034 33936.562 33917.654 33894.054 33868.703
## [547] 33844.593 33824.716 33811.731 33806.972 33811.439 33825.764 33849.099
## [554] 33880.224 33917.821 33960.173 34005.464 34051.877
dim(pred_temp)
## NULL
spline_data[1:558,4] <- pred_temp$x
spline_data[1:558,5] <- pred_temp$y
spline_data[1:558,1] <- temp_file$ID[1]
spline_data[1:558,2] <- temp_file$Genotype[1]
spline_data[1:558,3] <- temp_file$Treatment[1]
spline_data
final_spline <- spline_data
all_plants <- unique(data_curated$ID)
length(all_plants)
## [1] 83
for(i in 2:83){
  temp <- subset(data_curated, data_curated$ID == all_plants[i])
    if(dim(temp)[1]>10){
      plot.spl <- with(temp, smooth.spline(MinOfExp, area, df = 30))
      pred_temp <- predict(plot.spl, MinOfExp)
      spline_data[1:558,4] <- pred_temp$x
      spline_data[1:558,5] <- pred_temp$y
      spline_data[1:558,1] <- temp$ID[1]
      spline_data[1:558,2] <- temp$Genotype[1]
      spline_data[1:558,3] <- temp$Treatment[1]
      final_spline <- rbind(final_spline, spline_data)
    }else{
      spline_data[1:558,4] <- MinOfExp
      spline_data[1:558,5] <- 0
      spline_data[1:558,1] <- temp$ID[1]
      spline_data[1:558,2] <- temp$Genotype[1]
      spline_data[1:558,3] <- temp$Treatment[1]
  }
}
## Warning in smooth.spline(MinOfExp, area, df = 30): not using invalid df; must
## have 1 < df <= n := #{unique x} = 19
final_spline
final_spline$Area <- as.numeric(as.character(final_spline$Area))
final_spline$MinOfExp <- as.numeric(as.character(final_spline$MinOfExp))
final_spline2 <- subset(final_spline, final_spline$Area > 0)

all.lgraph <- ggplot(data=final_spline2, aes(x= MinOfExp, y=Area, group = plant.id, color = Treatment)) 
all.lgraph <- all.lgraph + geom_line(alpha = 0.1) + facet_wrap(~ Genotype)
all.lgraph <- all.lgraph + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group= Treatment), alpha=0.3)
all.lgraph <- all.lgraph + stat_summary(fun=mean, aes(group= Treatment),  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.
all.lgraph <- all.lgraph + ylab("Projected Rosette Area") + xlab("time after transfer (min)")# + scale_color_aaas() + theme_bw()
all.lgraph <- all.lgraph + guides(color=guide_legend(title="Treatment")) + theme(legend.position = c(0.1, 0.85))
all.lgraph

all.lgraph2 <- ggplot(data=final_spline2, aes(x= MinOfExp, y=Area, group = plant.id, color = Genotype)) 
all.lgraph2 <- all.lgraph2 + geom_line(alpha = 0.1) + facet_wrap(~ Treatment)
all.lgraph2 <- all.lgraph2 + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group= Genotype), alpha=0.3)
all.lgraph2 <- all.lgraph2 + stat_summary(fun=mean, aes(group= Genotype),  size=0.7, geom="line", linetype = "dashed")
all.lgraph2 <- all.lgraph2 + ylab("Projected Rosette Area") + xlab("time after transfer (min)")# + scale_color_aaas() + theme_bw()
all.lgraph2 <- all.lgraph2 + guides(color=guide_legend(title="Genotype")) + theme(legend.position = c(0.1, 0.85))
all.lgraph2

Col <- subset(final_spline2, final_spline2$Genotype == "Col-0")
noCol <- subset(final_spline2, final_spline2$Genotype != "Col-0")

Col
noCol$facet <- noCol$Genotype
Col_duf <- Col
Col_duf$facet <- "duf"
unique(noCol$Genotype)
## [1] "duf"    "2xko-E" "2xko-D" "wrky"
Col_wkr <- Col
Col_wkr$facet <- "wrky"
Col_2E <- Col
Col_2E$facet <- "2xko-E"
Col_2D <- Col
Col_2D$facet <- "2xko-D"

final_spline3 <- rbind(noCol, Col_duf, Col_wkr, Col_2D, Col_2E)
final_spline3
all.lgraph3 <- ggplot(data=final_spline3, aes(x= MinOfExp, y=Area, group = plant.id, color = Genotype)) 
all.lgraph3 <- all.lgraph3 + geom_line(alpha = 0.1) + facet_wrap(Treatment ~ facet, nrow = 2)
all.lgraph3 <- all.lgraph3 + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group= Genotype), alpha=0.3)
all.lgraph3 <- all.lgraph3 + stat_summary(fun=mean, aes(group= Genotype),  size=0.7, geom="line", linetype = "dashed")
all.lgraph3 <- all.lgraph3 + ylab("Projected Rosette Area") + xlab("time after transfer (min)")# + scale_color_aaas() + theme_bw()
all.lgraph3 <- all.lgraph3 + guides(color=guide_legend(title="Genotype"))# + theme(legend.position = c(0.1, 0.85))
all.lgraph3

pdf("Maryam_DUF_pairwise_SOIL.pdf", width = 20, height = 15)
plot(all.lgraph3)
dev.off()
## png 
##   2
60*24
## [1] 1440
day1 <- subset(final_spline2, final_spline2$MinOfExp < 60*24)
day1
growth_rate <- final_spline2[,c(1:3)]
GR <- unique(growth_rate)
GR$GR <- 0
GR$R2 <- 0
GR$doe <- 0
GR
i=1
temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
temp <- subset(temp, temp$MinOfExp < 24 * 60)
temp
model <- lm(temp$Area ~ temp$MinOfExp)
GR[i,4] <- model$coefficients[2]
GR[i,5] <- unlist(summary(model)$r.squared)
GR[i,6] <- 1
plot(Area ~ MinOfExp, data = temp)

GR
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp < 24 * 60)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}
## Warning in summary.lm(model): essentially perfect fit: summary may be
## unreliable
GR1 <- GR
GR1

calculating “Growth rate” for each individual day to see where we observe the most promising changes among genotypes. I have 12 days of imaging, starting from 10.3.23 as my day 1, to the 10.14.23 as the day 12 of the experiment. The stress started at 10.6.23.

#Growth rate for Day 1=10.3.23
GR1$Genotype <- gsub("-",".", GR1$Genotype)

GR1C <- subset(GR1, GR1$Treatment == "Control")
GR1S <- subset(GR1, GR1$Treatment == "Salt")
unique(GR1C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR1$Genotype<- factor(GR1$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))



Output <- TukeyHSD(aov(GR ~ Genotype, data = GR1C))
P7 = Output$Genotype[,'p adj']
library(multcompView)
## Warning: package 'multcompView' was built under R version 4.3.2
library(ggsci)
library(ggbeeswarm)
## Warning: package 'ggbeeswarm' was built under R version 4.3.2
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR1S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot1 <- ggplot(data = GR1, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot1 <- GR_Plot1 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot1 <- GR_Plot1 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot1 <- GR_Plot1 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
## Warning: The `fun.y` argument of `stat_summary()` is deprecated as of ggplot2 3.3.0.
## ℹ Please use the `fun` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
GR_Plot1 <- GR_Plot1 + theme(legend.position = "none")
GR_Plot1 <- GR_Plot1 + xlab("") + ylab("Growth Rate (pixels/day), Day 1, Before stress")
GR_Plot1 <- GR_Plot1 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot1 <- GR_Plot1 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot1 <- GR_Plot1 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot1

calculating for day 2

#growth rate for day 2=10.4.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 2)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}

GR2 <- GR
GR2
GR2$Genotype <- gsub("-",".", GR2$Genotype)

GR2C <- subset(GR2, GR2$Treatment == "Control")
GR2S <- subset(GR2, GR2$Treatment == "Salt")
unique(GR2C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR2$Genotype<- factor(GR2$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))


Output <- TukeyHSD(aov(GR ~ Genotype, data = GR2C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR2S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot2 <- ggplot(data = GR2, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot2 <- GR_Plot2 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot2 <- GR_Plot2 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot2 <- GR_Plot2 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot2 <- GR_Plot2 + theme(legend.position = "none")
GR_Plot2 <- GR_Plot2 + xlab("") + ylab("Growth Rate (pixels/day), Day 2, Before stress")
GR_Plot2 <- GR_Plot2 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot2 <- GR_Plot2 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot2 <- GR_Plot2 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot2

for day 3

#growth rate for day 3=10.5.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60 *2)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 3)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}
## Warning in summary.lm(model): essentially perfect fit: summary may be
## unreliable
GR3 <- GR
GR3
GR3$Genotype <- gsub("-",".", GR3$Genotype)

GR3C <- subset(GR3, GR3$Treatment == "Control")
GR3S <- subset(GR3, GR3$Treatment == "Salt")
unique(GR3C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR3$Genotype<- factor(GR3$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))



Output <- TukeyHSD(aov(GR ~ Genotype, data = GR3C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR3S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot3 <- ggplot(data = GR3, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot3 <- GR_Plot3 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot3 <- GR_Plot3 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot3 <- GR_Plot3 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot3 <- GR_Plot3 + theme(legend.position = "none")
GR_Plot3 <- GR_Plot3 + xlab("") + ylab("Growth Rate (pixels/day), Day 3, Before stress")
GR_Plot3 <- GR_Plot3 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot3 <- GR_Plot3 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot3 <- GR_Plot3 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot3

for day 4

#growth rate for day 4=10.6.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60 *3)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 4)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}

GR4 <- GR
GR4
GR4$Genotype <- gsub("-",".", GR4$Genotype)

GR4C <- subset(GR4, GR4$Treatment == "Control")
GR4S <- subset(GR4, GR4$Treatment == "Salt")
unique(GR4C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR4$Genotype<- factor(GR4$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))



Output <- TukeyHSD(aov(GR ~ Genotype, data = GR4C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR4S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot4 <- ggplot(data = GR4, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot4 <- GR_Plot4 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot4 <- GR_Plot4 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot4 <- GR_Plot4 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot4 <- GR_Plot4 + theme(legend.position = "none")
GR_Plot4 <- GR_Plot4 + xlab("") + ylab("Growth Rate (pixels/day), 1st day of stress")
GR_Plot4 <- GR_Plot4 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot4 <- GR_Plot4 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot4 <- GR_Plot4 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot4

for day 5

#growth rate for day 5=10.7.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60 *4)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 5)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}

GR5 <- GR
GR5
GR5$Genotype <- gsub("-",".", GR5$Genotype)

GR5C <- subset(GR5, GR5$Treatment == "Control")
GR5S <- subset(GR5, GR5$Treatment == "Salt")
unique(GR5C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR5$Genotype<- factor(GR5$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))




Output <- TukeyHSD(aov(GR ~ Genotype, data = GR5C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR5S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot5 <- ggplot(data = GR5, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot5 <- GR_Plot5 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot5 <- GR_Plot5 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot5 <- GR_Plot5 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot5 <- GR_Plot5 + theme(legend.position = "none")
GR_Plot5 <- GR_Plot5 + xlab("") + ylab("Growth Rate (pixels/day),2nd day of stress")
GR_Plot5 <- GR_Plot5 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot5 <- GR_Plot5 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot5 <- GR_Plot5 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot5

for day 6

#growth rate for day6=10.8.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60 *5)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 6)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}

GR6 <- GR
GR6
GR6$Genotype <- gsub("-",".", GR6$Genotype)

GR6C <- subset(GR6, GR6$Treatment == "Control")
GR6S <- subset(GR6, GR6$Treatment == "Salt")
unique(GR6C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR6$Genotype<- factor(GR6$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))


Output <- TukeyHSD(aov(GR ~ Genotype, data = GR6C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR6S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot6 <- ggplot(data = GR6, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot6 <- GR_Plot6 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot6 <- GR_Plot6 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot6 <- GR_Plot6 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot6 <- GR_Plot6 + theme(legend.position = "none")
GR_Plot6 <- GR_Plot6 + xlab("") + ylab("Growth Rate (pixels/day), 3rd day of stress")
GR_Plot6 <- GR_Plot6 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot6 <- GR_Plot6 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot6 <- GR_Plot6 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot6

for day 7

#growth rate for day 7=10.9.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60 *6)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 7)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}

GR7 <- GR
GR7
GR7$Genotype <- gsub("-",".", GR7$Genotype)

GR7C <- subset(GR7, GR7$Treatment == "Control")
GR7S <- subset(GR7, GR7$Treatment == "Salt")
unique(GR7C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR7$Genotype<- factor(GR7$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))



Output <- TukeyHSD(aov(GR ~ Genotype, data = GR7C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR7S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot7 <- ggplot(data = GR7, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot7 <- GR_Plot7 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot7 <- GR_Plot7 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot7 <- GR_Plot7 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot7 <- GR_Plot7 + theme(legend.position = "none")
GR_Plot7 <- GR_Plot7 + xlab("") + ylab("Growth Rate (pixels/day), 4th day of stress")
GR_Plot7 <- GR_Plot7 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot7 <- GR_Plot7 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot7 <- GR_Plot7 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot7

for day 8

#growth rate for day 8=10.10.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60 *7)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 8)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}
## Warning in summary.lm(model): essentially perfect fit: summary may be
## unreliable

## Warning in summary.lm(model): essentially perfect fit: summary may be
## unreliable

## Warning in summary.lm(model): essentially perfect fit: summary may be
## unreliable
GR8 <- GR
GR8
GR8$Genotype <- gsub("-",".", GR8$Genotype)

GR8C <- subset(GR8, GR8$Treatment == "Control")
GR8S <- subset(GR8, GR8$Treatment == "Salt")
unique(GR8C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR8$Genotype<- factor(GR8$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))


Output <- TukeyHSD(aov(GR ~ Genotype, data = GR8C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR8S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot8 <- ggplot(data = GR8, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot8 <- GR_Plot8 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot8 <- GR_Plot8 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot8 <- GR_Plot8 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot8 <- GR_Plot8 + theme(legend.position = "none")
GR_Plot8 <- GR_Plot8 + xlab("") + ylab("Growth Rate (pixels/day), 5th day of stress")
GR_Plot8 <- GR_Plot8 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot8 <- GR_Plot8 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot8 <- GR_Plot8 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot8

for day 9

#growth rate for day 9=10.11.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60 *8)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 9)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}

GR9 <- GR
GR9
GR9$Genotype <- gsub("-",".", GR9$Genotype)
GR9C <- subset(GR9, GR9$Treatment == "Control")
GR9S <- subset(GR9, GR9$Treatment == "Salt")
unique(GR9C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR9$Genotype<- factor(GR9$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))


Output <- TukeyHSD(aov(GR ~ Genotype, data = GR9C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR9S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot9 <- ggplot(data = GR9, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot9 <- GR_Plot9 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot9 <- GR_Plot9 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot9 <- GR_Plot9 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot9 <- GR_Plot9 + theme(legend.position = "none")
GR_Plot9 <- GR_Plot9 + xlab("") + ylab("Growth Rate (pixels/day), 6th day of stress")
GR_Plot9 <- GR_Plot9 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot9 <- GR_Plot9 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot9 <- GR_Plot9 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot9

for day 10

#growth rate for day 10=10.12.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60 *9)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 10)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}

GR10 <- GR
GR10
GR10$Genotype <- gsub("-",".", GR10$Genotype)
GR10C <- subset(GR10, GR10$Treatment == "Control")
GR10S <- subset(GR10, GR10$Treatment == "Salt")
unique(GR10C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR10$Genotype<- factor(GR10$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))


Output <- TukeyHSD(aov(GR ~ Genotype, data = GR10C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR10S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot10 <- ggplot(data = GR10, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot10 <- GR_Plot10 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot10 <- GR_Plot10 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot10 <- GR_Plot10 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot10 <- GR_Plot10 + theme(legend.position = "none")
GR_Plot10 <- GR_Plot10 + xlab("") + ylab("Growth Rate (pixels/day), 7th day of stress")
GR_Plot10 <- GR_Plot10 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot10 <- GR_Plot10 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot10 <- GR_Plot10 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot10

for day 11

#growth rate for day 11=10.13.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60 *10)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 11)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}

GR11 <- GR
GR11
GR11$Genotype <- gsub("-",".", GR11$Genotype)
GR11C <- subset(GR11, GR11$Treatment == "Control")
GR11S <- subset(GR11, GR11$Treatment == "Salt")
unique(GR11C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR11$Genotype<- factor(GR11$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))


Output <- TukeyHSD(aov(GR ~ Genotype, data = GR11C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"



Output <- TukeyHSD(aov(GR ~ Genotype, data = GR11S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)
GR_Plot11 <- ggplot(data = GR11, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot11 <- GR_Plot11 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot11 <- GR_Plot11 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot11 <- GR_Plot11 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot11 <- GR_Plot11 + theme(legend.position = "none")
GR_Plot11 <- GR_Plot11 + xlab("") + ylab("Growth Rate (pixels/day), 8th day of stress")
GR_Plot11 <- GR_Plot11 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot11 <- GR_Plot11 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot11 <- GR_Plot11 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot11

for day 12, end of my dataset

#growth rate for day 12=10.14.23
for(i in 2:nrow(GR)){
  temp <- subset(final_spline2, final_spline2$plant.id == GR[i,1])
  temp <- subset(temp, temp$MinOfExp > 24 * 60 *11)
  temp <- subset(temp, temp$MinOfExp < 24 * 60 * 12)
  if(dim(temp)[1]>10){
  model <- lm(temp$Area ~ temp$MinOfExp)
  GR[i,4] <- model$coefficients[2]
  GR[i,5] <- unlist(summary(model)$r.squared)}
  else{
  GR[i,4] <- 0
  GR[i,5] <- 0
  }
  GR[i,6] <- 1
}


GR12 <- GR
GR12
GR12$Genotype <- gsub("-",".", GR12$Genotype)
GR12C <- subset(GR12, GR12$Treatment == "Control")
GR12S <- subset(GR12, GR12$Treatment == "Salt")
unique(GR12C$Genotype)
## [1] "2xko.E" "wrky"   "duf"    "2xko.D" "Col.0"
GR12$Genotype<- factor(GR12$Genotype, levels=c("Col.0","duf", "wrky", "2xko.D", "2xko.E"))

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR12C))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testC <- as.data.frame(stat.test$Letters)
testC$group1 <- rownames(testC)
testC$group2 <- rownames(testC)
testC$Treatment <- "Control"
colnames(testC)[1] <- "Tukey"

Output <- TukeyHSD(aov(GR ~ Genotype, data = GR12S))
P7 = Output$Genotype[,'p adj']
stat.test<- multcompLetters(P7)
testD <- as.data.frame(stat.test$Letters)
testD$group1 <- rownames(testD)
testD$group2 <- rownames(testD)
testD$Treatment <- "Salt"
colnames(testD)[1] <- "Tukey"

test <- rbind(testC, testD)


GR_Plot12 <- ggplot(data = GR12, mapping = aes(x = Genotype, y = GR, colour = Genotype)) 
GR_Plot12 <- GR_Plot12 + geom_beeswarm(alpha=0.6, priority = "density")
GR_Plot12 <- GR_Plot12 + facet_wrap(~ Treatment) + theme_classic()
GR_Plot12 <- GR_Plot12 + stat_summary(fun.y=mean, geom="point", shape=95, size=6, color="black", fill="black")
GR_Plot12 <- GR_Plot12 + theme(legend.position = "none")
GR_Plot12 <- GR_Plot12 + xlab("") + ylab("Growth Rate (pixels/day), 9th day of stress")
GR_Plot12 <- GR_Plot12 + theme(axis.text.x = element_text(angle=90, vjust=0.5))
GR_Plot12 <- GR_Plot12 + stat_compare_means(method = "aov", label.y = 3)
GR_Plot12 <- GR_Plot12 + stat_pvalue_manual(test, label = "Tukey", y.position = 2.5)+ scale_color_jco()
GR_Plot12

I have decided for final graph, to choose growth rate at the end of my experiment which nicely shows how two double mutants have increased shoot growth under salt compared to each single and col plants.

library(cowplot)
## 
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggpubr':
## 
##     get_legend
pdf("shoot-size-5geno-soil-experiment.pdf", height = 5, width = 12)
plot_grid(all.lgraph2,GR_Plot12, ncol=2,
          align = "hv", labels=c("AUTO"), 
          label_size = 24)
dev.off()
## png 
##   2