library(readr)
RSA_Annie_2 <- read_csv("RSA_Annie_2.csv")
## Rows: 2713 Columns: 22
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): image, root_name, root, root_ontology, parent_name, parent, first_...
## dbl (12): day, length, vector_length, surface, volume, direction, diameter, ...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
RSA_Annie_2
## # A tibble: 2,713 × 22
##    image      day root_name root  length vector_length surface  volume direction
##    <chr>    <dbl> <chr>     <chr>  <dbl>         <dbl>   <dbl>   <dbl>     <dbl>
##  1 2024062…     1 Pl1_M_02… f7a3…  0.517         0.503  0.0238 9.13e-5      272.
##  2 2024062…     1 Pl1_M_02… 7c16…  0.683         0.680  0.0629 4.76e-4      259.
##  3 2024062…     1 Pl1_M_01… 6092…  0.874         0.775  0.0502 2.39e-4      267.
##  4 2024062…     1 Pl1_M_07… c01c…  0.590         0.577  0.0352 1.82e-4      271.
##  5 2024062…     1 Pl1_M_02… 97c8…  0.737         0.716  0.0491 2.73e-4      268.
##  6 2024062…     1 Pl1_M_02… 7b9f…  0.613         0.593  0.0363 1.78e-4      281.
##  7 2024062…     1 Pl1_M_01… 7b8e…  0.656         0.636  0.0352 1.64e-4      262.
##  8 2024062…     1 Pl1_M_01… a58b…  0.522         0.463  0.0354 1.99e-4      259.
##  9 2024062…     1 Pl1_M_01… a626…  0.864         0.819  0.0492 2.34e-4      272.
## 10 2024062…     1 Pl1_M_08… 31e4…  0.876         0.855  0.0728 4.89e-4      258.
## # ℹ 2,703 more rows
## # ℹ 13 more variables: diameter <dbl>, root_order <dbl>, root_ontology <chr>,
## #   parent_name <chr>, parent <chr>, insertion_position <dbl>,
## #   insertion_angle <dbl>, n_child <dbl>, child_density <dbl>,
## #   first_child <chr>, insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>

saving raw file

RSA_Annie_2_raw <- RSA_Annie_2
unique(RSA_Annie_2$day)
## [1] 1 5 9
Main_root <- subset(RSA_Annie_2, RSA_Annie_2$root_order == 0)
Main_root
## # A tibble: 745 × 22
##    image      day root_name root  length vector_length surface  volume direction
##    <chr>    <dbl> <chr>     <chr>  <dbl>         <dbl>   <dbl>   <dbl>     <dbl>
##  1 2024062…     1 Pl1_M_02… f7a3…  0.517         0.503  0.0238 9.13e-5      272.
##  2 2024062…     1 Pl1_M_02… 7c16…  0.683         0.680  0.0629 4.76e-4      259.
##  3 2024062…     1 Pl1_M_01… 6092…  0.874         0.775  0.0502 2.39e-4      267.
##  4 2024062…     1 Pl1_M_07… c01c…  0.590         0.577  0.0352 1.82e-4      271.
##  5 2024062…     1 Pl1_M_02… 97c8…  0.737         0.716  0.0491 2.73e-4      268.
##  6 2024062…     1 Pl1_M_02… 7b9f…  0.613         0.593  0.0363 1.78e-4      281.
##  7 2024062…     1 Pl1_M_01… 7b8e…  0.656         0.636  0.0352 1.64e-4      262.
##  8 2024062…     1 Pl1_M_01… a58b…  0.522         0.463  0.0354 1.99e-4      259.
##  9 2024062…     1 Pl1_M_01… a626…  0.864         0.819  0.0492 2.34e-4      272.
## 10 2024062…     1 Pl1_M_08… 31e4…  0.876         0.855  0.0728 4.89e-4      258.
## # ℹ 735 more rows
## # ℹ 13 more variables: diameter <dbl>, root_order <dbl>, root_ontology <chr>,
## #   parent_name <chr>, parent <chr>, insertion_position <dbl>,
## #   insertion_angle <dbl>, n_child <dbl>, child_density <dbl>,
## #   first_child <chr>, insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>
colnames(Main_root)
##  [1] "image"                 "day"                   "root_name"            
##  [4] "root"                  "length"                "vector_length"        
##  [7] "surface"               "volume"                "direction"            
## [10] "diameter"              "root_order"            "root_ontology"        
## [13] "parent_name"           "parent"                "insertion_position"   
## [16] "insertion_angle"       "n_child"               "child_density"        
## [19] "first_child"           "insertion_first_child" "last_child"           
## [22] "insertion_last_child"
Main_root[,c(4:6,11)]
## # A tibble: 745 × 4
##    root                                 length vector_length root_order
##    <chr>                                 <dbl>         <dbl>      <dbl>
##  1 f7a3097e-2170-4f57-958f-79b79c3526d1  0.517         0.503          0
##  2 7c164c79-7545-4861-a193-eeb82490c2eb  0.683         0.680          0
##  3 60929313-8622-4671-82fb-62ba0ea02d7d  0.874         0.775          0
##  4 c01cb305-5041-44d6-8d18-6885e154c944  0.590         0.577          0
##  5 97c81166-0747-485d-b663-e9cab198c902  0.737         0.716          0
##  6 7b9f4dab-e660-47af-b358-93383c819238  0.613         0.593          0
##  7 7b8e778d-05f1-4473-9507-b4125954cb62  0.656         0.636          0
##  8 a58b3c48-fc3b-40f1-b4cb-707d0e7e65cb  0.522         0.463          0
##  9 a6262902-120c-48bf-a259-ae2cea830363  0.864         0.819          0
## 10 31e4dc65-4b4b-407e-b61f-9697a91001b8  0.876         0.855          0
## # ℹ 735 more rows
colnames(Main_root)
##  [1] "image"                 "day"                   "root_name"            
##  [4] "root"                  "length"                "vector_length"        
##  [7] "surface"               "volume"                "direction"            
## [10] "diameter"              "root_order"            "root_ontology"        
## [13] "parent_name"           "parent"                "insertion_position"   
## [16] "insertion_angle"       "n_child"               "child_density"        
## [19] "first_child"           "insertion_first_child" "last_child"           
## [22] "insertion_last_child"
MR_data_2 <- Main_root[,c(1:5,17,18,20:22)]
MR_data_2
## # A tibble: 745 × 10
##    image              day root_name   root          length n_child child_density
##    <chr>            <dbl> <chr>       <chr>          <dbl>   <dbl>         <dbl>
##  1 20240624001.rsml     1 Pl1_M_02_03 f7a3097e-217…  0.517       0             0
##  2 20240624001.rsml     1 Pl1_M_02_02 7c164c79-754…  0.683       0             0
##  3 20240624001.rsml     1 Pl1_M_01_01 60929313-862…  0.874       0             0
##  4 20240624001.rsml     1 Pl1_M_07_01 c01cb305-504…  0.590       0             0
##  5 20240624001.rsml     1 Pl1_M_02_04 97c81166-074…  0.737       0             0
##  6 20240624001.rsml     1 Pl1_M_02_01 7b9f4dab-e66…  0.613       0             0
##  7 20240624001.rsml     1 Pl1_M_01_04 7b8e778d-05f…  0.656       0             0
##  8 20240624001.rsml     1 Pl1_M_01_03 a58b3c48-fc3…  0.522       0             0
##  9 20240624001.rsml     1 Pl1_M_01_02 a6262902-120…  0.864       0             0
## 10 20240624001.rsml     1 Pl1_M_08_04 31e4dc65-4b4…  0.876       0             0
## # ℹ 735 more rows
## # ℹ 3 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>
Lateral_root <- subset(RSA_Annie_2, RSA_Annie_2$root_order == 1)
Lateral_root
## # A tibble: 1,958 × 22
##    image      day root_name root  length vector_length surface  volume direction
##    <chr>    <dbl> <chr>     <chr>  <dbl>         <dbl>   <dbl>   <dbl>     <dbl>
##  1 62824_0…     5 root_1    3b46… 0.0514        0.0514 0.00137 2.90e-6      326.
##  2 62824_0…     5 root_0    92d4… 0.0319        0.0319 0.00128 4.19e-6      350.
##  3 70224_0…     9 root_26   5416… 0.0487        0.0487 0.00356 2.08e-5      206.
##  4 70224_0…     9 root_26   ba83… 0.0747        0.0747 0.00199 4.20e-6      254.
##  5 70224_0…     9 root_0    3144… 0.124         0.123  0.0102  6.70e-5      309.
##  6 70224_0…     9 root_26   7f5a… 0.180         0.179  0.0121  6.81e-5      317.
##  7 70224_0…     9 root_26   77cc… 0.0435        0.0435 0.00263 1.29e-5      204.
##  8 70224_0…     9 root_26   d631… 0.327         0.308  0.0237  1.40e-4      222.
##  9 70224_0…     9 root_27   981c… 0.361         0.354  0.0263  1.55e-4      315.
## 10 70224_0…     9 root_28   8766… 0.681         0.641  0.0416  2.05e-4      297.
## # ℹ 1,948 more rows
## # ℹ 13 more variables: diameter <dbl>, root_order <dbl>, root_ontology <chr>,
## #   parent_name <chr>, parent <chr>, insertion_position <dbl>,
## #   insertion_angle <dbl>, n_child <dbl>, child_density <dbl>,
## #   first_child <chr>, insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>
unique(Lateral_root$root_order)
## [1] 1
MR_data_2$root[1]
## [1] "f7a3097e-2170-4f57-958f-79b79c3526d1"
temporary <- subset(Lateral_root, Lateral_root$parent == MR_data_2$root[1])
temporary
## # A tibble: 1 × 22
##   image       day root_name root  length vector_length surface  volume direction
##   <chr>     <dbl> <chr>     <chr>  <dbl>         <dbl>   <dbl>   <dbl>     <dbl>
## 1 70224_00…     9 root_4    9a8d…  0.189         0.184  0.0138 8.31e-5      310.
## # ℹ 13 more variables: diameter <dbl>, root_order <dbl>, root_ontology <chr>,
## #   parent_name <chr>, parent <chr>, insertion_position <dbl>,
## #   insertion_angle <dbl>, n_child <dbl>, child_density <dbl>,
## #   first_child <chr>, insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>
MR_data_3 <- subset(MR_data_2, MR_data_2$n_child >0)
temporary <- subset(Lateral_root, Lateral_root$parent == MR_data_3$root[1])
temporary <- subset(temporary, temporary$day == MR_data_3$day[1])
temporary
## # A tibble: 1 × 22
##   image       day root_name root  length vector_length surface  volume direction
##   <chr>     <dbl> <chr>     <chr>  <dbl>         <dbl>   <dbl>   <dbl>     <dbl>
## 1 62824_01…     5 root_1    3b46… 0.0514        0.0514 0.00137 2.90e-6      326.
## # ℹ 13 more variables: diameter <dbl>, root_order <dbl>, root_ontology <chr>,
## #   parent_name <chr>, parent <chr>, insertion_position <dbl>,
## #   insertion_angle <dbl>, n_child <dbl>, child_density <dbl>,
## #   first_child <chr>, insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>
dim(temporary)
## [1]  1 22
dim(temporary)[1]
## [1] 1
dim(temporary)[2]
## [1] 22
total_LRL <- sum(temporary$length)
LR_number <- dim(temporary)[1]
total_LRL
## [1] 0.05141825
LR_number
## [1] 1
MR_data_3$LRL <- 0
MR_data_3$LRno <- 0
MR_data_3
## # A tibble: 247 × 12
##    image            day root_name    root           length n_child child_density
##    <chr>          <dbl> <chr>        <chr>           <dbl>   <dbl>         <dbl>
##  1 62824_012.rsml     5 Pl4_M_01_04  6013d64d-30a3…   2.25       1          0   
##  2 62824_012.rsml     5 Pl12_M_04_03 f934e717-3acb…   3.39       1          0   
##  3 70224_016.rsml     9 Pl16_C_06_04 94e86c63-b8aa…   5.40      11          3.32
##  4 70224_016.rsml     9 Pl16_C_06_03 32a861f3-e08b…   5.20       8          4.30
##  5 70224_016.rsml     9 Pl16_C_06_02 fb21ef9c-0363…   5.68      13          3.37
##  6 70224_016.rsml     9 Pl16_C_06_01 f030b1a4-8354…   6.93      11          5.02
##  7 70224_016.rsml     9 Pl16_C_05_04 8c4ccc99-1a35…   5.58      11          6.09
##  8 70224_016.rsml     9 Pl16_C_04_04 8ff8ab53-6d69…   6.57      14          4.20
##  9 70224_016.rsml     9 Pl16_C_04_03 8b9afaeb-9612…   7.65      23          5.21
## 10 70224_016.rsml     9 Pl16_C_04_02 28730492-9c81…   6.57      21          5.70
## # ℹ 237 more rows
## # ℹ 5 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>, LRL <dbl>, LRno <dbl>
MR_data_3$LRL[1] <- total_LRL
MR_data_3$LRno[1] <- LR_number
MR_data_3
## # A tibble: 247 × 12
##    image            day root_name    root           length n_child child_density
##    <chr>          <dbl> <chr>        <chr>           <dbl>   <dbl>         <dbl>
##  1 62824_012.rsml     5 Pl4_M_01_04  6013d64d-30a3…   2.25       1          0   
##  2 62824_012.rsml     5 Pl12_M_04_03 f934e717-3acb…   3.39       1          0   
##  3 70224_016.rsml     9 Pl16_C_06_04 94e86c63-b8aa…   5.40      11          3.32
##  4 70224_016.rsml     9 Pl16_C_06_03 32a861f3-e08b…   5.20       8          4.30
##  5 70224_016.rsml     9 Pl16_C_06_02 fb21ef9c-0363…   5.68      13          3.37
##  6 70224_016.rsml     9 Pl16_C_06_01 f030b1a4-8354…   6.93      11          5.02
##  7 70224_016.rsml     9 Pl16_C_05_04 8c4ccc99-1a35…   5.58      11          6.09
##  8 70224_016.rsml     9 Pl16_C_04_04 8ff8ab53-6d69…   6.57      14          4.20
##  9 70224_016.rsml     9 Pl16_C_04_03 8b9afaeb-9612…   7.65      23          5.21
## 10 70224_016.rsml     9 Pl16_C_04_02 28730492-9c81…   6.57      21          5.70
## # ℹ 237 more rows
## # ℹ 5 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>, LRL <dbl>, LRno <dbl>
MR_data_noChild <- subset(MR_data_2, MR_data_2$n_child == 0)
MR_data_noChild
## # A tibble: 498 × 10
##    image              day root_name   root          length n_child child_density
##    <chr>            <dbl> <chr>       <chr>          <dbl>   <dbl>         <dbl>
##  1 20240624001.rsml     1 Pl1_M_02_03 f7a3097e-217…  0.517       0             0
##  2 20240624001.rsml     1 Pl1_M_02_02 7c164c79-754…  0.683       0             0
##  3 20240624001.rsml     1 Pl1_M_01_01 60929313-862…  0.874       0             0
##  4 20240624001.rsml     1 Pl1_M_07_01 c01cb305-504…  0.590       0             0
##  5 20240624001.rsml     1 Pl1_M_02_04 97c81166-074…  0.737       0             0
##  6 20240624001.rsml     1 Pl1_M_02_01 7b9f4dab-e66…  0.613       0             0
##  7 20240624001.rsml     1 Pl1_M_01_04 7b8e778d-05f…  0.656       0             0
##  8 20240624001.rsml     1 Pl1_M_01_03 a58b3c48-fc3…  0.522       0             0
##  9 20240624001.rsml     1 Pl1_M_01_02 a6262902-120…  0.864       0             0
## 10 20240624001.rsml     1 Pl1_M_08_04 31e4dc65-4b4…  0.876       0             0
## # ℹ 488 more rows
## # ℹ 3 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>
dim(MR_data_3)
## [1] 247  12
for(i in 1:247){
  temporary <- subset(Lateral_root, Lateral_root$parent == MR_data_3$root[i])
  temporary <- subset(temporary, temporary$day == MR_data_3$day[i])
  total_LRL <- sum(temporary$length)
  LR_number <- dim(temporary)[1]
  MR_data_3$LRL[i] <- total_LRL
  MR_data_3$LRno[i] <- LR_number
}
MR_data_3$check <- MR_data_3$n_child - MR_data_3$LRno
MR_data_3
## # A tibble: 247 × 13
##    image            day root_name    root           length n_child child_density
##    <chr>          <dbl> <chr>        <chr>           <dbl>   <dbl>         <dbl>
##  1 62824_012.rsml     5 Pl4_M_01_04  6013d64d-30a3…   2.25       1          0   
##  2 62824_012.rsml     5 Pl12_M_04_03 f934e717-3acb…   3.39       1          0   
##  3 70224_016.rsml     9 Pl16_C_06_04 94e86c63-b8aa…   5.40      11          3.32
##  4 70224_016.rsml     9 Pl16_C_06_03 32a861f3-e08b…   5.20       8          4.30
##  5 70224_016.rsml     9 Pl16_C_06_02 fb21ef9c-0363…   5.68      13          3.37
##  6 70224_016.rsml     9 Pl16_C_06_01 f030b1a4-8354…   6.93      11          5.02
##  7 70224_016.rsml     9 Pl16_C_05_04 8c4ccc99-1a35…   5.58      11          6.09
##  8 70224_016.rsml     9 Pl16_C_04_04 8ff8ab53-6d69…   6.57      14          4.20
##  9 70224_016.rsml     9 Pl16_C_04_03 8b9afaeb-9612…   7.65      23          5.21
## 10 70224_016.rsml     9 Pl16_C_04_02 28730492-9c81…   6.57      21          5.70
## # ℹ 237 more rows
## # ℹ 6 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>, LRL <dbl>, LRno <dbl>, check <dbl>
unique(MR_data_3$check)
## [1] 0
head(MR_data_3)
## # A tibble: 6 × 13
##   image   day root_name root  length n_child child_density insertion_first_child
##   <chr> <dbl> <chr>     <chr>  <dbl>   <dbl>         <dbl> <chr>                
## 1 6282…     5 Pl4_M_01… 6013…   2.25       1          0    1.7297156            
## 2 6282…     5 Pl12_M_0… f934…   3.39       1          0    1.31693              
## 3 7022…     9 Pl16_C_0… 94e8…   5.40      11          3.32 0.82174563           
## 4 7022…     9 Pl16_C_0… 32a8…   5.20       8          4.30 0.90441424           
## 5 7022…     9 Pl16_C_0… fb21…   5.68      13          3.37 0.37227115           
## 6 7022…     9 Pl16_C_0… f030…   6.93      11          5.02 2.025383             
## # ℹ 5 more variables: last_child <chr>, insertion_last_child <chr>, LRL <dbl>,
## #   LRno <dbl>, check <dbl>
MR_data_Child2 <- MR_data_3[,1:12]
MR_data_Child2
## # A tibble: 247 × 12
##    image            day root_name    root           length n_child child_density
##    <chr>          <dbl> <chr>        <chr>           <dbl>   <dbl>         <dbl>
##  1 62824_012.rsml     5 Pl4_M_01_04  6013d64d-30a3…   2.25       1          0   
##  2 62824_012.rsml     5 Pl12_M_04_03 f934e717-3acb…   3.39       1          0   
##  3 70224_016.rsml     9 Pl16_C_06_04 94e86c63-b8aa…   5.40      11          3.32
##  4 70224_016.rsml     9 Pl16_C_06_03 32a861f3-e08b…   5.20       8          4.30
##  5 70224_016.rsml     9 Pl16_C_06_02 fb21ef9c-0363…   5.68      13          3.37
##  6 70224_016.rsml     9 Pl16_C_06_01 f030b1a4-8354…   6.93      11          5.02
##  7 70224_016.rsml     9 Pl16_C_05_04 8c4ccc99-1a35…   5.58      11          6.09
##  8 70224_016.rsml     9 Pl16_C_04_04 8ff8ab53-6d69…   6.57      14          4.20
##  9 70224_016.rsml     9 Pl16_C_04_03 8b9afaeb-9612…   7.65      23          5.21
## 10 70224_016.rsml     9 Pl16_C_04_02 28730492-9c81…   6.57      21          5.70
## # ℹ 237 more rows
## # ℹ 5 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>, LRL <dbl>, LRno <dbl>
MR_data_noChild
## # A tibble: 498 × 10
##    image              day root_name   root          length n_child child_density
##    <chr>            <dbl> <chr>       <chr>          <dbl>   <dbl>         <dbl>
##  1 20240624001.rsml     1 Pl1_M_02_03 f7a3097e-217…  0.517       0             0
##  2 20240624001.rsml     1 Pl1_M_02_02 7c164c79-754…  0.683       0             0
##  3 20240624001.rsml     1 Pl1_M_01_01 60929313-862…  0.874       0             0
##  4 20240624001.rsml     1 Pl1_M_07_01 c01cb305-504…  0.590       0             0
##  5 20240624001.rsml     1 Pl1_M_02_04 97c81166-074…  0.737       0             0
##  6 20240624001.rsml     1 Pl1_M_02_01 7b9f4dab-e66…  0.613       0             0
##  7 20240624001.rsml     1 Pl1_M_01_04 7b8e778d-05f…  0.656       0             0
##  8 20240624001.rsml     1 Pl1_M_01_03 a58b3c48-fc3…  0.522       0             0
##  9 20240624001.rsml     1 Pl1_M_01_02 a6262902-120…  0.864       0             0
## 10 20240624001.rsml     1 Pl1_M_08_04 31e4dc65-4b4…  0.876       0             0
## # ℹ 488 more rows
## # ℹ 3 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>
MR_data_noChild$LRL <- 0
MR_data_noChild$LRno <- 0

MR_all <- rbind(MR_data_Child2, MR_data_noChild)
unique(MR_all$day)
## [1] 5 9 1
?strsplit()
MR_all$root_name[1]
## [1] "Pl4_M_01_04"
text <- strsplit(x = MR_all$root_name[1], split = "_")
text
## [[1]]
## [1] "Pl4" "M"   "01"  "04"
genotype <- text[[1]][3]
genotype
## [1] "01"
cond <- text[[1]][2]
cond
## [1] "M"
replicate <- text[[1]][4]
replicate
## [1] "04"
plate <- text[[1]][1]
plate
## [1] "Pl4"
dim(MR_all)
## [1] 745  12
for(i in 1:745){
  text <- strsplit(x = MR_all$root_name[i], split = "_")
  genotype <- text[[1]][3]
  cond <- text[[1]][2]
  replicate <- text[[1]][4]
  plate <- text[[1]][1]
   
  MR_all$genotype[i] <- genotype
  MR_all$condition[i] <- cond
  MR_all$plate[i] <- plate
  MR_all$replicate[i] <- replicate
}
## Warning: Unknown or uninitialised column: `genotype`.
## Warning: Unknown or uninitialised column: `condition`.
## Warning: Unknown or uninitialised column: `plate`.
## Warning: Unknown or uninitialised column: `replicate`.
MR_all
## # A tibble: 745 × 16
##    image            day root_name    root           length n_child child_density
##    <chr>          <dbl> <chr>        <chr>           <dbl>   <dbl>         <dbl>
##  1 62824_012.rsml     5 Pl4_M_01_04  6013d64d-30a3…   2.25       1          0   
##  2 62824_012.rsml     5 Pl12_M_04_03 f934e717-3acb…   3.39       1          0   
##  3 70224_016.rsml     9 Pl16_C_06_04 94e86c63-b8aa…   5.40      11          3.32
##  4 70224_016.rsml     9 Pl16_C_06_03 32a861f3-e08b…   5.20       8          4.30
##  5 70224_016.rsml     9 Pl16_C_06_02 fb21ef9c-0363…   5.68      13          3.37
##  6 70224_016.rsml     9 Pl16_C_06_01 f030b1a4-8354…   6.93      11          5.02
##  7 70224_016.rsml     9 Pl16_C_05_04 8c4ccc99-1a35…   5.58      11          6.09
##  8 70224_016.rsml     9 Pl16_C_04_04 8ff8ab53-6d69…   6.57      14          4.20
##  9 70224_016.rsml     9 Pl16_C_04_03 8b9afaeb-9612…   7.65      23          5.21
## 10 70224_016.rsml     9 Pl16_C_04_02 28730492-9c81…   6.57      21          5.70
## # ℹ 735 more rows
## # ℹ 9 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>, LRL <dbl>, LRno <dbl>, genotype <chr>,
## #   condition <chr>, plate <chr>, replicate <chr>
unique(MR_all$genotype)
## [1] "01" "04" "06" "05" "03" "02" "08" "07" NA
MR_all.nona <- na.omit(MR_all)
unique(MR_all.nona$genotype)
## [1] "01" "04" "06" "05" "03" "02" "08" "07"
unique(MR_all.nona$condition)
## [1] "M" "C"
dim(MR_all.nona)
## [1] 725  16
unique(MR_all$day)
## [1] 5 9 1
MR_all.nona$TRS <- MR_all.nona$length + MR_all.nona$LRL
MR_all.nona$aLRL <- MR_all.nona$LRL/ MR_all.nona$LRno
MR_all.nona$MRpLRL <- MR_all.nona$length / MR_all.nona$LRL
MR_all.nona
## # A tibble: 725 × 19
##    image            day root_name    root           length n_child child_density
##    <chr>          <dbl> <chr>        <chr>           <dbl>   <dbl>         <dbl>
##  1 62824_012.rsml     5 Pl4_M_01_04  6013d64d-30a3…   2.25       1          0   
##  2 62824_012.rsml     5 Pl12_M_04_03 f934e717-3acb…   3.39       1          0   
##  3 70224_016.rsml     9 Pl16_C_06_04 94e86c63-b8aa…   5.40      11          3.32
##  4 70224_016.rsml     9 Pl16_C_06_03 32a861f3-e08b…   5.20       8          4.30
##  5 70224_016.rsml     9 Pl16_C_06_02 fb21ef9c-0363…   5.68      13          3.37
##  6 70224_016.rsml     9 Pl16_C_06_01 f030b1a4-8354…   6.93      11          5.02
##  7 70224_016.rsml     9 Pl16_C_05_04 8c4ccc99-1a35…   5.58      11          6.09
##  8 70224_016.rsml     9 Pl16_C_04_04 8ff8ab53-6d69…   6.57      14          4.20
##  9 70224_016.rsml     9 Pl16_C_04_03 8b9afaeb-9612…   7.65      23          5.21
## 10 70224_016.rsml     9 Pl16_C_04_02 28730492-9c81…   6.57      21          5.70
## # ℹ 715 more rows
## # ℹ 12 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>, LRL <dbl>, LRno <dbl>, genotype <chr>,
## #   condition <chr>, plate <chr>, replicate <chr>, TRS <dbl>, aLRL <dbl>,
## #   MRpLRL <dbl>
library(ggplot2)
library(ggpubr)
MR_all <- MR_all.nona
unique(MR_all.nona$condition)
## [1] "M" "C"
MR_all.nona$condition <- as.factor(MR_all.nona$condition)


histogram_TRS <- ggdensity(MR_all.nona, x = "TRS",
                           add = "mean", rug = TRUE,facet.by = "day",
                           color = "condition", fill = "condition",
                           panel.labs = list(day = c("Day 1", "Day 2", "Day 3")),
                           palette = c("#00AFBB", "#E7B800", "#FF0000"))
histogram_TRS <- ggpar(histogram_TRS, xlab = "Total Root Size", ylab = "Density", legend.title = "Condition")
histogram_TRS

?ggpar
histogram_LRL <- ggdensity(MR_all.nona, x = "LRL",
                           add = "mean", rug = TRUE,facet.by = "day",
                           color = "condition", fill = "condition",
                           palette = c("#00AFBB", "#E7B800", "#FF0000"))
histogram_LRL

pdf("histogram.TRS.pdf")
plot(histogram_TRS)
# if plotting multiple graphs - this command is extremely important 
dev.off()
## quartz_off_screen 
##                 2
library(cowplot)
## 
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggpubr':
## 
##     get_legend
pdf("Figure_MAIN_1.pdf", height = 15, width = 12)
plot_grid(histogram_TRS, histogram_LRL, ncol=2,
          align = "hv", labels=c("AUTO"), 
          label_size = 24)
dev.off()
## quartz_off_screen 
##                 2
unique(MR_all$genotype)
## [1] "01" "04" "06" "05" "03" "02" "08" "07"
TRS_lgraph <- ggplot(data=MR_all.nona, aes(x= genotype, y=TRS, color = condition)) 
TRS_lgraph <- TRS_lgraph + geom_boxplot()
TRS_lgraph <- TRS_lgraph + facet_grid(~ condition) + scale_color_manual(values=c("turquoise3", "maroon3", "dark orange"))
TRS_lgraph <- TRS_lgraph + ylab("Total root size (cm)") + xlab("") + theme(legend.position='none')
TRS_lgraph

#possibly if I did this right - no significance between the the diff accessions

library(ggsignif)
library(ggplot2)
library(ggsignif)

TRS_lgraph_sig <- ggplot(data = MR_all.nona, aes(x = genotype, y = TRS, color = condition)) +
  geom_boxplot() +
  facet_grid(~ condition) +
  scale_color_manual(values = c("turquoise3", "maroon3", "dark orange")) +
  ylab("Total root size (cm)") +
  xlab("") +
  theme(legend.position = 'none') +
  geom_signif(comparisons = list(c("01", "07")),
              map_signif_level = TRUE,
              textsize = 3.5)

TRS_lgraph_sig

library(ggsci)
library(ggbeeswarm)
library(gapminder)
library(RColorBrewer)
library(ggridges)
better_TRS_graph <- ggplot(data=MR_all.nona, aes(x= genotype, y=TRS, color = condition))
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.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
better_TRS_graph <- better_TRS_graph + facet_grid(day~ condition) + 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 = "01") 
better_TRS_graph
## Warning: Computation failed in `stat_compare_means()`.
## Caused by error:
## ! argument "x" is missing, with no default
## Warning: Computation failed in `stat_compare_means()`.
## Caused by error:
## ! Can't find specified reference group: 1. Allowed values include one of: 4, 2, 14, 16, 8, 6, 12, 10
## Warning: Computation failed in `stat_compare_means()`.
## Caused by error:
## ! argument "x" is missing, with no default
## Warning: Computation failed in `stat_compare_means()`.
## Caused by error:
## ! Can't find specified reference group: 1. Allowed values include one of: 2, 8, 16, 12, 10, 14, 6, 4
## Warning: Computation failed in `stat_compare_means()`.
## Caused by error:
## ! argument "x" is missing, with no default
## Warning: Computation failed in `stat_compare_means()`.
## Caused by error:
## ! Can't find specified reference group: 1. Allowed values include one of: 2, 16, 14, 4, 8, 6, 12, 10

day9 <- subset(MR_all.nona, MR_all.nona$day == "9")
day9
## # A tibble: 241 × 19
##    image            day root_name    root           length n_child child_density
##    <chr>          <dbl> <chr>        <chr>           <dbl>   <dbl>         <dbl>
##  1 70224_016.rsml     9 Pl16_C_06_04 94e86c63-b8aa…   5.40      11          3.32
##  2 70224_016.rsml     9 Pl16_C_06_03 32a861f3-e08b…   5.20       8          4.30
##  3 70224_016.rsml     9 Pl16_C_06_02 fb21ef9c-0363…   5.68      13          3.37
##  4 70224_016.rsml     9 Pl16_C_06_01 f030b1a4-8354…   6.93      11          5.02
##  5 70224_016.rsml     9 Pl16_C_05_04 8c4ccc99-1a35…   5.58      11          6.09
##  6 70224_016.rsml     9 Pl16_C_04_04 8ff8ab53-6d69…   6.57      14          4.20
##  7 70224_016.rsml     9 Pl16_C_04_03 8b9afaeb-9612…   7.65      23          5.21
##  8 70224_016.rsml     9 Pl16_C_04_02 28730492-9c81…   6.57      21          5.70
##  9 70224_016.rsml     9 Pl16_C_03_02 2a99cf64-03d3…   7.78      21          5.17
## 10 70224_016.rsml     9 Pl16_C_03_01 3da76b7a-d1c6…   6.74      11          4.18
## # ℹ 231 more rows
## # ℹ 12 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>, LRL <dbl>, LRno <dbl>, genotype <chr>,
## #   condition <fct>, plate <chr>, replicate <chr>, TRS <dbl>, aLRL <dbl>,
## #   MRpLRL <dbl>

day 9

?ggplot
# decoding genotypes
day9$genotype <- gsub("01", "Col.0", day9$genotype)
day9$genotype <- gsub("02", "cis1.1", day9$genotype)
day9$genotype <- gsub("03", "agl16.1", day9$genotype)
day9$genotype <- gsub("04", "akr4c9.3A", day9$genotype)
day9$genotype <- gsub("05", "cis1.2", day9$genotype)
day9$genotype <- gsub("06", "agl16.2", day9$genotype)
day9$genotype <- gsub("07", "akr4c9.2I", day9$genotype)
day9$genotype <- gsub("08", "akr4c9.1F2", day9$genotype)
day9$condition <- gsub("C", "Control", day9$condition)
day9$condition <- gsub("M", "Mannitol", day9$condition)
day9$genotype <- factor(day9$genotype, levels = c("Col.0", "akr4c9.3A", "akr4c9.2I", "akr4c9.1F2", "agl16.1", "agl16.2", "cis1.1", "cis1.2"))

better_TRS_graph <- ggplot(data=day9, aes(x= genotype, y=TRS, color = condition))
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")
better_TRS_graph <- better_TRS_graph + facet_grid(~ condition) + scale_color_manual(values=c("royalblue", "orange"))
better_TRS_graph <- better_TRS_graph + ylab("Total root size (cm)") + xlab("") + 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 = "01")
better_TRS_graph <- better_TRS_graph + theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))
better_TRS_graph
## Warning: 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

## adding p-values

library(stringr)
library(multcompView)
Control <- subset(day9, day9$condition == "Control")
Mannitol <- subset(day9, day9$condition == "Mannitol")
Control$genotype <- as.factor(Control$genotype)
Mannitol$genotype <- as.factor(Mannitol$genotype)

Output <- TukeyHSD(aov(TRS ~ genotype, data = Control))
P7 = Output$genotype[,'p adj']
stat.test<- multcompLetters(P7)
testc <- as.data.frame(stat.test$Letters)
testc$group2 <- rownames(testc)
testc$group1 <- rownames(testc)
testc$genotype <- rownames(testc)
testc$genotype <- rownames(testc)
colnames(testc)[1] <- "Tukey"
testc$condition <- "Control"

Output <- TukeyHSD(aov(TRS ~ genotype, data = Mannitol))
P7 = Output$genotype[,'p adj']
stat.test<- multcompLetters(P7)
tests <- as.data.frame(stat.test$Letters)
tests$group2 <- rownames(tests)
tests$group1 <- rownames(tests)
tests$genotype <- rownames(tests)
tests$genotype <- rownames(tests)
colnames(tests)[1] <- "Tukey"
tests$condition <- "Mannitol"

test <- rbind(testc, tests)
test
##             Tukey     group2     group1   genotype condition
## akr4c9.3A      ab  akr4c9.3A  akr4c9.3A  akr4c9.3A   Control
## akr4c9.2I       a  akr4c9.2I  akr4c9.2I  akr4c9.2I   Control
## akr4c9.1F2     ab akr4c9.1F2 akr4c9.1F2 akr4c9.1F2   Control
## agl16.1        ab    agl16.1    agl16.1    agl16.1   Control
## agl16.2        ab    agl16.2    agl16.2    agl16.2   Control
## cis1.1          b     cis1.1     cis1.1     cis1.1   Control
## cis1.2          b     cis1.2     cis1.2     cis1.2   Control
## Col.0          ab      Col.0      Col.0      Col.0   Control
## akr4c9.3A1    abc  akr4c9.3A  akr4c9.3A  akr4c9.3A  Mannitol
## akr4c9.2I1     ab  akr4c9.2I  akr4c9.2I  akr4c9.2I  Mannitol
## akr4c9.1F21     a akr4c9.1F2 akr4c9.1F2 akr4c9.1F2  Mannitol
## agl16.11        c    agl16.1    agl16.1    agl16.1  Mannitol
## agl16.21      abc    agl16.2    agl16.2    agl16.2  Mannitol
## cis1.11       abc     cis1.1     cis1.1     cis1.1  Mannitol
## cis1.21       abc     cis1.2     cis1.2     cis1.2  Mannitol
## Col.01         bc      Col.0      Col.0      Col.0  Mannitol
better_TRS_graph_2 <- better_TRS_graph + stat_pvalue_manual(test, label = "Tukey", y.position = 25)
better_TRS_graph_2
## Warning: 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

head(Mannitol)
## # A tibble: 6 × 19
##   image   day root_name root  length n_child child_density insertion_first_child
##   <chr> <dbl> <chr>     <chr>  <dbl>   <dbl>         <dbl> <chr>                
## 1 7022…     9 Pl1_M_01… 5c1c…   2.94       2          1.11 0                    
## 2 7022…     9 Pl1_M_08… 6e29…   4.72       6          3.38 0.4548766            
## 3 7022…     9 Pl1_M_08… cbaf…   4.75       7          4.66 1.013784             
## 4 7022…     9 Pl1_M_08… 7336…   5.01       6          2.82 0.19812164           
## 5 7022…     9 Pl1_M_07… 434c…   4.36       4          4.66 1.4458275            
## 6 7022…     9 Pl1_M_07… 6c41…   5.44      10          3.41 0.66941154           
## # ℹ 11 more variables: last_child <chr>, insertion_last_child <chr>, LRL <dbl>,
## #   LRno <dbl>, genotype <fct>, condition <chr>, plate <chr>, replicate <chr>,
## #   TRS <dbl>, aLRL <dbl>, MRpLRL <dbl>
head(day9)
## # A tibble: 6 × 19
##   image   day root_name root  length n_child child_density insertion_first_child
##   <chr> <dbl> <chr>     <chr>  <dbl>   <dbl>         <dbl> <chr>                
## 1 7022…     9 Pl16_C_0… 94e8…   5.40      11          3.32 0.82174563           
## 2 7022…     9 Pl16_C_0… 32a8…   5.20       8          4.30 0.90441424           
## 3 7022…     9 Pl16_C_0… fb21…   5.68      13          3.37 0.37227115           
## 4 7022…     9 Pl16_C_0… f030…   6.93      11          5.02 2.025383             
## 5 7022…     9 Pl16_C_0… 8c4c…   5.58      11          6.09 1.3077601            
## 6 7022…     9 Pl16_C_0… 8ff8…   6.57      14          4.20 0                    
## # ℹ 11 more variables: last_child <chr>, insertion_last_child <chr>, LRL <dbl>,
## #   LRno <dbl>, genotype <fct>, condition <chr>, plate <chr>, replicate <chr>,
## #   TRS <dbl>, aLRL <dbl>, MRpLRL <dbl>
library(ggpubr)
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
head(MR_all.nona)
## # A tibble: 6 × 19
##   image   day root_name root  length n_child child_density insertion_first_child
##   <chr> <dbl> <chr>     <chr>  <dbl>   <dbl>         <dbl> <chr>                
## 1 6282…     5 Pl4_M_01… 6013…   2.25       1          0    1.7297156            
## 2 6282…     5 Pl12_M_0… f934…   3.39       1          0    1.31693              
## 3 7022…     9 Pl16_C_0… 94e8…   5.40      11          3.32 0.82174563           
## 4 7022…     9 Pl16_C_0… 32a8…   5.20       8          4.30 0.90441424           
## 5 7022…     9 Pl16_C_0… fb21…   5.68      13          3.37 0.37227115           
## 6 7022…     9 Pl16_C_0… f030…   6.93      11          5.02 2.025383             
## # ℹ 11 more variables: last_child <chr>, insertion_last_child <chr>, LRL <dbl>,
## #   LRno <dbl>, genotype <chr>, condition <fct>, plate <chr>, replicate <chr>,
## #   TRS <dbl>, aLRL <dbl>, MRpLRL <dbl>
my_graph <- ggplot(data=MR_all.nona, 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") + theme(legend.position='none')
my_graph

ggplotly(my_graph)
geno_c <- subset(MR_all.nona, MR_all.nona$genotype == "01")
geno_c <- subset(MR_all.nona, MR_all.nona$genotype == "01")

my_graph <- ggplot(data=geno_c, 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("Col-O Main Root Length (cm)") + theme(legend.position='none')
my_graph

my_graph <- ggplot(data=geno_c, 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_c, 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_c, 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_02 <- subset(MR_all.nona, MR_all.nona$genotype == "02")

my_graph <- ggplot(data=geno_02, 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("02 Main Root Length (cm)") + theme(legend.position='none')
my_graph

geno_03 <- subset(MR_all.nona, MR_all.nona$genotype == "03")

my_graph <- ggplot(data=geno_03, 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("03 Main Root Length (cm)") + theme(legend.position='none')
my_graph

geno_04 <- subset(MR_all.nona, MR_all.nona$genotype == "04")

my_graph <- ggplot(data=geno_04, 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("04 Main Root Length (cm)") + theme(legend.position='none')
my_graph

geno_05 <- subset(MR_all.nona, MR_all.nona$genotype == "05")

my_graph <- ggplot(data=geno_05, 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("05 Main Root Length (cm)") + theme(legend.position='none')
my_graph

geno_06 <- subset(MR_all.nona, MR_all.nona$genotype == "06")

my_graph <- ggplot(data=geno_06, 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("06 Main Root Length (cm)") + theme(legend.position='none')
my_graph

geno_07 <- subset(MR_all.nona, MR_all.nona$genotype == "07")

my_graph <- ggplot(data=geno_07, 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("07 Main Root Length (cm)") + theme(legend.position='none')
my_graph

geno_08 <- subset(MR_all.nona, MR_all.nona$genotype == "08")

my_graph <- ggplot(data=geno_08, 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(" 08 Main Root Length (cm)") + theme(legend.position='none')
my_graph

MR_both_geno <- rbind(geno_c,geno_02, geno_03,geno_04,geno_05,geno_06, geno_07, geno_08)

MR_time_graph <- ggplot(data=MR_both_geno, aes(x= day, y=length, group = root_name, color = genotype)) 
MR_time_graph <- MR_time_graph + geom_line(alpha = 0.1) 
MR_time_graph <- MR_time_graph + facet_grid(~ condition)
MR_time_graph <- MR_time_graph + scale_color_manual(values= c("blue", "orange", "black", "hotpink","red", "darkblue","darkgreen", "purple" ))
MR_time_graph <- MR_time_graph + ylab("length (cm)") + xlab("time (days after germination)") + ggtitle("Main Root Length")
MR_time_graph <- MR_time_graph + stat_summary(fun.y=mean, aes(group= genotype),  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.
MR_time_graph

LRL_time_graph <- ggplot(data=MR_both_geno, aes(x= day, y=LRL, group = root_name, color = genotype)) 
LRL_time_graph <- LRL_time_graph + geom_line(alpha = 0.2) 
LRL_time_graph <- LRL_time_graph + facet_grid(~ condition) 
LRL_time_graph <- LRL_time_graph + scale_color_manual(values= c("blue", "orange", "black", "hotpink","red", "darkblue","darkgreen", "purple"))

LRL_time_graph <- LRL_time_graph + ylab("length (cm)") + xlab("time (days after germination)") + ggtitle("Lateral Root Length")
LRL_time_graph <- LRL_time_graph + stat_summary(fun.y=mean, aes(group= genotype),  size=0.7, geom="line", linetype = "dashed")
LRL_time_graph

LRno_time_graph <- ggplot(data=MR_both_geno, aes(x= day, y=LRno, group = root_name, color = genotype)) 
LRno_time_graph <- LRno_time_graph + geom_line(alpha = 0.2) 
LRno_time_graph <- LRno_time_graph + facet_grid(~ condition)
LRno_time_graph <- LRno_time_graph + scale_color_manual(values= c("blue", "orange", "black", "hotpink","red", "darkblue","darkgreen", "purple"))

LRno_time_graph <- LRno_time_graph + ylab("length (cm)") + xlab("time (days after germination)") + ggtitle("Lateral Root Number")
LRno_time_graph <- LRno_time_graph + stat_summary(fun.y=mean, aes(group= genotype),  size=0.7, geom="line", linetype = "dashed")
LRno_time_graph

TRS_time_graph <- ggplot(data=MR_both_geno, aes(x= day, y=TRS, group = root_name, color = genotype)) 
TRS_time_graph <- TRS_time_graph + geom_line(alpha = 0.2) 
TRS_time_graph <- TRS_time_graph + facet_grid(~ condition)
TRS_time_graph <- TRS_time_graph + scale_color_manual(values= c("blue", "orange", "black", "hotpink","red", "darkblue","darkgreen", "purple"))
TRS_time_graph <- TRS_time_graph + ylab("length (cm)") + xlab("time (days after germination)") + ggtitle("Total Root Length")
TRS_time_graph <- TRS_time_graph + stat_summary(fun.y=mean, aes(group= genotype),  size=0.7, geom="line", linetype = "dashed")
TRS_time_graph

aLRL_time_graph <- ggplot(data=MR_both_geno, aes(x= day, y=aLRL, group = root_name, color = genotype)) 
aLRL_time_graph <- aLRL_time_graph + geom_line(alpha = 0.2) 
aLRL_time_graph <- aLRL_time_graph + facet_grid(~ condition)
aLRL_time_graph <- aLRL_time_graph + scale_color_manual(values= c("blue", "orange", "black", "hotpink","red", "darkblue","darkgreen", "purple"))

aLRL_time_graph <- aLRL_time_graph + ylab("length (cm)") + xlab("time (days after germination)") + ggtitle("Total Average Lateral Root Length")
aLRL_time_graph <- aLRL_time_graph + stat_summary(fun.y=mean, aes(group= genotype),  size=0.7, geom="line", linetype = "dashed")
aLRL_time_graph
## Warning: Removed 479 rows containing non-finite outside the scale range
## (`stat_summary()`).
## Warning: Removed 478 rows containing missing values or values outside the scale range
## (`geom_line()`).

pdf("20221011_Arabidopsis_DUF_OE_RSA_Time_Graphs.pdf", width = 13, height = 13)
plot_grid(MR_time_graph , LRL_time_graph, LRno_time_graph, TRS_time_graph, labels = c("AUTO"), ncol = 2)
#pdf("20221011_Arabidopsis_DUF_OE_RSA_Time_Graphs.pdf", width = 13, height = 13)
dev.off()
## quartz_off_screen 
##                 2

Growth rate calculations

MR_both_geno
## # A tibble: 725 × 19
##    image            day root_name   root            length n_child child_density
##    <chr>          <dbl> <chr>       <chr>            <dbl>   <dbl>         <dbl>
##  1 62824_012.rsml     5 Pl4_M_01_04 6013d64d-30a3-…   2.25       1          0   
##  2 62824_008.rsml     5 Pl8_C_01_01 e8d074f3-f693-…   2.97       1          0   
##  3 62824_008.rsml     5 Pl8_C_01_04 aeb10c8f-f7b7-…   2.60       1          0   
##  4 62824_008.rsml     5 Pl8_C_01_02 c87267be-b262-…   3.42       2          6.26
##  5 62824_009.rsml     5 Pl9_C_01_01 456ad34f-f37b-…   2.04       1          0   
##  6 62824_009.rsml     5 Pl9_C_01_02 7bcd00b4-d8df-…   3.39       2          5.81
##  7 70224_001.rsml     9 Pl1_M_01_04 5c1cd1f0-119a-…   2.94       2          1.11
##  8 70224_001.rsml     9 Pl1_M_01_01 60929313-8622-…   4.07       2          4.47
##  9 70224_001.rsml     9 Pl1_M_01_03 a58b3c48-fc3b-…   2.07       1          0   
## 10 70224_006.rsml     9 Pl6_C_01_03 38879f0d-684c-…   5.22       7          2.43
## # ℹ 715 more rows
## # ℹ 12 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>, LRL <dbl>, LRno <dbl>, genotype <chr>,
## #   condition <fct>, plate <chr>, replicate <chr>, TRS <dbl>, aLRL <dbl>,
## #   MRpLRL <dbl>
new_name <- strsplit(MR_both_geno$root_name[1], "_")[[1]][2:4]
paste(new_name[1], new_name[2], new_name[3], sep="_")
## [1] "M_01_04"
for(i in 1:nrow(MR_both_geno)){
  new_name <- strsplit(MR_both_geno$root_name[i], "_")[[1]][2:4]
  MR_both_geno$root_name2[i] <-paste(new_name[1], new_name[2], new_name[3], sep="_") 
}
## Warning: Unknown or uninitialised column: `root_name2`.
MR_both_geno
## # A tibble: 725 × 20
##    image            day root_name   root            length n_child child_density
##    <chr>          <dbl> <chr>       <chr>            <dbl>   <dbl>         <dbl>
##  1 62824_012.rsml     5 Pl4_M_01_04 6013d64d-30a3-…   2.25       1          0   
##  2 62824_008.rsml     5 Pl8_C_01_01 e8d074f3-f693-…   2.97       1          0   
##  3 62824_008.rsml     5 Pl8_C_01_04 aeb10c8f-f7b7-…   2.60       1          0   
##  4 62824_008.rsml     5 Pl8_C_01_02 c87267be-b262-…   3.42       2          6.26
##  5 62824_009.rsml     5 Pl9_C_01_01 456ad34f-f37b-…   2.04       1          0   
##  6 62824_009.rsml     5 Pl9_C_01_02 7bcd00b4-d8df-…   3.39       2          5.81
##  7 70224_001.rsml     9 Pl1_M_01_04 5c1cd1f0-119a-…   2.94       2          1.11
##  8 70224_001.rsml     9 Pl1_M_01_01 60929313-8622-…   4.07       2          4.47
##  9 70224_001.rsml     9 Pl1_M_01_03 a58b3c48-fc3b-…   2.07       1          0   
## 10 70224_006.rsml     9 Pl6_C_01_03 38879f0d-684c-…   5.22       7          2.43
## # ℹ 715 more rows
## # ℹ 13 more variables: insertion_first_child <chr>, last_child <chr>,
## #   insertion_last_child <chr>, LRL <dbl>, LRno <dbl>, genotype <chr>,
## #   condition <fct>, plate <chr>, replicate <chr>, TRS <dbl>, aLRL <dbl>,
## #   MRpLRL <dbl>, root_name2 <chr>
temp1 <- subset(MR_both_geno, MR_both_geno$root_name == unique(MR_both_geno$root_name)[22])
temp1
## # A tibble: 3 × 20
##   image   day root_name root  length n_child child_density insertion_first_child
##   <chr> <dbl> <chr>     <chr>  <dbl>   <dbl>         <dbl> <chr>                
## 1 7022…     9 Pl12_M_0… a702…  5.80       12          3.89 0.46097413           
## 2 6282…     5 Pl12_M_0… a702…  3.18        0          0    null                 
## 3 2024…     1 Pl12_M_0… a702…  0.936       0          0    null                 
## # ℹ 12 more variables: last_child <chr>, insertion_last_child <chr>, LRL <dbl>,
## #   LRno <dbl>, genotype <chr>, condition <fct>, plate <chr>, replicate <chr>,
## #   TRS <dbl>, aLRL <dbl>, MRpLRL <dbl>, root_name2 <chr>
temp2 <- temp1[order(temp1$day),]
temp2
## # A tibble: 3 × 20
##   image   day root_name root  length n_child child_density insertion_first_child
##   <chr> <dbl> <chr>     <chr>  <dbl>   <dbl>         <dbl> <chr>                
## 1 2024…     1 Pl12_M_0… a702…  0.936       0          0    null                 
## 2 6282…     5 Pl12_M_0… a702…  3.18        0          0    null                 
## 3 7022…     9 Pl12_M_0… a702…  5.80       12          3.89 0.46097413           
## # ℹ 12 more variables: last_child <chr>, insertion_last_child <chr>, LRL <dbl>,
## #   LRno <dbl>, genotype <chr>, condition <fct>, plate <chr>, replicate <chr>,
## #   TRS <dbl>, aLRL <dbl>, MRpLRL <dbl>, root_name2 <chr>
temp2$condition[1]
## [1] M
## Levels: C M
temp_MR <- temp2[,c("day", "length")]
plot(temp_MR$length~ temp_MR$day)

plot(temp_MR$length~ temp_MR$day)
# let's add the regression line to this graph
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  
##      0.2663       0.6080
summary(MR_model)
## 
## Call:
## lm(formula = temp_MR$length ~ temp_MR$day)
## 
## Residuals:
##        1        2        3 
##  0.06156 -0.12312  0.06156 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)  0.26629    0.15919   1.673   0.3430  
## temp_MR$day  0.60802    0.02666  22.810   0.0279 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1508 on 1 degrees of freedom
## Multiple R-squared:  0.9981, Adjusted R-squared:  0.9962 
## F-statistic: 520.3 on 1 and 1 DF,  p-value: 0.02789
MR_model$coefficients[[2]]
## [1] 0.6080217
MR_growth_rate <- MR_model$coefficients[[2]]
temp2
## # A tibble: 3 × 20
##   image   day root_name root  length n_child child_density insertion_first_child
##   <chr> <dbl> <chr>     <chr>  <dbl>   <dbl>         <dbl> <chr>                
## 1 2024…     1 Pl12_M_0… a702…  0.936       0          0    null                 
## 2 6282…     5 Pl12_M_0… a702…  3.18        0          0    null                 
## 3 7022…     9 Pl12_M_0… a702…  5.80       12          3.89 0.46097413           
## # ℹ 12 more variables: last_child <chr>, insertion_last_child <chr>, LRL <dbl>,
## #   LRno <dbl>, genotype <chr>, condition <fct>, plate <chr>, replicate <chr>,
## #   TRS <dbl>, aLRL <dbl>, MRpLRL <dbl>, root_name2 <chr>
LR_temp <- temp2[,c("day", "LRno", "aLRL")]
LR_temp2 <- na.omit(LR_temp)
LR_temp2
## # A tibble: 1 × 3
##     day  LRno  aLRL
##   <dbl> <dbl> <dbl>
## 1     9    12 0.276
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  
##           12            NA
summary(LRno_model)
## 
## Call:
## lm(formula = LR_temp2$LRno ~ LR_temp2$day)
## 
## Residuals:
## ALL 1 residuals are 0: no residual degrees of freedom!
## 
## Coefficients: (1 not defined because of singularities)
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept)        12        NaN     NaN      NaN
## LR_temp2$day       NA         NA      NA       NA
## 
## Residual standard error: NaN on 0 degrees of freedom
LRno_increase <- as.numeric(as.character(LRno_model$coefficients[[2]]))
LRno_increase
## [1] NA
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.276            NA
summary(aLRL_model)
## 
## Call:
## lm(formula = LR_temp2$aLRL ~ LR_temp2$day)
## 
## Residuals:
## ALL 1 residuals are 0: no residual degrees of freedom!
## 
## Coefficients: (1 not defined because of singularities)
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept)     0.276        NaN     NaN      NaN
## LR_temp2$day       NA         NA      NA       NA
## 
## Residual standard error: NaN on 0 degrees of freedom
aLRL_growth <- as.numeric(as.character(aLRL_model$coefficients[[2]]))
aLRL_growth
## [1] NA
temp2$condition[1]
## [1] M
## Levels: C M
temp2$condition[1][1]
## [1] M
## Levels: C M
names <- c(text="root_name", "genotype", "condition", "MR.delta", "LRno.delta", "aLRL.delta")
growth_factors <- data.frame()
growth_factors
## data frame with 0 columns and 0 rows
for (k in names) growth_factors[[k]] <- as.character()

growth_factors[1,1] <- temp2$root_name[1]
growth_factors[1,2] <- temp2$genotype[1]
growth_factors[1,3] <- temp2$condition[[1]]
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
##     root_name genotype condition  MR.delta LRno.delta aLRL.delta
## 1 Pl12_M_01_3       01         2 0.6080217       <NA>       <NA>
length(unique(MR_both_geno$root_name))
## [1] 259
for(e in 1:259){
  temp1 <- subset(MR_both_geno, MR_both_geno$root_name == unique(MR_both_geno$root_name)[e])
  temp2 <- temp1[order(temp1$day),]
  temp2
  
  if(dim(temp2)[1] > 2){
  ############ MR calculations
  temp_MR <- temp2[,c("day", "length")]
  temp_MR$MRdouble <- "no"
  for(i in 2:nrow(temp_MR)){
    # we want the root to be at least 1 mm larger than the previous day - all the other ones will just indicate noise:
   if(temp_MR$length[i] <= temp_MR$length[i-1]+0.09){
    temp_MR$MRdouble[i] <- "yes"   
   } else{temp_MR$MRdouble[i] <- "no"}}
  temp_MR2 <- subset(temp_MR, temp_MR$MRdouble == "no")
  temp_MR2
  MR_model <- lm(temp_MR2$length~ temp_MR2$day)
  MR_growth_rate <- MR_model$coefficients[[2]]
  MR_growth_rate }else{
  MR_growth_rate <- 0  
  }
  ############ LRno calculations
  LR_temp <- temp2[,c("day", "LRno", "aLRL")]
  LR_temp2 <- na.omit(LR_temp)
  LR_temp2
  dim(LR_temp2)
  
  ####################### safety precaution to calculate LR growth rate only for the plants that have LR at least for two days: 
  if(dim(LR_temp2)[1] > 1){
  LRno_model <- lm(LR_temp2$LRno ~ LR_temp2$day)
  LRno_increase <- as.numeric(as.character(LRno_model$coefficients[[2]]))

  ############ aLRL calculations
  aLRL_model <- lm(LR_temp2$aLRL ~ LR_temp2$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] <- temp2$genotype[1]
  growth_factors[e,3] <- 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
##        root_name genotype condition          MR.delta LRno.delta
## 1    Pl4_M_01_04       01         2                 0          0
## 2    Pl8_C_01_01       01         1       0.813158725        4.5
## 3    Pl8_C_01_04       01         1       0.710006275       2.25
## 4    Pl8_C_01_02       01         1      0.8466061925       4.25
## 5    Pl9_C_01_01       01         1       0.617869375          1
## 6    Pl9_C_01_02       01         1       0.840557725       4.25
## 7    Pl1_M_01_04       01         2      0.2859252375          0
## 8    Pl1_M_01_01       01         2      0.3993961875          0
## 9    Pl1_M_01_03       01         2      0.1940168625          0
## 10   Pl6_C_01_03       01         1       0.536725875          0
## 11   Pl6_C_01_02       01         1      0.5971264625          0
## 12  Pl10_M_01_04       01         2                 0          0
## 13  Pl10_M_01_03       01         2                 0          0
## 14  Pl10_M_01_02       01         2                 0          0
## 15  Pl10_M_01_01       01         2                 0          0
## 16  Pl11_M_01_01       01         2        0.42590645          0
## 17  Pl11_M_01_03       01         2         0.5157705          0
## 18   Pl7_C_01_04       01         1       0.403761675          0
## 19   Pl7_C_01_03       01         1       0.502998425          0
## 20   Pl7_C_01_01       01         1     0.54359619375          0
## 21  Pl12_M_01_04       01         2                 0          0
## 22   Pl12_M_01_3       01         2         0.6080217          0
## 23  Pl12_M_01_01       01         2      0.4099114875          0
## 24  Pl12_M_01_02       01         2       0.441791725          0
## 25   Pl8_C_01_03       01         1       0.591046995          0
## 26   Pl9_C_01_04       01         1        0.74088145          0
## 27   Pl9_C_01_03       01         1         0.7701522          0
## 28  Pl10_C_01_01       01         1                 0          0
## 29   Pl1_M_01_02       01         2       0.140476945          0
## 30   Pl7_C_01_02       01         1       0.251226295          0
## 31   Pl6_C_01_04       01         1      0.4352060875          0
## 32   Pl6_C_01_01       01         1       0.250516125          0
## 33  Pl11_M_01_04       01         2                 0          0
## 34  Pl11_M_01_02       01         2                 0          0
## 35  Pl10_C_01_04       01         1                 0          0
## 36  Pl10_C_01_03       01         1                 0          0
## 37  Pl10_C_01_02       01         1                 0          0
## 38   Pl8_C_02_02       02         1         0.8309767       3.25
## 39   Pl9_C_02_04       02         1      0.8403002125          4
## 40   Pl9_C_02_03       02         1      0.8994527875          2
## 41   Pl1_M_02_03       02         2       0.345294135          0
## 42   Pl1_M_02_02       02         2       0.185601775          0
## 43   Pl1_M_02_04       02         2       0.385113505          0
## 44   Pl1_M_02_01       02         2        0.34125653          0
## 45   Pl6_C_02_02       02         1         0.5317902          0
## 46   Pl6_C_02_04       02         1       0.169884475          0
## 47   Pl6_C_02_03       02         1      0.4919284875          0
## 48  Pl10_M_02_04       02         2                 0          0
## 49  Pl10_M_02_03       02         2                 0          0
## 50  Pl10_M_02_02       02         2                 0          0
## 51  Pl10_M_02_01       02         2                 0          0
## 52  Pl11_M_02_03       02         2      0.3819924875          0
## 53  Pl11_M_02_02       02         2     0.43507329625          0
## 54   Pl7_C_02_01       02         1          0.529759          0
## 55  Pl12_M_02_04       02         2         0.5745379          0
## 56  Pl12_M_02_03       02         2         0.4310821          0
## 57  Pl12_M_02_02       02         2      0.3916473875          0
## 58  Pl12_M_02_01       02         2      0.4807238075          0
## 59   Pl8_C_02_04       02         1      0.5845632375          0
## 60   Pl8_C_02_03       02         1 0.693181277954546          0
## 61   Pl8_C_02_01       02         1      0.6194379875          0
## 62   Pl9_C_02_02       02         1      0.5574316175          0
## 63   Pl9_C_02_01       02         1       0.962761725          0
## 64  Pl10_C_02_01       02         1                 0          0
## 65   Pl7_C_02_04       02         1       0.398648825          0
## 66   Pl7_C_02_03       02         1     0.27379739375          0
## 67   Pl7_C_02_02       02         1         0.3684457          0
## 68   Pl6_C_02_01       02         1      0.4529618875          0
## 69  Pl11_M_02_04       02         2       0.409647375          0
## 70  Pl11_M_02_01       02         2      0.3578801125          0
## 71  Pl10_C_02_04       02         1                 0          0
## 72  Pl10_C_02_03       02         1                 0          0
## 73  Pl10_C_02_02       02         1                 0          0
## 74  Pl16_C_03_02       03         1       0.928972825          0
## 75  Pl16_C_03_01       03         1     0.80565257875          0
## 76   Pl9_C_03_01       03         1       0.509486225       3.25
## 77   Pl9_C_03_02       03         1       0.568553245          1
## 78  Pl15_C_03_04       03         1         0.9316032       6.25
## 79  Pl12_M_03_04       03         2         0.4806823          0
## 80  Pl12_M_03_03       03         2       0.476534975          0
## 81   Pl8_C_03_04       03         1      0.5346180875          0
## 82   Pl8_C_03_03       03         1     0.57301961875          0
## 83   Pl8_C_03_02       03         1        0.57839092          0
## 84   Pl8_C_03_01       03         1         0.5683905          0
## 85   Pl9_C_03_04       03         1       0.589936025          0
## 86  Pl13_M_03_03       03         2     0.60909883375          0
## 87  Pl13_M_03_02       03         2      0.5748877375          0
## 88  Pl13_M_03_01       03         2      0.4479638175          0
## 89  Pl14_M_03_02       03         2        0.50800475          0
## 90  Pl14_M_03_04       03         2          0.340379          0
## 91  Pl14_M_03_01       03         2      0.5724312125          0
## 92  Pl15_C_03_03       03         1        0.62774635          0
## 93  Pl12_M_03_02       03         2       0.231007875          0
## 94  Pl12_M_03_01       03         2     0.37259555375          0
## 95   Pl9_C_03_03       03         1       0.488624925          0
## 96  Pl13_M_03_04       03         2      0.3598815375          0
## 97  Pl10_M_03_04       03         2                 0          0
## 98  Pl10_M_03_03       03         2                 0          0
## 99  Pl10_M_03_02       03         2                 0          0
## 100 Pl10_M_03_01       03         2                 0          0
## 101 Pl14_M_03_03       03         2                 0          0
## 102 Pl15_C_03_02       03         1       0.437783855          0
## 103 Pl15_C_03_01       03         1     0.55199556625          0
## 104 Pl12_M_04_03       04         2      0.4833221875       1.75
## 105 Pl16_C_04_04       04         1        0.76160152          0
## 106 Pl16_C_04_03       04         1     0.87578631875        5.5
## 107 Pl16_C_04_02       04         1         0.7195959          5
## 108  Pl8_C_04_02       04         1       0.480335075          2
## 109 Pl13_M_04_04       04         2       0.602540475       2.25
## 110 Pl13_M_04_02       04         2         0.5412957          2
## 111 Pl10_M_04_02       04         2                 0          0
## 112 Pl10_M_04_01       04         2                 0          0
## 113 Pl15_C_04_02       04         1      0.8344400675       2.75
## 114 Pl12_M_04_04       04         2        0.48705905          0
## 115 Pl12_M_04_02       04         2       0.454433075          0
## 116  Pl8_C_04_04       04         1                 0          0
## 117  Pl8_C_04_03       04         1                 0          0
## 118  Pl9_C_04_04       04         1     0.61172129375          0
## 119  Pl9_C_04_03       04         1     0.59023315875          0
## 120  Pl9_C_04_02       04         1      0.5576237125          0
## 121  Pl9_C_04_01       04         1      0.5629938925          0
## 122 Pl13_M_04_03       04         2        0.45430235          0
## 123 Pl14_M_04_02       04         2      0.3788431375          0
## 124 Pl14_M_04_04       04         2      0.5239000625          0
## 125 Pl14_M_04_03       04         2      0.3860160875          0
## 126 Pl14_M_04_01       04         2      0.3314047875          0
## 127 Pl15_C_04_04       04         1     0.65063922125          0
## 128 Pl15_C_04_03       04         1       0.751748325          0
## 129 Pl15_C_04_01       04         1      0.6264209125          0
## 130 Pl12_M_04_01       04         2     0.46744599375          0
## 131 Pl16_C_04_01       04         1      0.4034346825          0
## 132  Pl8_C_04_01       04         1                 0          0
## 133 Pl10_M_04_04       04         2                 0          0
## 134 Pl10_M_04_03       04         2                 0          0
## 135 MPl8_C_04_04       04         1                 0          0
## 136 Pl10_C_04_04       04         1                 0          0
## 137 Pl10_C_04_03       04         1                 0          0
## 138 Pl10_C_04_02       04         1                 0          0
## 139 Pl10_C_04_01       04         1                 0          0
## 140 Pl16_C_05_04       05         1        0.64243801          0
## 141  Pl2_C_05_03       05         1       0.845673455          5
## 142  Pl3_C_05_03       05         1      0.8403463625        3.5
## 143  Pl4_M_05_04       05         2     0.46809217875          0
## 144  Pl4_M_05_03       05         2       0.369825425          0
## 145  Pl4_M_05_02       05         2        0.36377047          0
## 146  Pl4_M_05_01       05         2       0.502583475          0
## 147  Pl5_M_05_02       05         2     0.49386306875          0
## 148  Pl5_M_05_03       05         2     0.48627644375          0
## 149  Pl5_M_05_01       05         2     0.37578822875          0
## 150  Pl2_C_05_02       05         1                 0          0
## 151  Pl2_C_05_04       05         1      0.6202776325          0
## 152  Pl2_C_05_01       05         1                 0          0
## 153  Pl3_C_05_01       05         1      0.7456794325          0
## 154  Pl3_C_05_04       05         1      0.8046370625          0
## 155  Pl3_C_05_02       05         1      0.7191326125          0
## 156 Pl15_C_05_02       05         1     0.49424881625          0
## 157 Pl15_C_05_04       05         1        0.61359795          0
## 158 Pl15_C_05_03       05         1     0.47535795875          0
## 159 Pl15_C_05_01       05         1     0.58257980125          0
## 160 Pl16_C_05_03       05         1       0.449585725          0
## 161 Pl16_C_05_02       05         1      0.2159754375          0
## 162 Pl16_C_05_01       05         1       0.297969165          0
## 163  Pl5_M_05_04       05         2        0.33121922          0
## 164 Pl02_C_05_02       05         1                 0          0
## 165 Pl02_C_05_01       05         1                 0          0
## 166 Pl16_C_06_04       06         1      0.5975780125          0
## 167 Pl16_C_06_03       06         1     0.58101372125          0
## 168 Pl16_C_06_02       06         1     0.60594389625        2.5
## 169 Pl16_C_06_01       06         1      0.7712185375          0
## 170  Pl5_M_06_04       06         2      0.7791661625        2.5
## 171  Pl5_M_06_02       06         2       0.682791045       2.75
## 172  Pl2_C_06_01       06         1      0.7774068875        3.5
## 173  Pl2_C_06_04       06         1      0.9291828375       5.75
## 174  Pl2_C_06_02       06         1      0.8567024125        4.5
## 175 Pl15_C_06_04       06         1       0.590455505        3.5
## 176  Pl4_M_06_04       06         2        0.45032603          0
## 177  Pl4_M_06_03       06         2      0.6110591875          0
## 178  Pl4_M_06_02       06         2       0.224844725          0
## 179  Pl4_M_06_01       06         2      0.5782555625          0
## 180  Pl5_M_06_03       06         2      0.6026246925          0
## 181  Pl5_M_06_01       06         2         0.3778364          0
## 182 Pl13_M_06_02       06         2       0.432037675          0
## 183 Pl14_M_06_04       06         2       0.369138575          0
## 184 Pl14_M_06_01       06         2      0.3215934575          0
## 185  Pl2_C_06_03       06         1     0.86997337875          0
## 186  Pl3_C_06_04       06         1        0.62828125          0
## 187  Pl3_C_06_03       06         1       0.724494425          0
## 188  Pl3_C_06_02       06         1        0.78818275          0
## 189  Pl3_C_06_01       06         1        0.85085735          0
## 190 Pl15_C_06_02       06         1      0.5234183375          0
## 191 Pl15_C_06_01       06         1     0.65049308375          0
## 192 Pl13_M_06_01       06         2     0.27841551875          0
## 193 Pl14_M_06_03       06         2     0.35816954125          0
## 194 Pl14_M_06_02       06         2      0.2331369125          0
## 195 Pl15_C_06_03       06         1       0.310479015          0
## 196  Pl1_M_07_04       07         2     0.46381331625          0
## 197  Pl1_M_07_02       07         2      0.5907877625          0
## 198  Pl1_M_07_01       07         2      0.5409841125          0
## 199  Pl1_M_07_03       07         2      0.4824966125          0
## 200  Pl6_C_07_04       07         1     0.81682194625          0
## 201  Pl6_C_07_03       07         1      1.0188094875       3.75
## 202  Pl6_C_07_02       07         1     0.55674614375          0
## 203  Pl6_C_07_01       07         1      0.7642341875          0
## 204  Pl2_C_07_03       07         1     0.66539724375          1
## 205  Pl2_C_07_01       07         1     0.67488196625          4
## 206  Pl3_C_07_02       07         1     0.75136841875          3
## 207 Pl11_M_07_04       07         2     0.46209546625          0
## 208 Pl11_M_07_03       07         2     0.65128393125          0
## 209 Pl11_M_07_02       07         2      0.4958353125          0
## 210 Pl11_M_07_01       07         2       0.549309625          0
## 211  Pl7_C_07_04       07         1        0.67212965          0
## 212  Pl7_C_07_03       07         1        0.56524455          0
## 213  Pl7_C_07_02       07         1        0.61659525          0
## 214  Pl7_C_07_01       07         1       0.593791975          0
## 215  Pl4_M_07_04       07         2       0.610299695          0
## 216  Pl4_M_07_03       07         2     0.69308045375          0
## 217  Pl4_M_07_02       07         2     0.63670645375          0
## 218  Pl4_M_07_01       07         2        0.58598602          0
## 219  Pl5_M_07_04       07         2      0.6112187625          0
## 220  Pl5_M_07_03       07         2     0.66664569625          0
## 221  Pl5_M_07_02       07         2      0.5571907425          0
## 222  Pl5_M_07_01       07         2     0.54080799625          0
## 223  Pl2_C_07_04       07         1      0.6174833875          0
## 224  Pl2_C_07_02       07         1       0.710517475          0
## 225  Pl3_C_07_04       07         1      0.6408862125          0
## 226  Pl3_C_07_03       07         1      0.6772189625          0
## 227  Pl3_C_07_01       07         1        0.72082412          0
## 228  Pl1_M_08_02       08         2        0.52466548          0
## 229  Pl1_M_08_03       08         2       0.508775925          0
## 230  Pl1_M_08_01       08         2      0.5356339875          0
## 231  Pl1_M_08_04       08         2      0.5920565125          0
## 232  Pl5_M_08_03       08         2     0.55415963125       1.25
## 233  Pl6_C_08_04       08         1       0.566273915          0
## 234  Pl6_C_08_03       08         1      0.8430136125          0
## 235  Pl6_C_08_02       08         1      0.7740699125          0
## 236  Pl6_C_08_01       08         1     0.65329229375       3.25
## 237  Pl3_C_08_04       08         1     0.63008300375          4
## 238  Pl3_C_08_03       08         1     0.54697688375          2
## 239 Pl11_M_08_04       08         2      0.5114103075          0
## 240 Pl11_M_08_03       08         2     0.59807305375          0
## 241 Pl11_M_08_02       08         2        0.49575432          0
## 242 Pl11_M_08_01       08         2     0.67394106875       2.25
## 243  Pl7_C_08_04       08         1        0.81965462          0
## 244  Pl7_C_08_03       08         1        0.92487395          0
## 245  Pl7_C_08_02       08         1     0.98616646625          0
## 246  Pl7_C_08_01       08         1     0.88724672125          0
## 247  Pl4_M_08_04       08         2        0.61069795          0
## 248  Pl4_M_08_03       08         2      0.5930884625          0
## 249  Pl4_M_08_02       08         2       0.387557745          0
## 250  Pl4_M_08_01       08         2        0.55736775          0
## 251  Pl5_M_08_01       08         2       0.588690925          0
## 252  Pl5_M_08_04       08         2        0.52489527          0
## 253  Pl5_M_08_02       08         2       0.666429645          0
## 254  Pl2_C_08_04       08         1         0.6272715          0
## 255  Pl2_C_08_03       08         1        0.63528245          0
## 256  Pl2_C_08_02       08         1         0.7086221          0
## 257  Pl2_C_08_01       08         1       0.691633475          0
## 258  Pl3_C_08_01       08         1      0.6411387825          0
## 259  Pl3_C_08_02       08         1      0.5919273375          0
##              aLRL.delta
## 1                     0
## 2     0.109739870407895
## 3        0.132206579125
## 4     0.098935055736842
## 5          0.0634006866
## 6    0.0995367347368421
## 7                     0
## 8                     0
## 9                     0
## 10                    0
## 11                    0
## 12                    0
## 13                    0
## 14                    0
## 15                    0
## 16                    0
## 17                    0
## 18                    0
## 19                    0
## 20                    0
## 21                    0
## 22                    0
## 23                    0
## 24                    0
## 25                    0
## 26                    0
## 27                    0
## 28                    0
## 29                    0
## 30                    0
## 31                    0
## 32                    0
## 33                    0
## 34                    0
## 35                    0
## 36                    0
## 37                    0
## 38    0.117982811446429
## 39    0.120255050411765
## 40   0.0584443816388889
## 41                    0
## 42                    0
## 43                    0
## 44                    0
## 45                    0
## 46                    0
## 47                    0
## 48                    0
## 49                    0
## 50                    0
## 51                    0
## 52                    0
## 53                    0
## 54                    0
## 55                    0
## 56                    0
## 57                    0
## 58                    0
## 59                    0
## 60                    0
## 61                    0
## 62                    0
## 63                    0
## 64                    0
## 65                    0
## 66                    0
## 67                    0
## 68                    0
## 69                    0
## 70                    0
## 71                    0
## 72                    0
## 73                    0
## 74                    0
## 75                    0
## 76         0.0868226815
## 77          0.082140183
## 78   0.0778175775096154
## 79                    0
## 80                    0
## 81                    0
## 82                    0
## 83                    0
## 84                    0
## 85                    0
## 86                    0
## 87                    0
## 88                    0
## 89                    0
## 90                    0
## 91                    0
## 92                    0
## 93                    0
## 94                    0
## 95                    0
## 96                    0
## 97                    0
## 98                    0
## 99                    0
## 100                   0
## 101                   0
## 102                   0
## 103                   0
## 104    0.05640729596875
## 105                   0
## 106    0.12422206651087
## 107   0.112294295654762
## 108      0.103925753275
## 109        0.0881391596
## 110       0.04294646575
## 111                   0
## 112                   0
## 113   0.112859666211538
## 114                   0
## 115                   0
## 116                   0
## 117                   0
## 118                   0
## 119                   0
## 120                   0
## 121                   0
## 122                   0
## 123                   0
## 124                   0
## 125                   0
## 126                   0
## 127                   0
## 128                   0
## 129                   0
## 130                   0
## 131                   0
## 132                   0
## 133                   0
## 134                   0
## 135                   0
## 136                   0
## 137                   0
## 138                   0
## 139                   0
## 140                   0
## 141 -0.0199634288690476
## 142  0.0991977055166666
## 143                   0
## 144                   0
## 145                   0
## 146                   0
## 147                   0
## 148                   0
## 149                   0
## 150                   0
## 151                   0
## 152                   0
## 153                   0
## 154                   0
## 155                   0
## 156                   0
## 157                   0
## 158                   0
## 159                   0
## 160                   0
## 161                   0
## 162                   0
## 163                   0
## 164                   0
## 165                   0
## 166                   0
## 167                   0
## 168   0.152144571019231
## 169                   0
## 170  0.0877431929583333
## 171  0.0434172150416667
## 172        0.1029270736
## 173 0.00533032031249999
## 174     0.1319099284375
## 175  0.0495053082833333
## 176                   0
## 177                   0
## 178                   0
## 179                   0
## 180                   0
## 181                   0
## 182                   0
## 183                   0
## 184                   0
## 185                   0
## 186                   0
## 187                   0
## 188                   0
## 189                   0
## 190                   0
## 191                   0
## 192                   0
## 193                   0
## 194                   0
## 195                   0
## 196                   0
## 197                   0
## 198                   0
## 199                   0
## 200                   0
## 201    0.05821575040625
## 202                   0
## 203                   0
## 204        0.1179209265
## 205   0.119499510617647
## 206   0.119461052089286
## 207                   0
## 208                   0
## 209                   0
## 210                   0
## 211                   0
## 212                   0
## 213                   0
## 214                   0
## 215                   0
## 216                   0
## 217                   0
## 218                   0
## 219                   0
## 220                   0
## 221                   0
## 222                   0
## 223                   0
## 224                   0
## 225                   0
## 226                   0
## 227                   0
## 228                   0
## 229                   0
## 230                   0
## 231                   0
## 232  0.0723639170833333
## 233                   0
## 234                   0
## 235                   0
## 236        0.1036340475
## 237   0.104998590308824
## 238   0.118904786722222
## 239                   0
## 240                   0
## 241                   0
## 242        0.0706312206
## 243                   0
## 244                   0
## 245                   0
## 246                   0
## 247                   0
## 248                   0
## 249                   0
## 250                   0
## 251                   0
## 252                   0
## 253                   0
## 254                   0
## 255                   0
## 256                   0
## 257                   0
## 258                   0
## 259                   0
growth_factors <- subset(growth_factors, growth_factors$MR.delta > 0)
growth_factors
##        root_name genotype condition          MR.delta LRno.delta
## 2    Pl8_C_01_01       01         1       0.813158725        4.5
## 3    Pl8_C_01_04       01         1       0.710006275       2.25
## 4    Pl8_C_01_02       01         1      0.8466061925       4.25
## 5    Pl9_C_01_01       01         1       0.617869375          1
## 6    Pl9_C_01_02       01         1       0.840557725       4.25
## 7    Pl1_M_01_04       01         2      0.2859252375          0
## 8    Pl1_M_01_01       01         2      0.3993961875          0
## 9    Pl1_M_01_03       01         2      0.1940168625          0
## 10   Pl6_C_01_03       01         1       0.536725875          0
## 11   Pl6_C_01_02       01         1      0.5971264625          0
## 16  Pl11_M_01_01       01         2        0.42590645          0
## 17  Pl11_M_01_03       01         2         0.5157705          0
## 18   Pl7_C_01_04       01         1       0.403761675          0
## 19   Pl7_C_01_03       01         1       0.502998425          0
## 20   Pl7_C_01_01       01         1     0.54359619375          0
## 22   Pl12_M_01_3       01         2         0.6080217          0
## 23  Pl12_M_01_01       01         2      0.4099114875          0
## 24  Pl12_M_01_02       01         2       0.441791725          0
## 25   Pl8_C_01_03       01         1       0.591046995          0
## 26   Pl9_C_01_04       01         1        0.74088145          0
## 27   Pl9_C_01_03       01         1         0.7701522          0
## 29   Pl1_M_01_02       01         2       0.140476945          0
## 30   Pl7_C_01_02       01         1       0.251226295          0
## 31   Pl6_C_01_04       01         1      0.4352060875          0
## 32   Pl6_C_01_01       01         1       0.250516125          0
## 38   Pl8_C_02_02       02         1         0.8309767       3.25
## 39   Pl9_C_02_04       02         1      0.8403002125          4
## 40   Pl9_C_02_03       02         1      0.8994527875          2
## 41   Pl1_M_02_03       02         2       0.345294135          0
## 42   Pl1_M_02_02       02         2       0.185601775          0
## 43   Pl1_M_02_04       02         2       0.385113505          0
## 44   Pl1_M_02_01       02         2        0.34125653          0
## 45   Pl6_C_02_02       02         1         0.5317902          0
## 46   Pl6_C_02_04       02         1       0.169884475          0
## 47   Pl6_C_02_03       02         1      0.4919284875          0
## 52  Pl11_M_02_03       02         2      0.3819924875          0
## 53  Pl11_M_02_02       02         2     0.43507329625          0
## 54   Pl7_C_02_01       02         1          0.529759          0
## 55  Pl12_M_02_04       02         2         0.5745379          0
## 56  Pl12_M_02_03       02         2         0.4310821          0
## 57  Pl12_M_02_02       02         2      0.3916473875          0
## 58  Pl12_M_02_01       02         2      0.4807238075          0
## 59   Pl8_C_02_04       02         1      0.5845632375          0
## 60   Pl8_C_02_03       02         1 0.693181277954546          0
## 61   Pl8_C_02_01       02         1      0.6194379875          0
## 62   Pl9_C_02_02       02         1      0.5574316175          0
## 63   Pl9_C_02_01       02         1       0.962761725          0
## 65   Pl7_C_02_04       02         1       0.398648825          0
## 66   Pl7_C_02_03       02         1     0.27379739375          0
## 67   Pl7_C_02_02       02         1         0.3684457          0
## 68   Pl6_C_02_01       02         1      0.4529618875          0
## 69  Pl11_M_02_04       02         2       0.409647375          0
## 70  Pl11_M_02_01       02         2      0.3578801125          0
## 74  Pl16_C_03_02       03         1       0.928972825          0
## 75  Pl16_C_03_01       03         1     0.80565257875          0
## 76   Pl9_C_03_01       03         1       0.509486225       3.25
## 77   Pl9_C_03_02       03         1       0.568553245          1
## 78  Pl15_C_03_04       03         1         0.9316032       6.25
## 79  Pl12_M_03_04       03         2         0.4806823          0
## 80  Pl12_M_03_03       03         2       0.476534975          0
## 81   Pl8_C_03_04       03         1      0.5346180875          0
## 82   Pl8_C_03_03       03         1     0.57301961875          0
## 83   Pl8_C_03_02       03         1        0.57839092          0
## 84   Pl8_C_03_01       03         1         0.5683905          0
## 85   Pl9_C_03_04       03         1       0.589936025          0
## 86  Pl13_M_03_03       03         2     0.60909883375          0
## 87  Pl13_M_03_02       03         2      0.5748877375          0
## 88  Pl13_M_03_01       03         2      0.4479638175          0
## 89  Pl14_M_03_02       03         2        0.50800475          0
## 90  Pl14_M_03_04       03         2          0.340379          0
## 91  Pl14_M_03_01       03         2      0.5724312125          0
## 92  Pl15_C_03_03       03         1        0.62774635          0
## 93  Pl12_M_03_02       03         2       0.231007875          0
## 94  Pl12_M_03_01       03         2     0.37259555375          0
## 95   Pl9_C_03_03       03         1       0.488624925          0
## 96  Pl13_M_03_04       03         2      0.3598815375          0
## 102 Pl15_C_03_02       03         1       0.437783855          0
## 103 Pl15_C_03_01       03         1     0.55199556625          0
## 104 Pl12_M_04_03       04         2      0.4833221875       1.75
## 105 Pl16_C_04_04       04         1        0.76160152          0
## 106 Pl16_C_04_03       04         1     0.87578631875        5.5
## 107 Pl16_C_04_02       04         1         0.7195959          5
## 108  Pl8_C_04_02       04         1       0.480335075          2
## 109 Pl13_M_04_04       04         2       0.602540475       2.25
## 110 Pl13_M_04_02       04         2         0.5412957          2
## 113 Pl15_C_04_02       04         1      0.8344400675       2.75
## 114 Pl12_M_04_04       04         2        0.48705905          0
## 115 Pl12_M_04_02       04         2       0.454433075          0
## 118  Pl9_C_04_04       04         1     0.61172129375          0
## 119  Pl9_C_04_03       04         1     0.59023315875          0
## 120  Pl9_C_04_02       04         1      0.5576237125          0
## 121  Pl9_C_04_01       04         1      0.5629938925          0
## 122 Pl13_M_04_03       04         2        0.45430235          0
## 123 Pl14_M_04_02       04         2      0.3788431375          0
## 124 Pl14_M_04_04       04         2      0.5239000625          0
## 125 Pl14_M_04_03       04         2      0.3860160875          0
## 126 Pl14_M_04_01       04         2      0.3314047875          0
## 127 Pl15_C_04_04       04         1     0.65063922125          0
## 128 Pl15_C_04_03       04         1       0.751748325          0
## 129 Pl15_C_04_01       04         1      0.6264209125          0
## 130 Pl12_M_04_01       04         2     0.46744599375          0
## 131 Pl16_C_04_01       04         1      0.4034346825          0
## 140 Pl16_C_05_04       05         1        0.64243801          0
## 141  Pl2_C_05_03       05         1       0.845673455          5
## 142  Pl3_C_05_03       05         1      0.8403463625        3.5
## 143  Pl4_M_05_04       05         2     0.46809217875          0
## 144  Pl4_M_05_03       05         2       0.369825425          0
## 145  Pl4_M_05_02       05         2        0.36377047          0
## 146  Pl4_M_05_01       05         2       0.502583475          0
## 147  Pl5_M_05_02       05         2     0.49386306875          0
## 148  Pl5_M_05_03       05         2     0.48627644375          0
## 149  Pl5_M_05_01       05         2     0.37578822875          0
## 151  Pl2_C_05_04       05         1      0.6202776325          0
## 153  Pl3_C_05_01       05         1      0.7456794325          0
## 154  Pl3_C_05_04       05         1      0.8046370625          0
## 155  Pl3_C_05_02       05         1      0.7191326125          0
## 156 Pl15_C_05_02       05         1     0.49424881625          0
## 157 Pl15_C_05_04       05         1        0.61359795          0
## 158 Pl15_C_05_03       05         1     0.47535795875          0
## 159 Pl15_C_05_01       05         1     0.58257980125          0
## 160 Pl16_C_05_03       05         1       0.449585725          0
## 161 Pl16_C_05_02       05         1      0.2159754375          0
## 162 Pl16_C_05_01       05         1       0.297969165          0
## 163  Pl5_M_05_04       05         2        0.33121922          0
## 166 Pl16_C_06_04       06         1      0.5975780125          0
## 167 Pl16_C_06_03       06         1     0.58101372125          0
## 168 Pl16_C_06_02       06         1     0.60594389625        2.5
## 169 Pl16_C_06_01       06         1      0.7712185375          0
## 170  Pl5_M_06_04       06         2      0.7791661625        2.5
## 171  Pl5_M_06_02       06         2       0.682791045       2.75
## 172  Pl2_C_06_01       06         1      0.7774068875        3.5
## 173  Pl2_C_06_04       06         1      0.9291828375       5.75
## 174  Pl2_C_06_02       06         1      0.8567024125        4.5
## 175 Pl15_C_06_04       06         1       0.590455505        3.5
## 176  Pl4_M_06_04       06         2        0.45032603          0
## 177  Pl4_M_06_03       06         2      0.6110591875          0
## 178  Pl4_M_06_02       06         2       0.224844725          0
## 179  Pl4_M_06_01       06         2      0.5782555625          0
## 180  Pl5_M_06_03       06         2      0.6026246925          0
## 181  Pl5_M_06_01       06         2         0.3778364          0
## 182 Pl13_M_06_02       06         2       0.432037675          0
## 183 Pl14_M_06_04       06         2       0.369138575          0
## 184 Pl14_M_06_01       06         2      0.3215934575          0
## 185  Pl2_C_06_03       06         1     0.86997337875          0
## 186  Pl3_C_06_04       06         1        0.62828125          0
## 187  Pl3_C_06_03       06         1       0.724494425          0
## 188  Pl3_C_06_02       06         1        0.78818275          0
## 189  Pl3_C_06_01       06         1        0.85085735          0
## 190 Pl15_C_06_02       06         1      0.5234183375          0
## 191 Pl15_C_06_01       06         1     0.65049308375          0
## 192 Pl13_M_06_01       06         2     0.27841551875          0
## 193 Pl14_M_06_03       06         2     0.35816954125          0
## 194 Pl14_M_06_02       06         2      0.2331369125          0
## 195 Pl15_C_06_03       06         1       0.310479015          0
## 196  Pl1_M_07_04       07         2     0.46381331625          0
## 197  Pl1_M_07_02       07         2      0.5907877625          0
## 198  Pl1_M_07_01       07         2      0.5409841125          0
## 199  Pl1_M_07_03       07         2      0.4824966125          0
## 200  Pl6_C_07_04       07         1     0.81682194625          0
## 201  Pl6_C_07_03       07         1      1.0188094875       3.75
## 202  Pl6_C_07_02       07         1     0.55674614375          0
## 203  Pl6_C_07_01       07         1      0.7642341875          0
## 204  Pl2_C_07_03       07         1     0.66539724375          1
## 205  Pl2_C_07_01       07         1     0.67488196625          4
## 206  Pl3_C_07_02       07         1     0.75136841875          3
## 207 Pl11_M_07_04       07         2     0.46209546625          0
## 208 Pl11_M_07_03       07         2     0.65128393125          0
## 209 Pl11_M_07_02       07         2      0.4958353125          0
## 210 Pl11_M_07_01       07         2       0.549309625          0
## 211  Pl7_C_07_04       07         1        0.67212965          0
## 212  Pl7_C_07_03       07         1        0.56524455          0
## 213  Pl7_C_07_02       07         1        0.61659525          0
## 214  Pl7_C_07_01       07         1       0.593791975          0
## 215  Pl4_M_07_04       07         2       0.610299695          0
## 216  Pl4_M_07_03       07         2     0.69308045375          0
## 217  Pl4_M_07_02       07         2     0.63670645375          0
## 218  Pl4_M_07_01       07         2        0.58598602          0
## 219  Pl5_M_07_04       07         2      0.6112187625          0
## 220  Pl5_M_07_03       07         2     0.66664569625          0
## 221  Pl5_M_07_02       07         2      0.5571907425          0
## 222  Pl5_M_07_01       07         2     0.54080799625          0
## 223  Pl2_C_07_04       07         1      0.6174833875          0
## 224  Pl2_C_07_02       07         1       0.710517475          0
## 225  Pl3_C_07_04       07         1      0.6408862125          0
## 226  Pl3_C_07_03       07         1      0.6772189625          0
## 227  Pl3_C_07_01       07         1        0.72082412          0
## 228  Pl1_M_08_02       08         2        0.52466548          0
## 229  Pl1_M_08_03       08         2       0.508775925          0
## 230  Pl1_M_08_01       08         2      0.5356339875          0
## 231  Pl1_M_08_04       08         2      0.5920565125          0
## 232  Pl5_M_08_03       08         2     0.55415963125       1.25
## 233  Pl6_C_08_04       08         1       0.566273915          0
## 234  Pl6_C_08_03       08         1      0.8430136125          0
## 235  Pl6_C_08_02       08         1      0.7740699125          0
## 236  Pl6_C_08_01       08         1     0.65329229375       3.25
## 237  Pl3_C_08_04       08         1     0.63008300375          4
## 238  Pl3_C_08_03       08         1     0.54697688375          2
## 239 Pl11_M_08_04       08         2      0.5114103075          0
## 240 Pl11_M_08_03       08         2     0.59807305375          0
## 241 Pl11_M_08_02       08         2        0.49575432          0
## 242 Pl11_M_08_01       08         2     0.67394106875       2.25
## 243  Pl7_C_08_04       08         1        0.81965462          0
## 244  Pl7_C_08_03       08         1        0.92487395          0
## 245  Pl7_C_08_02       08         1     0.98616646625          0
## 246  Pl7_C_08_01       08         1     0.88724672125          0
## 247  Pl4_M_08_04       08         2        0.61069795          0
## 248  Pl4_M_08_03       08         2      0.5930884625          0
## 249  Pl4_M_08_02       08         2       0.387557745          0
## 250  Pl4_M_08_01       08         2        0.55736775          0
## 251  Pl5_M_08_01       08         2       0.588690925          0
## 252  Pl5_M_08_04       08         2        0.52489527          0
## 253  Pl5_M_08_02       08         2       0.666429645          0
## 254  Pl2_C_08_04       08         1         0.6272715          0
## 255  Pl2_C_08_03       08         1        0.63528245          0
## 256  Pl2_C_08_02       08         1         0.7086221          0
## 257  Pl2_C_08_01       08         1       0.691633475          0
## 258  Pl3_C_08_01       08         1      0.6411387825          0
## 259  Pl3_C_08_02       08         1      0.5919273375          0
##              aLRL.delta
## 2     0.109739870407895
## 3        0.132206579125
## 4     0.098935055736842
## 5          0.0634006866
## 6    0.0995367347368421
## 7                     0
## 8                     0
## 9                     0
## 10                    0
## 11                    0
## 16                    0
## 17                    0
## 18                    0
## 19                    0
## 20                    0
## 22                    0
## 23                    0
## 24                    0
## 25                    0
## 26                    0
## 27                    0
## 29                    0
## 30                    0
## 31                    0
## 32                    0
## 38    0.117982811446429
## 39    0.120255050411765
## 40   0.0584443816388889
## 41                    0
## 42                    0
## 43                    0
## 44                    0
## 45                    0
## 46                    0
## 47                    0
## 52                    0
## 53                    0
## 54                    0
## 55                    0
## 56                    0
## 57                    0
## 58                    0
## 59                    0
## 60                    0
## 61                    0
## 62                    0
## 63                    0
## 65                    0
## 66                    0
## 67                    0
## 68                    0
## 69                    0
## 70                    0
## 74                    0
## 75                    0
## 76         0.0868226815
## 77          0.082140183
## 78   0.0778175775096154
## 79                    0
## 80                    0
## 81                    0
## 82                    0
## 83                    0
## 84                    0
## 85                    0
## 86                    0
## 87                    0
## 88                    0
## 89                    0
## 90                    0
## 91                    0
## 92                    0
## 93                    0
## 94                    0
## 95                    0
## 96                    0
## 102                   0
## 103                   0
## 104    0.05640729596875
## 105                   0
## 106    0.12422206651087
## 107   0.112294295654762
## 108      0.103925753275
## 109        0.0881391596
## 110       0.04294646575
## 113   0.112859666211538
## 114                   0
## 115                   0
## 118                   0
## 119                   0
## 120                   0
## 121                   0
## 122                   0
## 123                   0
## 124                   0
## 125                   0
## 126                   0
## 127                   0
## 128                   0
## 129                   0
## 130                   0
## 131                   0
## 140                   0
## 141 -0.0199634288690476
## 142  0.0991977055166666
## 143                   0
## 144                   0
## 145                   0
## 146                   0
## 147                   0
## 148                   0
## 149                   0
## 151                   0
## 153                   0
## 154                   0
## 155                   0
## 156                   0
## 157                   0
## 158                   0
## 159                   0
## 160                   0
## 161                   0
## 162                   0
## 163                   0
## 166                   0
## 167                   0
## 168   0.152144571019231
## 169                   0
## 170  0.0877431929583333
## 171  0.0434172150416667
## 172        0.1029270736
## 173 0.00533032031249999
## 174     0.1319099284375
## 175  0.0495053082833333
## 176                   0
## 177                   0
## 178                   0
## 179                   0
## 180                   0
## 181                   0
## 182                   0
## 183                   0
## 184                   0
## 185                   0
## 186                   0
## 187                   0
## 188                   0
## 189                   0
## 190                   0
## 191                   0
## 192                   0
## 193                   0
## 194                   0
## 195                   0
## 196                   0
## 197                   0
## 198                   0
## 199                   0
## 200                   0
## 201    0.05821575040625
## 202                   0
## 203                   0
## 204        0.1179209265
## 205   0.119499510617647
## 206   0.119461052089286
## 207                   0
## 208                   0
## 209                   0
## 210                   0
## 211                   0
## 212                   0
## 213                   0
## 214                   0
## 215                   0
## 216                   0
## 217                   0
## 218                   0
## 219                   0
## 220                   0
## 221                   0
## 222                   0
## 223                   0
## 224                   0
## 225                   0
## 226                   0
## 227                   0
## 228                   0
## 229                   0
## 230                   0
## 231                   0
## 232  0.0723639170833333
## 233                   0
## 234                   0
## 235                   0
## 236        0.1036340475
## 237   0.104998590308824
## 238   0.118904786722222
## 239                   0
## 240                   0
## 241                   0
## 242        0.0706312206
## 243                   0
## 244                   0
## 245                   0
## 246                   0
## 247                   0
## 248                   0
## 249                   0
## 250                   0
## 251                   0
## 252                   0
## 253                   0
## 254                   0
## 255                   0
## 256                   0
## 257                   0
## 258                   0
## 259                   0
unique(growth_factors$condition)
## [1] "1" "2"
write.csv(growth_factors, "20221011_DUF_OE_growth_factors.csv", row.names = FALSE)
### Visualizing the growth factors:

growth_factors$genotype <- gsub("01", "Col.0", growth_factors$genotype)
growth_factors$genotype <- gsub("02", "cis1.1", growth_factors$genotype)
growth_factors$genotype <- gsub("03", "agl16.1", growth_factors$genotype)
growth_factors$genotype <- gsub("04", "akr4c9.3A", growth_factors$genotype)
growth_factors$genotype <- gsub("05", "cis1.2", growth_factors$genotype)
growth_factors$genotype <- gsub("06", "agl16.2", growth_factors$genotype)
growth_factors$genotype <- gsub("07", "akr4c9.2I", growth_factors$genotype)
growth_factors$genotype <- gsub("08", "akr4c9.1F2", growth_factors$genotype)
?ggerrorplot
library(ggplot2)
growth_factors$genotype <- factor(growth_factors$genotype, levels = c("Col.0", "akr4c9.3A", "akr4c9.2I", "akr4c9.1F2", "agl16.1", "agl16.2", "cis1.1", "cis1.2"))
growth_factors_2 <- subset(growth_factors, growth_factors$MR.delta >= 0)


growth_factors_2$MR.delta <- as.numeric(as.character(growth_factors_2$MR.delta))
growth_factors_2$aLRL.delta <- as.numeric(as.character(growth_factors_2$aLRL.delta))
growth_factors_2$LRno.delta <- as.numeric(as.character(growth_factors_2$LRno.delta))

growth_factors_2$condition <- factor(growth_factors_2$condition, levels = c("1", "2"))

MR.delta_p_geno <- ggerrorplot(growth_factors_2, y = "MR.delta", x = "genotype", fill="genotype", color="condition", 
                        facet.by = c("condition"), ncol=3,
                        desc_stat = "mean_sd", add = "jitter",
                        panel.labs = list(condition = c("Control", "Mannitol")),
                        add.params = list(color = "darkgray"),
                        xlab="", ylab="Growth Rate (cm / day)")
                        
MR.delta_p_geno <- MR.delta_p_geno + rremove("legend") + stat_compare_means(method="t.test", ref.group = "col", 
                                                              label = "p.signif")
MR.delta_p_geno <- MR.delta_p_geno + ggtitle("Main Root Growth")
MR.delta_p_geno <- MR.delta_p_geno + theme(axis.text=element_text(size=10))
MR.delta_p_geno <- MR.delta_p_geno + theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))
MR.delta_p_geno <- MR.delta_p_geno + scale_color_manual(values= c("royalblue", "orange"))
MR.delta_p_geno
## Warning: 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

head(growth_factors_2)
##     root_name genotype condition  MR.delta LRno.delta aLRL.delta
## 2 Pl8_C_01_01    Col.0         1 0.8131587       4.50 0.10973987
## 3 Pl8_C_01_04    Col.0         1 0.7100063       2.25 0.13220658
## 4 Pl8_C_01_02    Col.0         1 0.8466062       4.25 0.09893506
## 5 Pl9_C_01_01    Col.0         1 0.6178694       1.00 0.06340069
## 6 Pl9_C_01_02    Col.0         1 0.8405577       4.25 0.09953673
## 7 Pl1_M_01_04    Col.0         2 0.2859252       0.00 0.00000000
library(stringr)
library(multcompView)
Control <- subset(growth_factors_2, growth_factors_2$condition == "1")
Mannitol <- subset(growth_factors_2, growth_factors_2$condition == "2")
Control$genotype <- as.factor(Control$genotype)
Mannitol$genotype <- as.factor(Mannitol$genotype)

Output <- TukeyHSD(aov(MR.delta ~ genotype, data = Control))
P7 = Output$genotype[,'p adj']
stat.test<- multcompLetters(P7)
testc <- as.data.frame(stat.test$Letters)
testc$group2 <- rownames(testc)
testc$group1 <- rownames(testc)
testc$genotype <- rownames(testc)
testc$genotype <- rownames(testc)
colnames(testc)[1] <- "Tukey"
testc$condition <- "1"

Output <- TukeyHSD(aov(MR.delta ~ genotype, data = Mannitol))
P7 = Output$genotype[,'p adj']
stat.test<- multcompLetters(P7)
tests <- as.data.frame(stat.test$Letters)
tests$group2 <- rownames(tests)
tests$group1 <- rownames(tests)
tests$genotype <- rownames(tests)
tests$genotype <- rownames(tests)
colnames(tests)[1] <- "Tukey"
tests$condition <- "2"

test <- rbind(testc, tests)
test
##             Tukey     group2     group1   genotype condition
## akr4c9.3A       a  akr4c9.3A  akr4c9.3A  akr4c9.3A         1
## akr4c9.2I       a  akr4c9.2I  akr4c9.2I  akr4c9.2I         1
## akr4c9.1F2      a akr4c9.1F2 akr4c9.1F2 akr4c9.1F2         1
## agl16.1         a    agl16.1    agl16.1    agl16.1         1
## agl16.2         a    agl16.2    agl16.2    agl16.2         1
## cis1.1          a     cis1.1     cis1.1     cis1.1         1
## cis1.2          a     cis1.2     cis1.2     cis1.2         1
## Col.0           a      Col.0      Col.0      Col.0         1
## akr4c9.3A1    abc  akr4c9.3A  akr4c9.3A  akr4c9.3A         2
## akr4c9.2I1      a  akr4c9.2I  akr4c9.2I  akr4c9.2I         2
## akr4c9.1F21    ab akr4c9.1F2 akr4c9.1F2 akr4c9.1F2         2
## agl16.11      abc    agl16.1    agl16.1    agl16.1         2
## agl16.21      abc    agl16.2    agl16.2    agl16.2         2
## cis1.11         c     cis1.1     cis1.1     cis1.1         2
## cis1.21        bc     cis1.2     cis1.2     cis1.2         2
## Col.01          c      Col.0      Col.0      Col.0         2
better_MRG_graph <- MR.delta_p_geno + stat_pvalue_manual(test, label = "Tukey", y.position = 1.2)
better_MRG_graph
## Warning: 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