This is a RSA analysis for 3 tomatoes experienced cytokinin and salt treatments on plate. The seeds were germinated on 1/4 ms plate for 4 complete days, and then transferred to treatment plates at d5, and being scanned for 5 consecutive days. The root tracing was done by undergraduate student Trent Donalson in Dec.2022-January2023.

getwd()
## [1] "C:/Users/Julkowska Lab/Desktop/R codes by Maryam/20230131_RSA_M248M058LA1511_cyto_100mM_Salt_Trent"
setwd("C:/Users/Julkowska Lab/Desktop/R codes by Maryam/20230131_RSA_M248M058LA1511_cyto_100mM_Salt_Trent/")
list.files(pattern = ".csv")
## [1] "2023Feb_3acc_CYTO_growth_factors.csv"
## [2] "d5-cyto.csv"                         
## [3] "d9-cyto.csv"                         
## [4] "d9-updated.csv"
my_data_d5<- read.csv("d5-cyto.csv")
my_data_d9<- read.csv("d9-updated.csv")
head(my_data_d5)
library(readr)
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(tidyr)
my_data_d5<-my_data_d5%>%mutate(day=5,my_data_d5 )
head(my_data_d5)
my_data_d9<-my_data_d9%>%mutate(day=9,my_data_d9 )
head(my_data_d9)
all_data<-rbind(my_data_d5,my_data_d9)
all_data
unique(all_data$day)
## [1] 5 9
Main_root <- subset(all_data, all_data$root_order == 0)
Main_root
colnames(Main_root)
##  [1] "image"                 "root_name"             "root"                 
##  [4] "length"                "vector_length"         "surface"              
##  [7] "volume"                "direction"             "diameter"             
## [10] "root_order"            "root_ontology"         "parent_name"          
## [13] "parent"                "insertion_position"    "insertion_angle"      
## [16] "n_child"               "child_density"         "first_child"          
## [19] "insertion_first_child" "last_child"            "insertion_last_child" 
## [22] "day"
MR_data<-Main_root[, c(1:4, 10, 14:17, 19:22)]
MR_data
Lateral_root <- subset(all_data, all_data$root_order != 0)
Lateral_root
unique(Lateral_root$root_order)
## [1] 1
colnames(Lateral_root)
##  [1] "image"                 "root_name"             "root"                 
##  [4] "length"                "vector_length"         "surface"              
##  [7] "volume"                "direction"             "diameter"             
## [10] "root_order"            "root_ontology"         "parent_name"          
## [13] "parent"                "insertion_position"    "insertion_angle"      
## [16] "n_child"               "child_density"         "first_child"          
## [19] "insertion_first_child" "last_child"            "insertion_last_child" 
## [22] "day"
MR_data2 <- subset(MR_data, MR_data$n_child >0)
MR_data2
temporary <- subset(Lateral_root, Lateral_root$parent == MR_data2$root[1])
temporary
temporary <- subset(temporary, temporary$day == MR_data2$day[3])
temporary
dim(temporary)
## [1]  3 22
total_LRL <- sum(temporary$length)
angle_LR.avg <- mean(temporary$insertion_angle)
angle_LR.sd <- sd(temporary$insertion_angle)
LR_number <- dim(temporary)[1]
total_LRL
## [1] 0.9414866
angle_LR.avg
## [1] 98.4573
angle_LR.sd
## [1] 45.83293
LR_number
## [1] 3
MR_data2$LRL <- 0
MR_data2$LRno <- 0
MR_data2$LRangle.avg <- 0
MR_data2$LRangle.sd <- 0
MR_data2
MR_data2$LRL[1] <- total_LRL
MR_data2$LRno[1] <- LR_number
MR_data2$LRangle.avg[1] <- angle_LR.avg
MR_data2$LRangle.sd[1] <- angle_LR.sd
MR_data2
MR_data_noChild <- subset(MR_data, MR_data$n_child == 0)
MR_data_noChild
length(MR_data2$root)
## [1] 164
for(i in 2:164){
  temporary <- subset(Lateral_root, Lateral_root$parent == MR_data2$root[i])
  temporary <- subset(temporary, temporary$day == MR_data2$day[i])
  total_LRL <- sum(temporary$length)
  angle_LR.avg <- mean(temporary$insertion_angle)
  angle_LR.sd <- sd(temporary$insertion_angle)
  LR_number <- dim(temporary)[1]
  MR_data2$LRL[i] <- total_LRL
  MR_data2$LRno[i] <- LR_number
  MR_data2$LRangle.avg[i] <- angle_LR.avg
  MR_data2$LRangle.sd[i] <- angle_LR.sd
    
}

MR_data2$check <- MR_data2$n_child - MR_data2$LRno
MR_data2
unique(MR_data2$check)
## [1] -2  0
MR3<- subset(MR_data2, MR_data2$check == 0)
unique(MR3$check)
## [1] 0
colnames(MR3)
##  [1] "image"                 "root_name"             "root"                 
##  [4] "length"                "root_order"            "insertion_position"   
##  [7] "insertion_angle"       "n_child"               "child_density"        
## [10] "insertion_first_child" "last_child"            "insertion_last_child" 
## [13] "day"                   "LRL"                   "LRno"                 
## [16] "LRangle.avg"           "LRangle.sd"            "check"
MR_data_Child2 <- MR3[,1:17]
MR_data_Child2
MR_data_noChild
MR_data_noChild$LRL <- 0
MR_data_noChild$LRno <- 0
MR_data_noChild$LRangle.avg <- 0
MR_data_noChild$LRangle.sd <- 0
MR_all <-rbind(MR_data_Child2, MR_data_noChild)
MR_all
dim(MR_data_Child2)
## [1] 163  17
dim(MR_data_noChild)
## [1] 195  17
dim(MR_all)
## [1] 358  17
MR_all$root_name[50]
## [1] " pl6-s-nocyto-LA1511"
text <- strsplit(x = MR_all$root_name[50], split = "-")
text
## [[1]]
## [1] " pl6"   "s"      "nocyto" "LA1511"
plate <- text[[1]][1]
plate <- gsub(" ", "", plate)
plate
## [1] "pl6"
cond <- text[[1]][2:3]
cond
## [1] "s"      "nocyto"
genotype <- text[[1]][4]
genotype
## [1] "LA1511"
dim(MR_all)
## [1] 358  17
for(i in 1:358){
  text <- strsplit(x = MR_all$root_name[i], split = "-")
  plate <- text[[1]][1]
  cond <- paste(text[[1]][2], text[[1]][3], sep="_")
  genotype <- text[[1]][4]
   
  MR_all$genotype[i] <- genotype
  MR_all$condition[i] <- cond
  MR_all$plate[i] <- plate
}

MR_all
MR_all$TRS <- MR_all$length + MR_all$LRL

for(i in 1:nrow(MR_all)){
  if(MR_all$LRno[i] == 0){
    MR_all$aLRL[i] <- 0
  } else {
  MR_all$aLRL[i] <- MR_all$LRL[i]/ MR_all$LRno[i]  
  }
}


MR_all$MRpLRL <- MR_all$length / MR_all$LRL
MR_all
length(unique(MR_all$root_name))
## [1] 177
unique(MR_all$day)
## [1] 9 5
MR_all$day <- as.numeric(as.character(MR_all$day))
unique(MR_all$day)
## [1] 9 5
358/177
## [1] 2.022599
unique(MR_all$root_name)
##   [1] " pl1-s-hicyto-LA1511"  " pl2-s-hicyto-LA1511"  " pl3-s-hicyto-LA1511" 
##   [4] " pl4-s-hicyto-LA1511"  " pl6-s-hicyto-LA1511"  " pl7-s-hicyto-LA1511" 
##   [7] " pl8-s-hicyto-LA1511"  " pl9-s-hicyto-LA1511"  " pl10-s-hicyto-LA1511"
##  [10] " pl1-c-hicyto-LA1511"  " pl2-c-hicyto-LA1511"  " pl3-c-hicyto-LA1511" 
##  [13] " pl4-c-hicyto-LA1511"  " pl5-c-hicyto-LA1511"  " pl6-c-hicyto-LA1511" 
##  [16] " pl7-c-hicyto-LA1511"  " pl8-c-hicyto-LA1511"  " pl9-c-hicyto-LA1511" 
##  [19] " pl10-c-hicyto-LA1511" " pl1-c-locyto-LA1511"  " pl2-c-locyto-LA1511" 
##  [22] " pl3-c-locyto-LA1511"  " pl4-c-locyto-LA1511"  " pl5-c-locyto-LA1511" 
##  [25] " pl6-c-locyto-LA1511"  " pl7-c-locyto-LA1511"  " pl8-c-locyto-LA1511" 
##  [28] " pl9-c-locyto-LA1511"  " pl10-c-locyto-LA1511" " pl1-s-locyto-LA1511" 
##  [31] " pl2-s-locyto-LA1511"  " pl3-s-locyto-LA1511"  " pl5-s-locyto-LA1511" 
##  [34] " pl6-s-locyto-LA1511"  " pl7-s-locyto-LA1511"  " pl8-s-locyto-LA1511" 
##  [37] " pl9-s-locyto-LA1511"  " pl10-s-locyto-LA1511" " pl1-c-nocyto-LA1511" 
##  [40] " pl2-c-nocyto-LA1511"  " pl3-c-nocyto-LA1511"  " pl4-c-nocyto-LA1511" 
##  [43] " pl5-c-nocyto-LA1511"  " pl7-c-nocyto-LA1511"  " pl1-s-nocyto-LA1511" 
##  [46] " pl2-s-nocyto-LA1511"  " p1#3-s-nocyto-LA1511" " pl4-s-nocyto-LA1511" 
##  [49] " pl5-s-nocyto-LA1511"  " pl6-s-nocyto-LA1511"  " pl7-s-nocyto-LA1511" 
##  [52] " pl8-s-nocyto-LA1511"  " pl9-s-nocyto-LA1511"  " pl10-s-nocyto-LA1511"
##  [55] " pl1-s-hicyto-M248"    " pl2-s-hicyto-M248"    " pl4-s-hicyto-M248"   
##  [58] " pl5-s-hicyto-M248"    " pl6-s-hicyto-M248"    " pl7-s-hicyto-M248"   
##  [61] " pl8-s-hicyto-M248"    " pl9-s-hicyto-M248"    " pl1-c-hicyto-M248"   
##  [64] " pl2-c-hicyto-M248"    " pl3-c-hicyto-M248"    " pl4-c-hicyto-M248"   
##  [67] " pl5-c-hicyto-M248"    " pl6-c-hicyto-M248"    " pl7-c-hicyto-M248"   
##  [70] " pl8-c-hicyto-M248"    " pl9-c-hicyto-M248"    " pl10-c-hicyto-M248"  
##  [73] " pl10-c-locyto-M248"   " pl19-c-locyto-M248"   " pl8-c-locyto-M248"   
##  [76] " pl7-c-locyto-M248"    " pl6-c-locyto-M248"    " pl5-c-locyto-M248"   
##  [79] " pl4-c-locyto-M248"    " pl3-c-locyto-M248"    " pl2-c-locyto-M248"   
##  [82] " pl1-c-locyto-M248"    " pl1-s-locyto-M248"    " pl2-s-locyto-M248"   
##  [85] " pl3-s-locyto-M248"    " pl4-s-locyto-M248"    " pl5-s-locyto-M248"   
##  [88] " pl6-s-locyto-M248"    " pl7-s-locyto-M248"    " pl8-s-locyto-M248"   
##  [91] " pl9-s-locyto-M248"    " pl10-c-nocyto-M248"   " pl9-c-nocyto-M248"   
##  [94] " pl8-c-nocyto-M248"    " pl7-c-nocyto-M248"    " pl6-c-nocyto-M248"   
##  [97] " pl5-c-nocyto-M248"    " pl4-c-nocyto-M248"    " pl3-c-nocyto-M248"   
## [100] " pl2-c-nocyto-M248"    " pl1-c-nocyto-M248"    " pl10-s-nocyto-M248"  
## [103] " pl9-s-nocyto-M248"    " pl8-s-nocyto-M248"    " pl7-s-nocyto-M248"   
## [106] " pl6-s-nocyto-M248"    " pl5-s-nocyto-M248"    " pl4-s-nocyto-M248"   
## [109] " pl3-s-nocyto-M248"    " pl2-s-nocyto-M248"    " pl1-s-nocyto-M248"   
## [112] " pl10-c-locyto-M058"   " pl9-c-locyto-M058"    " pl8-c-locyto-M058"   
## [115] " pl7-c-locyto-M058"    " pl6-c-locyto-M058"    " pl5-c-locyto-M058"   
## [118] " pl4-c-locyto-M058"    " pl3-c-locyto-M058"    " pl2-c-locyto-M058"   
## [121] " pl1-c-locyto-M058"    " pl10-s-locyto-M058"   " pl9-s-locyto-M058"   
## [124] " pl8-s-locyto-M058"    " pl7-s-locyto-M058"    " pl6-s-locyto-M058"   
## [127] " pl5-s-locyto-M058"    " pl4-s-locyto-M058"    " pl3-s-locyto-M058"   
## [130] " pl2-s-locyto-M058"    " pl1-s-locyto-M058"    " pl10-s-hicyto-M058"  
## [133] " pl9-s-hicyto-M058"    " pl8-s-hicyto-M058"    " pl6-s-hicyto-M058"   
## [136] " pl5-s-hicyto-M058"    " pl4-s-hicyto-M058"    " pl3-s-hicyto-M058"   
## [139] " pl1-s-hicyto-M058"    " pl10-c-hicyto-M058"   " pl8-c-hicyto-M058"   
## [142] " pl7-c-hicyto-M058"    " pl6-c-hicyto-M058"    " pl5-c-hicyto-M058"   
## [145] " pl4-c-hicyto-M058"    " pl3-c-hicyto-M058"    " pl1-c-hicyto-M058"   
## [148] " pl10-c-nocyto-M058"   " pl9-c-nocyto-M058"    " pl8-c-nocyto-M058"   
## [151] " pl7-c-nocyto-M058"    " pl6-c-nocyto-M058"    " pl5-c-nocyto-M058"   
## [154] " pl4-c-nocyto-M058"    " pl3-c-nocyto-M058"    " pl2-c-nocyto-M058"   
## [157] " pl1-c-nocyto-M058"    " pl10-s-nocyto-M058"   " pl9-s-nocyto-M058"   
## [160] " pl6-s-nocyto-M058"    " pl4-s-nocyto-M058"    " pl1-s-nocyto-M058"   
## [163] " pl5-s-hicyto-LA1511"  " pl4-s-locyto-LA1511"  " pl6-c-nocyto-LA1511" 
## [166] " root_0"               " pl3-s-nocyto-LA1511"  " pl10-s-hicyto-M248"  
## [169] " pl7-s-hicyto-M058"    " pl2-s-hicyto-M058"    " pl9-c-hicyto-M058"   
## [172] " pl2-c-hicyto-M058"    " pl8-s-nocyto-M058"    " pl7-s-nocyto-M058"   
## [175] " pl5-s-nocyto-M058"    " pl3-s-nocyto-M058"    " pl2-s-nocyto-M058"
unique(MR_all$genotype)
## [1] "LA1511" "M248"   "M058"   NA

##it seems that I have one main root that does not have name, and I have NA in genotype as well…….

good_stuff <- c("M248", "M058", "LA1511")
funk <- subset(MR_all, !(MR_all$genotype %in% good_stuff))
funk
unique(MR_all$genotype)
## [1] "LA1511" "M248"   "M058"   NA
MR_all <- subset(MR_all, (MR_all$genotype %in% good_stuff))
MR_d9 <- subset(MR_all, MR_all$day == 5)
MR_d5 <- subset(MR_all, MR_all$day == 9)

suspish <- subset(MR_d9, !(MR_d9$root_name %in% MR_d5$root_name))
suspish
MR_clean <- subset(MR_all, (MR_all$root_name %in% MR_d5$root_name))

MR_d9 <- subset(MR_clean, MR_clean$day == 5)
MR_d5 <- subset(MR_clean, MR_clean$day == 9)

suspish <- subset(MR_d9, !(MR_d9$root_name %in% MR_d5$root_name))
suspish
suspish <- subset(MR_d9, !(MR_d5$root_name %in% MR_d9$root_name))
suspish
unique(MR_all$cond)
## [1] "s_hicyto" "c_hicyto" "c_locyto" "s_locyto" "c_nocyto" "s_nocyto"
library(ggplot2)
library(ggpubr)
MR_all$condition<- factor(MR_all$condition, levels=c("c_nocyto", "c_locyto", "c_hicyto",  "s_nocyto", "s_locyto", "s_hicyto"))


histogram_TRS_cyto <- ggdensity(MR_all, x = "TRS",
                           add = "mean", rug = TRUE, facet.by = "day",
                           color = "condition", fill = "condition")
                           

histogram_TRS_cyto

histogram_LRno_cyto <- ggdensity(MR_all, x = "LRno",
                           add = "mean", rug = TRUE, facet.by = "day",
                           color = "condition", fill = "condition")
                           

histogram_LRno_cyto

pdf("histogram.TRS.cytokinin.pdf")
plot(histogram_TRS_cyto)
# if plotting multiple graphs - this command is extremely important 
dev.off()
## png 
##   2
pdf("histogram.LRno.cyto.pdf")
plot(histogram_LRno_cyto)
# if plotting multiple graphs - this command is extremely important 
dev.off()
## png 
##   2
library(cowplot)
## 
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggpubr':
## 
##     get_legend
pdf("Figure_Histogram.pdf", height = 15, width = 12)
plot_grid(histogram_TRS_cyto, histogram_LRno_cyto, ncol=2,
          align = "hv", labels=c("AUTO"), 
          label_size = 24)
dev.off()
## png 
##   2
unique(MR_all$genotype)
## [1] "LA1511" "M248"   "M058"
TRS_lgraph <- ggplot(data=MR_all, aes(x= genotype, y=TRS, color = condition)) 
TRS_lgraph <- TRS_lgraph + geom_boxplot()
TRS_lgraph <- TRS_lgraph + facet_grid(day ~ condition, scales = "free") + scale_color_manual(values=c("blue","turquoise3", "cyan","red", "maroon3", "dark orange"))
TRS_lgraph <- TRS_lgraph + ylab("Total root size (cm)") + xlab("Genotype") + theme(legend.position='none')
TRS_lgraph

unique(MR_all$day)
## [1] 9 5
TRS_data <- subset(MR_all, MR_all$day == 9)
TRS_data
TRS_graph_d9 <- ggerrorplot(TRS_data, y = "TRS", x = "condition", fill="condition", color="condition", 
                        desc_stat = "mean_sd", add = "jitter", facet.by = "genotype", palette = "jco",
                        add.params = list(color = "darkgray"),
                        xlab="", ylab="Total Root Size (cm)") 
TRS_graph_d9 <- TRS_graph_d9 + rremove("legend") + stat_compare_means(method="t.test", ref.group = "c_nocyto", 
                                                              label = "p.signif", hide.ns = T)
TRS_graph_d9 <- TRS_graph_d9 + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
TRS_graph_d9

library(ggsci)
library(ggbeeswarm)
library(gapminder)
library(RColorBrewer)
library(ggridges)
better_TRS_graph <- ggplot(data=MR_all, aes(x= genotype, y=TRS, color = genotype))
better_TRS_graph <- better_TRS_graph + geom_beeswarm(alpha=0.6, priority = "density")
better_TRS_graph <- better_TRS_graph + 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.
better_TRS_graph <- better_TRS_graph + facet_grid(day ~ condition, scales = "free") + scale_color_manual(values=c("turquoise3", "maroon3", "dark orange"))
better_TRS_graph <- better_TRS_graph + ylab("Total root size (cm)") + xlab("Genotype") + theme(legend.position='none')
better_TRS_graph <- better_TRS_graph + theme(axis.text.x = element_text(angle=90, hjust=0.9, vjust=0.5))
better_TRS_graph <- better_TRS_graph + stat_compare_means(label = "p.signif", method = "t.test", ref.group = "LA1511", hide.ns = TRUE) 
better_TRS_graph

library(ggplot2)
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
my_graph <- ggplot(data=MR_all, aes(x= day, y=length, group = root_name, color = condition)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ genotype) 
my_graph <- my_graph + ylab("Main Root Length (cm)") + xlab("time (day)") 
my_graph

my_graph <- ggerrorplot(MR_all, y = "length", x = "condition", fill="cond", color="condition", 
                        desc_stat = "mean_sd", add = "jitter", facet.by = "genotype", palette = "jco",
                        add.params = list(color = "darkgray"),
                        xlab="", ylab="Main Root Length (cm)") 
my_graph <- my_graph + rremove("legend") + stat_compare_means(method="t.test", ref.group = "c_nocyto", 
                                                              label = "p.signif", hide.ns = T)
my_graph <- my_graph + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
my_graph

### Curating the data

MR_all$root_name <- gsub(" ", "", MR_all$root_name)
geno_1511 <- subset(MR_all, MR_all$genotype == "LA1511")
bye <- c("pl6-c-nocyto-LA1511", "pl10-s-nocyto-LA1511")
geno_1511 <- subset(geno_1511, !(geno_1511$root_name %in% bye))
unique(geno_1511$root_name)
##  [1] "pl1-s-hicyto-LA1511"  "pl2-s-hicyto-LA1511"  "pl3-s-hicyto-LA1511" 
##  [4] "pl4-s-hicyto-LA1511"  "pl6-s-hicyto-LA1511"  "pl7-s-hicyto-LA1511" 
##  [7] "pl8-s-hicyto-LA1511"  "pl9-s-hicyto-LA1511"  "pl10-s-hicyto-LA1511"
## [10] "pl1-c-hicyto-LA1511"  "pl2-c-hicyto-LA1511"  "pl3-c-hicyto-LA1511" 
## [13] "pl4-c-hicyto-LA1511"  "pl5-c-hicyto-LA1511"  "pl6-c-hicyto-LA1511" 
## [16] "pl7-c-hicyto-LA1511"  "pl8-c-hicyto-LA1511"  "pl9-c-hicyto-LA1511" 
## [19] "pl10-c-hicyto-LA1511" "pl1-c-locyto-LA1511"  "pl2-c-locyto-LA1511" 
## [22] "pl3-c-locyto-LA1511"  "pl4-c-locyto-LA1511"  "pl5-c-locyto-LA1511" 
## [25] "pl6-c-locyto-LA1511"  "pl7-c-locyto-LA1511"  "pl8-c-locyto-LA1511" 
## [28] "pl9-c-locyto-LA1511"  "pl10-c-locyto-LA1511" "pl1-s-locyto-LA1511" 
## [31] "pl2-s-locyto-LA1511"  "pl3-s-locyto-LA1511"  "pl5-s-locyto-LA1511" 
## [34] "pl6-s-locyto-LA1511"  "pl7-s-locyto-LA1511"  "pl8-s-locyto-LA1511" 
## [37] "pl9-s-locyto-LA1511"  "pl10-s-locyto-LA1511" "pl1-c-nocyto-LA1511" 
## [40] "pl2-c-nocyto-LA1511"  "pl3-c-nocyto-LA1511"  "pl4-c-nocyto-LA1511" 
## [43] "pl5-c-nocyto-LA1511"  "pl7-c-nocyto-LA1511"  "pl1-s-nocyto-LA1511" 
## [46] "pl2-s-nocyto-LA1511"  "p1#3-s-nocyto-LA1511" "pl4-s-nocyto-LA1511" 
## [49] "pl5-s-nocyto-LA1511"  "pl6-s-nocyto-LA1511"  "pl7-s-nocyto-LA1511" 
## [52] "pl8-s-nocyto-LA1511"  "pl9-s-nocyto-LA1511"  "pl5-s-hicyto-LA1511" 
## [55] "pl4-s-locyto-LA1511"  "pl3-s-nocyto-LA1511"
my_graph <- ggplot(data=geno_1511, aes(x= day, y=length, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("length") + xlab("time (day)") + ggtitle("Main Root Length (cm)") + theme(legend.position='none')
my_graph

ggplotly(my_graph)
my_graph <- ggplot(data=geno_1511, aes(x= day, y=TRS, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("length (cm)") + xlab("time (day)") + ggtitle("Total Root Length") + theme(legend.position='none')
my_graph

my_graph <- ggplot(data=geno_1511, aes(x= day, y=LRno, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("number") + xlab("time (day)") + ggtitle("Lateral Root number") + theme(legend.position='none')
my_graph

my_graph <- ggplot(data=geno_1511, aes(x= day, y=LRL, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("length (cm)") + xlab("time (day)") + ggtitle("Lateral Root Length") + theme(legend.position='none')
my_graph

geno_248 <- subset(MR_all, MR_all$genotype == "M248")
geno_248
bye <- c("pl1-c-nocyto-M248", "pl4-s-nocyto-M248", "pl4-s-hicyto-M248")
geno_248 <- subset(geno_248, !(geno_248$root_name %in% bye))
unique(geno_248$root_name)
##  [1] "pl1-s-hicyto-M248"  "pl2-s-hicyto-M248"  "pl5-s-hicyto-M248" 
##  [4] "pl6-s-hicyto-M248"  "pl7-s-hicyto-M248"  "pl8-s-hicyto-M248" 
##  [7] "pl9-s-hicyto-M248"  "pl1-c-hicyto-M248"  "pl2-c-hicyto-M248" 
## [10] "pl3-c-hicyto-M248"  "pl4-c-hicyto-M248"  "pl5-c-hicyto-M248" 
## [13] "pl6-c-hicyto-M248"  "pl7-c-hicyto-M248"  "pl8-c-hicyto-M248" 
## [16] "pl9-c-hicyto-M248"  "pl10-c-hicyto-M248" "pl10-c-locyto-M248"
## [19] "pl19-c-locyto-M248" "pl8-c-locyto-M248"  "pl7-c-locyto-M248" 
## [22] "pl6-c-locyto-M248"  "pl5-c-locyto-M248"  "pl4-c-locyto-M248" 
## [25] "pl3-c-locyto-M248"  "pl2-c-locyto-M248"  "pl1-c-locyto-M248" 
## [28] "pl1-s-locyto-M248"  "pl2-s-locyto-M248"  "pl3-s-locyto-M248" 
## [31] "pl4-s-locyto-M248"  "pl5-s-locyto-M248"  "pl6-s-locyto-M248" 
## [34] "pl7-s-locyto-M248"  "pl8-s-locyto-M248"  "pl9-s-locyto-M248" 
## [37] "pl10-c-nocyto-M248" "pl9-c-nocyto-M248"  "pl8-c-nocyto-M248" 
## [40] "pl7-c-nocyto-M248"  "pl6-c-nocyto-M248"  "pl5-c-nocyto-M248" 
## [43] "pl4-c-nocyto-M248"  "pl3-c-nocyto-M248"  "pl2-c-nocyto-M248" 
## [46] "pl10-s-nocyto-M248" "pl9-s-nocyto-M248"  "pl8-s-nocyto-M248" 
## [49] "pl7-s-nocyto-M248"  "pl6-s-nocyto-M248"  "pl5-s-nocyto-M248" 
## [52] "pl3-s-nocyto-M248"  "pl2-s-nocyto-M248"  "pl1-s-nocyto-M248" 
## [55] "pl10-s-hicyto-M248"
my_graph <- ggplot(data=geno_248, aes(x= day, y=length, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("length") + xlab("time (day)") + ggtitle("Main Root Length (cm)") + theme(legend.position='none')
my_graph

ggplotly(my_graph)
my_graph <- ggplot(data=geno_248, aes(x= day, y=TRS, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("length (cm)") + xlab("time (day)") + ggtitle("Total Root Length") + theme(legend.position='none')
my_graph

my_graph <- ggplot(data=geno_248, aes(x= day, y=LRno, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("number") + xlab("time (day)") + ggtitle("Lateral Root number") + theme(legend.position='none')
my_graph

my_graph <- ggplot(data=geno_248, aes(x= day, y=LRL, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("length (cm)") + xlab("time (day)") + ggtitle("Lateral Root Length") + theme(legend.position='none')
my_graph

geno_058 <- subset(MR_all, MR_all$genotype == "M058")

bye <- c("pl4-s-nocyto-M058", "pl2-s-hicyto-M058")
geno_058 <- subset(geno_058, !(geno_058$root_name %in% bye))
unique(geno_058$root_name)
##  [1] "pl10-c-locyto-M058" "pl9-c-locyto-M058"  "pl8-c-locyto-M058" 
##  [4] "pl7-c-locyto-M058"  "pl6-c-locyto-M058"  "pl5-c-locyto-M058" 
##  [7] "pl4-c-locyto-M058"  "pl3-c-locyto-M058"  "pl2-c-locyto-M058" 
## [10] "pl1-c-locyto-M058"  "pl10-s-locyto-M058" "pl9-s-locyto-M058" 
## [13] "pl8-s-locyto-M058"  "pl7-s-locyto-M058"  "pl6-s-locyto-M058" 
## [16] "pl5-s-locyto-M058"  "pl4-s-locyto-M058"  "pl3-s-locyto-M058" 
## [19] "pl2-s-locyto-M058"  "pl1-s-locyto-M058"  "pl10-s-hicyto-M058"
## [22] "pl9-s-hicyto-M058"  "pl8-s-hicyto-M058"  "pl6-s-hicyto-M058" 
## [25] "pl5-s-hicyto-M058"  "pl4-s-hicyto-M058"  "pl3-s-hicyto-M058" 
## [28] "pl1-s-hicyto-M058"  "pl10-c-hicyto-M058" "pl8-c-hicyto-M058" 
## [31] "pl7-c-hicyto-M058"  "pl6-c-hicyto-M058"  "pl5-c-hicyto-M058" 
## [34] "pl4-c-hicyto-M058"  "pl3-c-hicyto-M058"  "pl1-c-hicyto-M058" 
## [37] "pl10-c-nocyto-M058" "pl9-c-nocyto-M058"  "pl8-c-nocyto-M058" 
## [40] "pl7-c-nocyto-M058"  "pl6-c-nocyto-M058"  "pl5-c-nocyto-M058" 
## [43] "pl4-c-nocyto-M058"  "pl3-c-nocyto-M058"  "pl2-c-nocyto-M058" 
## [46] "pl1-c-nocyto-M058"  "pl10-s-nocyto-M058" "pl9-s-nocyto-M058" 
## [49] "pl6-s-nocyto-M058"  "pl1-s-nocyto-M058"  "pl7-s-hicyto-M058" 
## [52] "pl9-c-hicyto-M058"  "pl2-c-hicyto-M058"  "pl8-s-nocyto-M058" 
## [55] "pl7-s-nocyto-M058"  "pl5-s-nocyto-M058"  "pl3-s-nocyto-M058" 
## [58] "pl2-s-nocyto-M058"
my_graph <- ggplot(data=geno_058, aes(x= day, y=length, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("length") + xlab("time (day)") + ggtitle("Main Root Length (cm)") + theme(legend.position='none')
my_graph

ggplotly(my_graph)
my_graph <- ggplot(data=geno_058, aes(x= day, y=TRS, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("length (cm)") + xlab("time (day)") + ggtitle("Total Root Length") + theme(legend.position='none')
my_graph

my_graph <- ggplot(data=geno_058, aes(x= day, y=LRno, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("number") + xlab("time (day)") + ggtitle("Lateral Root number") + theme(legend.position='none')
my_graph

my_graph <- ggplot(data=geno_058, aes(x= day, y=LRL, group = root_name, color = genotype)) 
my_graph <- my_graph + geom_line(alpha = 0.2) 
my_graph <- my_graph + facet_grid(~ condition) 
my_graph <- my_graph + ylab("length (cm)") + xlab("time (day)") + ggtitle("Lateral Root Length") + theme(legend.position='none')
my_graph

### Increase in MRL / LRL / LRno through time - final graphs

MR_all2 <- rbind(geno_1511, geno_248)
MR_all2 <- rbind(MR_all2, geno_058)

MR_time_graph <- ggplot(data=MR_all2, aes(x= day, y=length, group = root_name, color = condition)) 
MR_time_graph <- MR_time_graph + geom_line(alpha = 0.2) 
MR_time_graph <- MR_time_graph + facet_grid(genotype~condition) 
MR_time_graph <- MR_time_graph + ylab("Main root length (cm)") + xlab("Time (days after germination)") #+ ggtitle("Main Root Length")
MR_time_graph <- MR_time_graph + stat_summary(fun=mean, aes(group= cond),  size=0.7, geom="line", linetype = "dashed")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
MR_time_graph

LRL_time_graph <- ggplot(data=MR_all2, aes(x= day, y=LRL, group = root_name, color = condition)) 
LRL_time_graph <- LRL_time_graph + geom_line(alpha = 0.2) 
LRL_time_graph <- LRL_time_graph + facet_grid( genotype~condition) 
LRL_time_graph <- LRL_time_graph + ylab("Lateral root length (cm)") + xlab("Time (days after germination)") #+ ggtitle("Lateral Root Length")
LRL_time_graph <- LRL_time_graph + stat_summary(fun.y=mean, aes(group= cond),  size=0.7, geom="line", linetype = "dashed")
LRL_time_graph

LRno_time_graph <- ggplot(data=MR_all2, aes(x= day, y=LRno, group = root_name, color = condition)) 
LRno_time_graph <- LRno_time_graph + geom_line(alpha = 0.2) 
LRno_time_graph <- LRno_time_graph + facet_grid( genotype~condition) 
LRno_time_graph <- LRno_time_graph + ylab("Lateral root number") + xlab("Time (days after germination)") #+ ggtitle("Lateral Root Number")
LRno_time_graph <- LRno_time_graph + stat_summary(fun.y=mean, aes(group= cond),  size=0.7, geom="line", linetype = "dashed")
LRno_time_graph

aLRL_time_graph <- ggplot(data=MR_all2, aes(x= day, y=aLRL, group = root_name, color = condition)) 
aLRL_time_graph <- aLRL_time_graph + geom_line(alpha = 0.2) 
aLRL_time_graph <- aLRL_time_graph + facet_grid(genotype~condition) 
aLRL_time_graph <- aLRL_time_graph + ylab("Average lateral root length (cm)") + xlab("Time (days after germination)") #+ ggtitle("average Lateral Root Length")
aLRL_time_graph <- aLRL_time_graph + stat_summary(fun.y=mean, aes(group= cond),  size=0.7, geom="line", linetype = "dashed")

aLRL_time_graph

TRS_time_graph <- ggplot(data=MR_all2, aes(x= day, y=TRS, group = root_name, color = condition)) 
TRS_time_graph <- TRS_time_graph + geom_line(alpha = 0.2) 
TRS_time_graph <- TRS_time_graph + facet_grid( genotype~condition) 
TRS_time_graph <- TRS_time_graph + ylab("Total root length (cm)") + xlab("Time (days after germination)") #+ ggtitle("Total Root Length")
TRS_time_graph <- TRS_time_graph + stat_summary(fun.y=mean, aes(group= cond),  size=0.7, geom="line", linetype = "dashed")
TRS_time_graph

### growth factor calculations - setup

So for calculating growth rate - lets first establish calculations on one plant. Let’s take the first plant that is within the experiment

temp1 <- subset(MR_all2, MR_all2$root_name == unique(MR_all2$root_name)[1])
temp2 <- temp1[order(temp1$day),]
temp2
# For Main Root Growth Rate - we want to remove all the datapoints that are repeating, because that indicates root hitting the plate edge:
temp_MR <- temp2[,c("day", "length")]
plot(temp_MR$length~ temp_MR$day)
abline(lm(temp_MR$length~ temp_MR$day))

MR_model <- lm(temp_MR$length~ temp_MR$day)
MR_model
## 
## Call:
## lm(formula = temp_MR$length ~ temp_MR$day)
## 
## Coefficients:
## (Intercept)  temp_MR$day  
##       4.528       -0.040
MR_growth_rate <- MR_model$coefficients[[2]]
MR_growth_rate
## [1] -0.0400018
#Let's remove all NA for LRno and aLRL in temp2
LR_temp <- temp2[,c("day", "LRno", "aLRL")]
LR_temp2 <- na.omit(LR_temp)

# Let's start with LRno
plot(LR_temp2$LRno ~ LR_temp2$day)
abline(lm(LR_temp2$LRno ~ LR_temp2$day))

LRno_model <- lm(LR_temp2$LRno ~ LR_temp2$day)
LRno_model
## 
## Call:
## lm(formula = LR_temp2$LRno ~ LR_temp2$day)
## 
## Coefficients:
##  (Intercept)  LR_temp2$day  
##         -7.5           1.5
LRno_increase <- as.numeric(as.character(LRno_model$coefficients[[2]]))
LRno_increase
## [1] 1.5
plot(LR_temp2$aLRL ~ LR_temp2$day)
abline(lm(LR_temp2$aLRL ~ LR_temp2$day))

aLRL_model <- lm(LR_temp2$aLRL ~ LR_temp2$day)
aLRL_model
## 
## Call:
## lm(formula = LR_temp2$aLRL ~ LR_temp2$day)
## 
## Coefficients:
##  (Intercept)  LR_temp2$day  
##     -0.13355       0.02671
aLRL_growth <- as.numeric(as.character(aLRL_model$coefficients[[2]]))
aLRL_growth
## [1] 0.02671084
temp2
names <- c(text="root_name", "genotype", "cond.final", "MR.delta", "LRno.delta", "aLRL.delta")
growth_factors <- data.frame()

for (k in names) growth_factors[[k]] <- as.character()

growth_factors[1,1] <- temp2$root_name[1]
growth_factors[1,2] <- as.character(temp2$genotype[1])
growth_factors[1,3] <- as.character(temp2$condition[1])
if(MR_growth_rate < 0){
  MR_growth_rate <- 0}
growth_factors[1,4] <- as.numeric(as.character(MR_growth_rate))
growth_factors[1,5] <- as.numeric(as.character(LRno_increase))
growth_factors[1,6] <- as.numeric(as.character(aLRL_growth))

growth_factors
length(unique(MR_all2$root_name))
## [1] 169

growth factor calculations - loop

# we are starting the loop from 2nd plant (i in 2:...), because we already calculated growth rates for the #1st plant:
for(e in 1:169){

  temp1 <- subset(MR_all2, MR_all2$root_name == unique(MR_all2$root_name)[e])
  temp2 <- temp1[order(temp1$day),]
  temp2

############ MR calculations
  temp_MR <- temp2[,c("day", "length")]
  if(dim(temp_MR)[1] > 1){
    MR_model <- lm(temp_MR$length~ temp_MR$day)
    MR_growth_rate <- MR_model$coefficients[[2]]} else{MR_growth_rate <- 0}
  if(MR_growth_rate < 0){MR_growth_rate <- 0}
    
  ############ LRno calculations
  LR_temp <- temp2[,c("day", "LRno", "aLRL")]
  LR_temp$aLRL <- as.numeric(as.character(LR_temp$aLRL))
  #LR_temp2 <- na.omit(LR_temp)
  dim(LR_temp)
  
  ####################### safety precaution to calculate LR growth rate only for the plants that have LR at #least for two days: 
  if(dim(LR_temp)[1] > 1){
  LRno_model <- lm(LR_temp$LRno ~ LR_temp$day)
  LRno_increase <- as.numeric(as.character(LRno_model$coefficients[[2]]))

  ############ aLRL calculations
  aLRL_model <- lm(LR_temp$aLRL ~ LR_temp$day)
  aLRL_growth <- as.numeric(as.character(aLRL_model$coefficients[[2]]))
  } else{
  ####################### safety precaution continued:
  ####################### so if you only have one day where LR are there - this wont be good enough to #calculate LRno or LRL rate
  ####################### and thus:
  LRno_increase <- 0
  aLRL_growth <- 0
  }
  LRno_increase
  aLRL_growth
  ############ adding the information to the table:
  growth_factors[e,1] <- temp2$root_name[1]
  growth_factors[e,2] <- as.character(temp2$genotype[1])
  growth_factors[e,3] <- as.character(temp2$condition[1])
  growth_factors[e,4] <- as.numeric(as.character(MR_growth_rate))
  growth_factors[e,5] <- as.numeric(as.character(LRno_increase))
  growth_factors[e,6] <- as.numeric(as.character(aLRL_growth))
}

growth_factors
growth_factors$cond.final <- factor(growth_factors$cond.final, levels = c("c_nocyto", "c_locyto", "c_hicyto",  "s_nocyto", "s_locyto", "s_hicyto"))
growth_factors$genotype <- factor(growth_factors$genotype, levels = c("LA1511", "M058", "M248"))


write.csv(growth_factors, "2023Feb_3acc_CYTO_growth_factors.csv", row.names = FALSE)

growth factor calculations - graphs

growth_factors$MR.delta <- as.numeric(as.character(growth_factors$MR.delta))
growth_factors$aLRL.delta <- as.numeric(as.character(growth_factors$aLRL.delta))
growth_factors$LRno.delta <- as.numeric(as.character(growth_factors$LRno.delta))
MR.delta_p_geno <- ggerrorplot(growth_factors, y = "MR.delta", x = "cond.final", fill="cond.final", color="cond.final", 
                        facet.by = c("genotype"), ncol=3,
                        desc_stat = "mean_sd", add = "jitter", 
                        add.params = list(color = "darkgray"),
                        xlab="", ylab="Main root growth rate (cm / day)") 
MR.delta_p_geno <- MR.delta_p_geno + rremove("legend") + stat_compare_means(method="t.test", ref.group = "c_nocyto", 
                                                              label = "p.signif", hide.ns = T)
MR.delta_p_geno

LRno.delta_p_geno <- ggerrorplot(growth_factors, y = "LRno.delta", x = "cond.final", fill="cond.final", color="cond.final", 
                        facet.by = c("genotype"), ncol=3,
                        desc_stat = "mean_sd", add = "jitter", 
                        add.params = list(color = "darkgray"),
                        xlab="", ylab="Lateral root number increase rate (# LR / day)") 
LRno.delta_p_geno <- LRno.delta_p_geno + rremove("legend") + stat_compare_means(method="t.test", ref.group = "c_nocyto", 
                                                              label = "p.signif", hide.ns = T)
LRno.delta_p_geno <- LRno.delta_p_geno #+ ggtitle("Lateral Root Number Increase")
LRno.delta_p_geno

aLRL.delta_p_geno <- ggerrorplot(growth_factors, y = "aLRL.delta", x = "cond.final", fill="cond.final", color="cond.final", 
                        facet.by = c("genotype"), ncol=3,
                        desc_stat = "mean_sd", add = "jitter", 
                        add.params = list(color = "darkgray"),
                        xlab="", ylab="Average lateral root length growth rate (cm / day)") 
aLRL.delta_p_geno <- aLRL.delta_p_geno + rremove("legend") + stat_compare_means(method="t.test", ref.group = "c_nocyto", 
                                                              label = "p.signif", hide.ns = T)
aLRL.delta_p_geno <- aLRL.delta_p_geno #+ ggtitle("average Lateral Root Growth")
aLRL.delta_p_geno

### growth factor calculations - Salt Stress Tolerance Indexes calculations. in theory, I have 3 STI.

library(doBy)
## 
## Attaching package: 'doBy'
## The following object is masked from 'package:dplyr':
## 
##     order_by
unique(growth_factors$cond.final)
## [1] s_hicyto c_hicyto c_locyto s_locyto c_nocyto s_nocyto
## Levels: c_nocyto c_locyto c_hicyto s_nocyto s_locyto s_hicyto
avg_growth <- summaryBy(data = growth_factors, MR.delta + aLRL.delta + LRno.delta ~ genotype + cond.final + cyto)
avg_growth
control_treatments <- c("c_nocyto", "c_locyto", "c_hicyto")
avg_growth2 <- subset(avg_growth, avg_growth$cond.final %in% control_treatments)
colnames(avg_growth2) <- gsub(".mean", ".control", colnames(avg_growth2))
avg_growth2$cyto <- avg_growth2$cond.final
avg_growth2$cyto <- gsub("c_", "", avg_growth2$cyto)

avg_growth2 <- avg_growth2[,c(1,3:6)]
avg_growth2
growth_factors2 <- growth_factors
growth_factors2$cyto <- growth_factors2$cond.final
growth_factors2$cyto <- gsub("c_", "", growth_factors2$cyto)
growth_factors2$cyto <- gsub("s_", "", growth_factors2$cyto)
unique(growth_factors2$cyto)
## [1] "hicyto" "locyto" "nocyto"
unique(growth_factors2$cond.final)
## [1] s_hicyto c_hicyto c_locyto s_locyto c_nocyto s_nocyto
## Levels: c_nocyto c_locyto c_hicyto s_nocyto s_locyto s_hicyto
growth_factors3 <- merge(growth_factors2, avg_growth2, by = c("genotype", "cyto"))
growth_factors3
growth_factors3$MR.STI <- growth_factors3$MR.delta / growth_factors3$MR.delta.control
growth_factors3$aLRL.STI <- growth_factors3$aLRL.delta / growth_factors3$aLRL.delta.control
growth_factors3$LRno.STI <- growth_factors3$LRno.delta / growth_factors3$LRno.delta.control
head(growth_factors3)
growth_factors3$cyto <- factor(growth_factors3$cyto, levels=c("nocyto", "locyto", "hicyto"))
### growth factor calculations - Salt Stress Tolerance Indexes graphs....

MR.STI_plot <- ggplot(data = growth_factors3, mapping = aes(x = cyto, y = MR.STI, colour = cyto)) 
MR.STI_plot <- MR.STI_plot + geom_beeswarm(alpha=0.6, priority = "density")
MR.STI_plot <- MR.STI_plot + facet_grid(~ genotype)
MR.STI_plot <- MR.STI_plot + stat_summary(fun=mean, geom="point", shape=95, size=10, color="black", fill="black")
MR.STI_plot <- MR.STI_plot + theme(legend.position = "none")
MR.STI_plot <- MR.STI_plot + xlab("")
MR.STI_plot <- MR.STI_plot + ylab("Salt tolerance index based on main root growth (Fraction of control)") #+ ggtitle("Salt Tolerance Index based on Main Root Growth")
MR.STI_plot <- MR.STI_plot + stat_compare_means(label = "p.signif", method = "t.test", ref.group = "c_nocyto", hide.ns = T) 
MR.STI_plot <- MR.STI_plot + scale_color_manual(values=c("royalblue", "coral3", "tomato4"))
MR.STI_plot
## Warning: Computation failed in `stat_compare_means()`
## Computation failed in `stat_compare_means()`
## Computation failed in `stat_compare_means()`
## Caused by error in `if (ref.group == ".all.") ...`:
## ! missing value where TRUE/FALSE needed

aLRL.STI_plot <- ggplot(data = growth_factors3, mapping = aes(x = cyto, y = aLRL.STI, colour = cyto)) 
aLRL.STI_plot <- aLRL.STI_plot + geom_beeswarm(alpha=0.6, priority = "density")
aLRL.STI_plot <- aLRL.STI_plot + facet_grid(~ genotype)
aLRL.STI_plot <- aLRL.STI_plot + stat_summary(fun=mean, geom="point", shape=95, size=10, color="black", fill="black")
aLRL.STI_plot <- aLRL.STI_plot + theme(legend.position = "none")
aLRL.STI_plot <- aLRL.STI_plot + xlab("")
aLRL.STI_plot <- aLRL.STI_plot + ylab("Salt tolerance index based on average lateral root growth (Fraction of control)")
aLRL.STI_plot <- aLRL.STI_plot + stat_compare_means(label = "p.signif", method = "t.test", ref.group = "c_nocyto", hide.ns = T) 
aLRL.STI_plot <- aLRL.STI_plot + scale_color_manual(values=c("royalblue", "coral3", "tomato4"))
aLRL.STI_plot
## Warning: Computation failed in `stat_compare_means()`
## Computation failed in `stat_compare_means()`
## Computation failed in `stat_compare_means()`
## Caused by error in `if (ref.group == ".all.") ...`:
## ! missing value where TRUE/FALSE needed

LRno.STI_plot <- ggplot(data = growth_factors3, mapping = aes(x = cyto, y = LRno.STI, colour = cyto)) 
LRno.STI_plot <- LRno.STI_plot + geom_beeswarm(alpha=0.6, priority = "density")
LRno.STI_plot <- LRno.STI_plot + facet_grid(~ genotype)
LRno.STI_plot <- LRno.STI_plot + stat_summary(fun=mean, geom="point", shape=95, size=10, color="black", fill="black")
LRno.STI_plot <- LRno.STI_plot + theme(legend.position = "none")
LRno.STI_plot <- LRno.STI_plot + xlab("")
LRno.STI_plot <- LRno.STI_plot + ylab("Salt tolerance index based on average increase in lateral root number (Fraction of control)")
LRno.STI_plot <- LRno.STI_plot + stat_compare_means(label = "p.signif", method = "t.test", ref.group = "c_nocyto", hide.ns = T) 
LRno.STI_plot <- LRno.STI_plot + scale_color_manual(values=c("royalblue", "coral3", "tomato4"))
LRno.STI_plot
## Warning: Computation failed in `stat_compare_means()`
## Computation failed in `stat_compare_means()`
## Computation failed in `stat_compare_means()`
## Caused by error in `if (ref.group == ".all.") ...`:
## ! missing value where TRUE/FALSE needed