setwd("~/Google Drive/Agrosavia/Colaboraciones/Fabricio/data")
library(Plasticity)
library(agricolae)
library(Rmisc)
## Loading required package: lattice
## Loading required package: plyr
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
library(FSA)
## ## FSA v0.9.1. See citation('FSA') if used in publication.
## ## Run fishR() for related website and fishR('IFAR') for related book.
## 
## Attaching package: 'FSA'
## The following object is masked from 'package:psych':
## 
##     headtail
## The following object is masked from 'package:plyr':
## 
##     mapvalues
library(forcats)
library(Hmisc)
## Loading required package: survival
## Loading required package: Formula
## 
## Attaching package: 'Hmisc'
## The following object is masked from 'package:psych':
## 
##     describe
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## The following objects are masked from 'package:plyr':
## 
##     is.discrete, summarize
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library("PerformanceAnalytics")
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## Attaching package: 'PerformanceAnalytics'
## The following objects are masked from 'package:agricolae':
## 
##     kurtosis, skewness
## The following object is masked from 'package:graphics':
## 
##     legend
library(onewaytests)
## Registered S3 methods overwritten by 'car':
##   method       from
##   hist.boot    FSA 
##   confint.boot FSA
## 
## Attaching package: 'onewaytests'
## The following object is masked from 'package:Hmisc':
## 
##     describe
## The following object is masked from 'package:psych':
## 
##     describe
library(emmeans)
library(ggthemes)
library(multcompView)
clone <- read.table("res_fin.csv", header=T, sep=",")
clone$Repetición<-as.factor(clone$Repetición)
clone$Clon<-as.factor(clone$Clon)
clone$env<-as.factor(clone$env)
# Generando bases de datos para los rangos ambientales a evaluar (100-300, 500-2000)
clone.high <- filter(clone, clone$env == "500" | clone$env=="2000")
clone.high.fin <- droplevels(clone.high)
clone.high.fin$env<-as.factor(clone.high.fin$env)
clone.high.fin$Clon<-as.factor(clone.high.fin$Clon)
# Calculo del RDPI para todos los caracteres luz alta (500-2000)
A.high.rdpi<-rdpi(clone.high.fin, Clon, A, env)
## 
## Attaching package: 'sciplot'
## The following object is masked from 'package:FSA':
## 
##     se
## [1] "ANOVA test"
##              Df Sum Sq Mean Sq F value Pr(>F)    
## RDPI$sp      19  4.734  0.2491   11.32 <2e-16 ***
## Residuals   300  6.600  0.0220                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Joining, by = "sp"

## [1] "Tukey HSD test for differences accross groups"
## # A tibble: 20 × 5
##    sp      mean     sd     se groups
##    <fct>  <dbl>  <dbl>  <dbl> <chr> 
##  1 TCS 01 0.258 0.0997 0.0249 cdef  
##  2 TCS 02 0.143 0.0887 0.0222 ef    
##  3 TCS 03 0.415 0.242  0.0605 abcd  
##  4 TCS 04 0.250 0.143  0.0359 cdef  
##  5 TCS 05 0.322 0.116  0.0291 bcde  
##  6 TCS 08 0.213 0.0610 0.0152 ef    
##  7 TCS 10 0.581 0.197  0.0493 a     
##  8 TCS 11 0.209 0.119  0.0296 ef    
##  9 TCS 12 0.457 0.231  0.0579 ab    
## 10 TCS 20 0.234 0.185  0.0463 def   
## 11 TCS 40 0.130 0.0860 0.0215 f     
## 12 TCS 41 0.273 0.0758 0.0190 bcdef 
## 13 TCS 42 0.133 0.0916 0.0229 f     
## 14 TCS 43 0.246 0.0637 0.0159 def   
## 15 TCS 44 0.153 0.102  0.0255 ef    
## 16 TCS 45 0.122 0.0895 0.0224 f     
## 17 TCS 46 0.223 0.178  0.0446 ef    
## 18 TCS 47 0.304 0.127  0.0318 bcdef 
## 19 TCS 48 0.162 0.127  0.0317 ef    
## 20 TCS 49 0.435 0.277  0.0694 abc
E.high.rdpi<-rdpi(clone.high.fin, Clon, E, env)
## [1] "ANOVA test"
##              Df Sum Sq Mean Sq F value Pr(>F)    
## RDPI$sp      19  4.087 0.21512   7.674 <2e-16 ***
## Residuals   300  8.410 0.02803                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Joining, by = "sp"

## [1] "Tukey HSD test for differences accross groups"
## # A tibble: 20 × 5
##    sp      mean     sd     se groups
##    <fct>  <dbl>  <dbl>  <dbl> <chr> 
##  1 TCS 01 0.445 0.124  0.0309 abcde 
##  2 TCS 02 0.279 0.133  0.0332 ef    
##  3 TCS 03 0.523 0.294  0.0734 ab    
##  4 TCS 04 0.376 0.183  0.0456 bcdef 
##  5 TCS 05 0.439 0.119  0.0298 bcde  
##  6 TCS 08 0.383 0.162  0.0406 bcdef 
##  7 TCS 10 0.652 0.0949 0.0237 a     
##  8 TCS 11 0.368 0.163  0.0408 bcdef 
##  9 TCS 12 0.502 0.220  0.0551 abcd  
## 10 TCS 20 0.287 0.161  0.0402 ef    
## 11 TCS 40 0.174 0.121  0.0303 f     
## 12 TCS 41 0.436 0.120  0.0300 bcde  
## 13 TCS 42 0.304 0.137  0.0343 cdef  
## 14 TCS 43 0.381 0.192  0.0481 bcdef 
## 15 TCS 44 0.235 0.164  0.0411 ef    
## 16 TCS 45 0.290 0.0485 0.0121 def   
## 17 TCS 46 0.322 0.188  0.0469 bcdef 
## 18 TCS 47 0.312 0.163  0.0409 bcdef 
## 19 TCS 48 0.257 0.151  0.0377 ef    
## 20 TCS 49 0.510 0.242  0.0605 abc
WUE.high.rdpi<-rdpi(clone.high.fin, Clon, WUE, env)
## [1] "ANOVA test"
##              Df Sum Sq Mean Sq F value  Pr(>F)   
## RDPI$sp      19  0.488 0.02567   2.293 0.00188 **
## Residuals   300  3.358 0.01119                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Joining, by = "sp"

## [1] "Tukey HSD test for differences accross groups"
## # A tibble: 20 × 5
##    sp       mean     sd     se groups
##    <fct>   <dbl>  <dbl>  <dbl> <chr> 
##  1 TCS 01 0.225  0.130  0.0325 ab    
##  2 TCS 02 0.162  0.0631 0.0158 abc   
##  3 TCS 03 0.242  0.177  0.0442 a     
##  4 TCS 04 0.167  0.0945 0.0236 abc   
##  5 TCS 05 0.154  0.104  0.0261 abc   
##  6 TCS 08 0.188  0.126  0.0316 abc   
##  7 TCS 10 0.132  0.0896 0.0224 abc   
##  8 TCS 11 0.201  0.0805 0.0201 abc   
##  9 TCS 12 0.167  0.0885 0.0221 abc   
## 10 TCS 20 0.0794 0.0533 0.0133 c     
## 11 TCS 40 0.160  0.122  0.0304 abc   
## 12 TCS 41 0.190  0.0686 0.0171 abc   
## 13 TCS 42 0.195  0.0559 0.0140 abc   
## 14 TCS 43 0.223  0.167  0.0417 ab    
## 15 TCS 44 0.107  0.0792 0.0198 bc    
## 16 TCS 45 0.182  0.0991 0.0248 abc   
## 17 TCS 46 0.143  0.111  0.0278 abc   
## 18 TCS 47 0.190  0.126  0.0314 abc   
## 19 TCS 48 0.159  0.0729 0.0182 abc   
## 20 TCS 49 0.129  0.104  0.0261 abc
gsw.high.rdpi<-rdpi(clone.high.fin, Clon, gsw, env)
## [1] "ANOVA test"
##              Df Sum Sq Mean Sq F value Pr(>F)    
## RDPI$sp      19  5.191 0.27320   8.764 <2e-16 ***
## Residuals   300  9.352 0.03117                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Joining, by = "sp"

## [1] "Tukey HSD test for differences accross groups"
## # A tibble: 20 × 5
##    sp      mean     sd     se groups
##    <fct>  <dbl>  <dbl>  <dbl> <chr> 
##  1 TCS 01 0.441 0.0921 0.0230 abcde 
##  2 TCS 02 0.278 0.150  0.0376 defg  
##  3 TCS 03 0.516 0.255  0.0637 abc   
##  4 TCS 04 0.396 0.185  0.0461 bcdef 
##  5 TCS 05 0.411 0.180  0.0451 bcdef 
##  6 TCS 08 0.377 0.150  0.0374 bcdef 
##  7 TCS 10 0.646 0.214  0.0536 a     
##  8 TCS 11 0.430 0.0878 0.0219 abcdef
##  9 TCS 12 0.561 0.247  0.0616 ab    
## 10 TCS 20 0.231 0.160  0.0401 efg   
## 11 TCS 40 0.144 0.119  0.0296 g     
## 12 TCS 41 0.471 0.138  0.0344 abcd  
## 13 TCS 42 0.271 0.168  0.0421 defg  
## 14 TCS 43 0.373 0.0828 0.0207 bcdef 
## 15 TCS 44 0.208 0.146  0.0364 fg    
## 16 TCS 45 0.292 0.187  0.0468 defg  
## 17 TCS 46 0.302 0.217  0.0542 cdefg 
## 18 TCS 47 0.410 0.182  0.0456 bcdef 
## 19 TCS 48 0.235 0.131  0.0328 efg   
## 20 TCS 49 0.525 0.277  0.0692 ab
cica.high.rdpi<-rdpi(clone.high.fin, Clon, cica, env)
## [1] "ANOVA test"
##              Df Sum Sq  Mean Sq F value   Pr(>F)    
## RDPI$sp      19 0.1964 0.010336    3.78 3.93e-07 ***
## Residuals   300 0.8203 0.002734                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Joining, by = "sp"

## [1] "Tukey HSD test for differences accross groups"
## # A tibble: 20 × 5
##    sp       mean     sd      se groups
##    <fct>   <dbl>  <dbl>   <dbl> <chr> 
##  1 TCS 01 0.0880 0.0275 0.00688 abcde 
##  2 TCS 02 0.0617 0.0348 0.00870 bcde  
##  3 TCS 03 0.129  0.0800 0.0200  a     
##  4 TCS 04 0.0760 0.0458 0.0115  abcde 
##  5 TCS 05 0.100  0.0724 0.0181  abcd  
##  6 TCS 08 0.0794 0.0473 0.0118  abcde 
##  7 TCS 10 0.0721 0.0563 0.0141  abcde 
##  8 TCS 11 0.101  0.0546 0.0137  abcd  
##  9 TCS 12 0.0925 0.0520 0.0130  abcde 
## 10 TCS 20 0.0878 0.0707 0.0177  abcde 
## 11 TCS 40 0.0339 0.0211 0.00528 e     
## 12 TCS 41 0.121  0.0648 0.0162  ab    
## 13 TCS 42 0.105  0.0607 0.0152  abc   
## 14 TCS 43 0.0853 0.0371 0.00927 abcde 
## 15 TCS 44 0.0450 0.0276 0.00690 cde   
## 16 TCS 45 0.0849 0.0653 0.0163  abcde 
## 17 TCS 46 0.0597 0.0456 0.0114  bcde  
## 18 TCS 47 0.0924 0.0653 0.0163  abcde 
## 19 TCS 48 0.0354 0.0200 0.00500 de    
## 20 TCS 49 0.0744 0.0375 0.00936 abcde
high.rdpi<-data.frame(A.high.rdpi$sp, A.high.rdpi$rdpi, E.high.rdpi$rdpi, WUE.high.rdpi$rdpi, gsw.high.rdpi$rdpi, 
                      cica.high.rdpi$rdpi)
colnames(high.rdpi)<-c('gen', 'Ardpi', 'Erdpi', 'WUErdpi', 'gswrdpi', 'cicardpi')
high.rdpi$treatment <- "high"
# analysis of variance
anova_A <- aov(high.rdpi$Ardpi ~ high.rdpi$gen, data = high.rdpi)
anova_E <- aov(high.rdpi$Erdpi ~ high.rdpi$gen, data = high.rdpi)
anova_WUE <- aov(high.rdpi$WUErdpi ~ high.rdpi$gen, data = high.rdpi)
anova_gsw <- aov(high.rdpi$gswrdpi ~ high.rdpi$gen, data = high.rdpi)
anova_cica <- aov(high.rdpi$cicardpi ~ high.rdpi$gen, data = high.rdpi)
# Tukey's test
tukey_A <- TukeyHSD(anova_A)
tukey_E <- TukeyHSD(anova_E)
tukey_WUE <- TukeyHSD(anova_WUE)
tukey_gsw <- TukeyHSD(anova_gsw)
tukey_cica <- TukeyHSD(anova_cica)
# compact letter display
cld_A <- multcompLetters4(anova_A, tukey_A)
cld_E <- multcompLetters4(anova_E, tukey_E)
cld_WUE <- multcompLetters4(anova_WUE, tukey_WUE)
cld_gsw <- multcompLetters4(anova_gsw, tukey_gsw)
cld_cica <- multcompLetters4(anova_cica, tukey_cica)
# table with factors and 3rd quantile
dt_A <- group_by(high.rdpi, gen) %>%
  summarise(w=mean(Ardpi)) %>%
  arrange(desc(w))
dt_E <- group_by(high.rdpi, gen) %>%
  summarise(w=mean(Erdpi)) %>%
  arrange(desc(w))
dt_WUE <- group_by(high.rdpi, gen) %>%
  summarise(w=mean(WUErdpi)) %>%
  arrange(desc(w))
dt_gsw <- group_by(high.rdpi, gen) %>%
  summarise(w=mean(gswrdpi)) %>%
  arrange(desc(w))
dt_cica <- group_by(high.rdpi, gen) %>%
  summarise(w=mean(cicardpi)) %>%
  arrange(desc(w))
# extracting the compact letter display and adding to the Tk table
dt_A$cldA <- cld_A$`high.rdpi$gen`$Letters
print(dt_A)
## # A tibble: 20 × 3
##    gen        w cldA 
##    <fct>  <dbl> <chr>
##  1 TCS 10 0.581 a    
##  2 TCS 12 0.457 ab   
##  3 TCS 49 0.435 abc  
##  4 TCS 03 0.415 abcd 
##  5 TCS 05 0.322 bcde 
##  6 TCS 47 0.304 bcdef
##  7 TCS 41 0.273 bcdef
##  8 TCS 01 0.258 cdef 
##  9 TCS 04 0.250 cdef 
## 10 TCS 43 0.246 def  
## 11 TCS 20 0.234 def  
## 12 TCS 46 0.223 ef   
## 13 TCS 08 0.213 ef   
## 14 TCS 11 0.209 ef   
## 15 TCS 48 0.162 ef   
## 16 TCS 44 0.153 ef   
## 17 TCS 02 0.143 ef   
## 18 TCS 42 0.133 f    
## 19 TCS 40 0.130 f    
## 20 TCS 45 0.122 f
dt_E$cldE <- cld_E$`high.rdpi$gen`$Letters
print(dt_E)
## # A tibble: 20 × 3
##    gen        w cldE 
##    <fct>  <dbl> <chr>
##  1 TCS 10 0.652 a    
##  2 TCS 03 0.523 ab   
##  3 TCS 49 0.510 abc  
##  4 TCS 12 0.502 abcd 
##  5 TCS 01 0.445 abcde
##  6 TCS 05 0.439 bcde 
##  7 TCS 41 0.436 bcde 
##  8 TCS 08 0.383 bcdef
##  9 TCS 43 0.381 bcdef
## 10 TCS 04 0.376 bcdef
## 11 TCS 11 0.368 bcdef
## 12 TCS 46 0.322 bcdef
## 13 TCS 47 0.312 bcdef
## 14 TCS 42 0.304 cdef 
## 15 TCS 45 0.290 def  
## 16 TCS 20 0.287 ef   
## 17 TCS 02 0.279 ef   
## 18 TCS 48 0.257 ef   
## 19 TCS 44 0.235 ef   
## 20 TCS 40 0.174 f
dt_WUE$cldWUE <- cld_WUE$`high.rdpi$gen`$Letters
print(dt_WUE)
## # A tibble: 20 × 3
##    gen         w cldWUE
##    <fct>   <dbl> <chr> 
##  1 TCS 03 0.242  a     
##  2 TCS 01 0.225  ab    
##  3 TCS 43 0.223  ab    
##  4 TCS 11 0.201  abc   
##  5 TCS 42 0.195  abc   
##  6 TCS 41 0.190  abc   
##  7 TCS 47 0.190  abc   
##  8 TCS 08 0.188  abc   
##  9 TCS 45 0.182  abc   
## 10 TCS 12 0.167  abc   
## 11 TCS 04 0.167  abc   
## 12 TCS 02 0.162  abc   
## 13 TCS 40 0.160  abc   
## 14 TCS 48 0.159  abc   
## 15 TCS 05 0.154  abc   
## 16 TCS 46 0.143  abc   
## 17 TCS 10 0.132  abc   
## 18 TCS 49 0.129  abc   
## 19 TCS 44 0.107  bc    
## 20 TCS 20 0.0794 c
dt_gsw$cldgsw <- cld_gsw$`high.rdpi$gen`$Letters
print(dt_gsw)
## # A tibble: 20 × 3
##    gen        w cldgsw
##    <fct>  <dbl> <chr> 
##  1 TCS 10 0.646 a     
##  2 TCS 12 0.561 ab    
##  3 TCS 49 0.525 ab    
##  4 TCS 03 0.516 abc   
##  5 TCS 41 0.471 abcd  
##  6 TCS 01 0.441 abcde 
##  7 TCS 11 0.430 abcdef
##  8 TCS 05 0.411 bcdef 
##  9 TCS 47 0.410 bcdef 
## 10 TCS 04 0.396 bcdef 
## 11 TCS 08 0.377 bcdef 
## 12 TCS 43 0.373 bcdef 
## 13 TCS 46 0.302 cdefg 
## 14 TCS 45 0.292 defg  
## 15 TCS 02 0.278 defg  
## 16 TCS 42 0.271 defg  
## 17 TCS 48 0.235 efg   
## 18 TCS 20 0.231 efg   
## 19 TCS 44 0.208 fg    
## 20 TCS 40 0.144 g
dt_cica$cldcica <- cld_cica$`high.rdpi$gen`$Letters
print(dt_cica)
## # A tibble: 20 × 3
##    gen         w cldcica
##    <fct>   <dbl> <chr>  
##  1 TCS 03 0.129  a      
##  2 TCS 41 0.121  ab     
##  3 TCS 42 0.105  abc    
##  4 TCS 11 0.101  abcd   
##  5 TCS 05 0.100  abcd   
##  6 TCS 12 0.0925 abcde  
##  7 TCS 47 0.0924 abcde  
##  8 TCS 01 0.0880 abcde  
##  9 TCS 20 0.0878 abcde  
## 10 TCS 43 0.0853 abcde  
## 11 TCS 45 0.0849 abcde  
## 12 TCS 08 0.0794 abcde  
## 13 TCS 04 0.0760 abcde  
## 14 TCS 49 0.0744 abcde  
## 15 TCS 10 0.0721 abcde  
## 16 TCS 02 0.0617 bcde   
## 17 TCS 46 0.0597 bcde   
## 18 TCS 44 0.0450 cde    
## 19 TCS 48 0.0354 de     
## 20 TCS 40 0.0339 e
### group high.rdpi by gen and return some averages
high2 <- high.rdpi %>%
  select(gen, Ardpi, Erdpi, WUErdpi, gswrdpi, cicardpi) %>%
  group_by(gen) %>%
  summarise(
    Ardpi_m = mean(Ardpi), 
    Erdpi_m = mean(Erdpi), 
    WUErdpi_m = mean(WUErdpi), 
    gswrdpi_m = mean(gswrdpi), 
    cicardpi_m = mean(cicardpi),
    n=n(),
    sd_A=sd(Ardpi),
    sd_E=sd(Erdpi),
    sd_WUE=sd(WUErdpi),
    sd_gsw=sd(gswrdpi),
    sd_cica=sd(cicardpi)
  ) %>%
  mutate(se_A=sd_A/sqrt(n)) %>%
  mutate(se_E=sd_E/sqrt(n)) %>%
  mutate(se_WUE=sd_WUE/sqrt(n)) %>%
  mutate(se_gsw=sd_gsw/sqrt(n)) %>%
  mutate(se_cica=sd_cica/sqrt(n))
## Adding Tukey letters to high
high2<-merge(dt_A, high2, by="gen")
high2<-merge(dt_E, high2, by="gen")
high2<-merge(dt_WUE, high2, by="gen")
high2<-merge(dt_gsw, high2, by="gen")
## Warning in merge.data.frame(dt_gsw, high2, by = "gen"): column names 'w.x',
## 'w.y' are duplicated in the result
high2<-merge(dt_cica, high2, by="gen")
## saving the data frames
write.csv(high2, "~/Google Drive/Agrosavia/Colaboraciones/Fabricio/data/high.csv")
highs <- read.table("high.csv", header=T, sep=",")
attach(highs)
##Reordering gen by mean
new_order8 <- with(highs, reorder(gen, Ardpi_m, mean, na.rm=T))
new_order9 <- with(highs, reorder(gen, Erdpi_m, mean, na.rm=T))
new_order10 <- with(highs, reorder(gen, WUErdpi_m, mean, na.rm=T))
new_order11 <- with(highs, reorder(gen, gswrdpi_m, mean, na.rm=T))
new_order12 <- with(highs, reorder(gen, cicardpi_m, mean, na.rm=T))
##Barplots
Aplot=highs %>%
  arrange(Ardpi_m) %>%
  mutate(gen=factor(gen, levels = gen)) %>%
  ggplot( aes(x=gen, y=Ardpi_m, fill=cldA)) +
  geom_col(alpha=.9, width=.7, show.legend = FALSE) +
  scale_fill_brewer(palette = "Paired") +
  geom_errorbar(aes(ymin=Ardpi_m-se_A, ymax=Ardpi_m+se_A), width=0.2)+
  geom_text(aes(label = cldA, y = Ardpi_m), nudge_x =0, nudge_y = 0.13, size = 3.5)+
  coord_flip() +
  xlab("") +
  ylab(expression(RDPI[A])) +
  theme_classic()
Aplot + theme(axis.text = element_text(size = 12))

ggsave("Aplot.tiff", plot= Aplot, width = 4, height = 3, dpi = 1000)

Eplot=highs %>%
  arrange(Erdpi_m) %>%
  mutate(gen=factor(gen, levels = gen)) %>%
  ggplot( aes(x=gen, y=Erdpi_m, fill=cldE)) +
  geom_col(alpha=.9, width=.7, show.legend = FALSE) +
  scale_fill_brewer(palette = "Paired") +
  geom_errorbar(aes(ymin=Erdpi_m-se_E, ymax=Erdpi_m+se_E), width=0.2)+
  geom_text(aes(label = cldE, y = Erdpi_m), nudge_x =0, nudge_y = 0.1, size = 3.5)+
  coord_flip() +
  xlab("") +
  ylab(expression(RDPI[E])) +
  theme_classic()
Eplot + theme(axis.text = element_text(size = 12))

ggsave("Eplot.tiff", plot= Eplot, width = 4, height = 3, dpi = 1000)

WUEplot=highs %>%
  arrange(WUErdpi_m) %>%
  mutate(gen=factor(gen, levels = gen)) %>%
  ggplot( aes(x=gen, y=WUErdpi_m, fill=cldWUE)) +
  geom_col(alpha=.9, width=.7, show.legend = FALSE) +
  scale_fill_brewer(palette = "Paired") +
  geom_errorbar(aes(ymin=WUErdpi_m-se_WUE, ymax=WUErdpi_m+se_WUE), width=0.2)+
  geom_text(aes(label = cldWUE, y = WUErdpi_m), nudge_x =0, nudge_y = 0.09, size = 3.5)+
  coord_flip() +
  xlab("") +
  ylab(expression(RDPI[WUE])) +
  theme_classic()
WUEplot + theme(axis.text = element_text(size = 12))

ggsave("WUEplot.tiff", plot= WUEplot, width = 4, height = 3, dpi = 1000)

gswplot=highs %>%
  arrange(gswrdpi_m) %>%
  mutate(gen=factor(gen, levels = gen)) %>%
  ggplot( aes(x=gen, y=gswrdpi_m, fill = cldgsw)) +
  geom_col(alpha=.9, width=.7, show.legend = FALSE) +
  scale_fill_brewer(palette = "Paired") +
  geom_errorbar(aes(ymin=gswrdpi_m-se_gsw, ymax=gswrdpi_m+se_gsw), width=0.2)+
  geom_text(aes(label = cldgsw, y = gswrdpi_m), nudge_x =0, nudge_y = 0.13, size = 3.5)+
  coord_flip() +
  xlab("") +
  ylab(expression(RDPI[gSw])) +
  theme_classic()
gswplot + theme(axis.text = element_text(size = 12))

ggsave("gswplot.tiff", plot= gswplot, width = 4, height = 3, dpi = 1000)

cicaplot=highs %>%
  arrange(cicardpi_m) %>%
  mutate(gen=factor(gen, levels = gen)) %>%
  ggplot( aes(x=gen, y=cicardpi_m, fill = cldcica )) +
  geom_col(alpha=.9, width=.7, show.legend = FALSE) +
  scale_fill_brewer(palette = "Paired") +
  geom_errorbar(aes(ymin=cicardpi_m-se_cica, ymax=cicardpi_m+se_cica), width=0.2)+
  geom_text(aes(label = cldcica, y = cicardpi_m), nudge_x =0, nudge_y = 0.07, size = 3.5)+
  coord_flip() +
  xlab("") +
  ylab(expression(RDPI[Ci/Ca])) +
  theme_classic()
cicaplot + theme(axis.text = element_text(size = 12))

ggsave("cicaplot.tiff", plot= cicaplot, width = 4, height = 3, dpi = 1000)

detach(highs)