In this notebook, I am only re-plotting some of the data that was previously re-analyzed by Helena Oakey and Mitch Morton.

list.files()
##  [1] "00-raw.0275.dat.rda"                        
##  [2] "01-longi5.0275_MJLM_FINALFINAL.dat.csv"     
##  [3] "01-longi5.0275_MJLM_FINALFINAL.dat.rda"     
##  [4] "20221012_plots.nb.html"                     
##  [5] "20221012_plots.Rmd"                         
##  [6] "20230208_plots_and_figures.html"            
##  [7] "20230208_plots_and_figures.nb.html"         
##  [8] "20230208_plots_and_figures.Rmd"             
##  [9] "Analysis_Graphs"                            
## [10] "Annotated TPA outliers.numbers"             
## [11] "emptyPots_adj.csv"                          
## [12] "emptyPots.csv"                              
## [13] "Evap.carts.rda"                             
## [14] "Fig.Interval.data_MMJ.pdf"                  
## [15] "Fig.Interval.data_MMJ.png"                  
## [16] "Fig.Interval.data.pdf"                      
## [17] "Fig.Interval.png"                           
## [18] "Fig.l_plots.pdf"                            
## [19] "Fig.S.ShootFreshMass_vs_PSA_MMJ.pdf"        
## [20] "Fig.S.ShootFreshMass_vs_PSA_MMJ.png"        
## [21] "Fig.S.ShootFreshMass_vs_PSA.pdf"            
## [22] "Fig.S.ShootFreshMass_vs_PSA.png"            
## [23] "Fig.SFM_indices.pdf"                        
## [24] "Fig.SFM_indices.png"                        
## [25] "Fig.SFM_ions_MMJ.pdf"                       
## [26] "Fig.SFM_ions.pdf"                           
## [27] "Fig.SFM_ions.png"                           
## [28] "Final_TPAScript_RawToSmooth.R"              
## [29] "MMJ_Fig.Phenotype_TPA.pdf"                  
## [30] "MMJ_Fig.Phenotype_TPA.png"                  
## [31] "README_Data_prep_files.rtf"                 
## [32] "Regression_SFM.pdf"                         
## [33] "TPA_correlation_pearson.pdf"                
## [34] "TPA_correlation_spearman.pdf"               
## [35] "TPA_correlations.pdf"                       
## [36] "TPA_fig_long_MMJ.pdf"                       
## [37] "TPA_fig_long_MMJ.png"                       
## [38] "TPA_fig_long.pdf"                           
## [39] "TPA_terminal.harvest_MMJ.pdf"               
## [40] "TPA_terminal.harvest.pdf"                   
## [41] "TPA_terminal.png"                           
## [42] "TPA.Adj.Rsq.csv"                            
## [43] "TPA.pval.csv"                               
## [44] "TPA.RSE.csv"                                
## [45] "TPA.Rsq.csv"                                
## [46] "TPA.stress.indices.all.traits.csv"          
## [47] "TPAData_Corrected+SFM+FlameMeans_rmM104.csv"
long <- read.csv("01-longi5.0275_MJLM_FINALFINAL.dat.csv")
long
library("ggplot2")
library("ggpubr")
library("ggsci")

long$Days.after.Salting <- as.factor(long$Days.after.Salting)

Area_lgraph <- ggplot(data=long, aes(x= Days.after.Salting, y=Area.smooth, group = Snapshot.ID.Tag, color = Treatment.1)) 
Area_lgraph <- Area_lgraph + geom_line(alpha = 0.1) 
Area_lgraph <- Area_lgraph + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group= Treatment.1), alpha=0.3)
Area_lgraph <- Area_lgraph + stat_summary(fun=mean, aes(group= Treatment.1),  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.
Area_lgraph <- Area_lgraph + stat_compare_means(aes(group = Treatment.1), label = "p.signif", method = "aov", hide.ns = T)
Area_lgraph <- Area_lgraph + ylab("Projected Shoot Area (kpixels)") + xlab("Days after stress") + scale_color_aaas() + theme_bw()
Area_lgraph <- Area_lgraph + guides(color=guide_legend(title="Treatment")) + theme(legend.position = c(0.1, 0.7))
Area_lgraph
## Warning: The dot-dot notation (`..p.signif..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(p.signif)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Removed 532 rows containing non-finite values (`stat_summary()`).
## Removed 532 rows containing non-finite values (`stat_summary()`).
## Warning: Removed 532 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 531 rows containing missing values (`geom_line()`).

AreaAGR_lgraph <- ggplot(data=long, aes(x= Days.after.Salting, y=Area.smooth.AGR, group = Snapshot.ID.Tag, color = Treatment.1)) 
AreaAGR_lgraph <- AreaAGR_lgraph + geom_line(alpha = 0.1) 
AreaAGR_lgraph <- AreaAGR_lgraph + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group= Treatment.1), alpha=0.3)
AreaAGR_lgraph <- AreaAGR_lgraph + stat_summary(fun=mean, aes(group= Treatment.1),  size=0.7, geom="line", linetype = "dashed")
AreaAGR_lgraph <- AreaAGR_lgraph + stat_compare_means(aes(group = Treatment.1), label = "p.signif", method = "aov", hide.ns = T)
AreaAGR_lgraph <- AreaAGR_lgraph + ylab("Absolute Growth Rrate (kpixels / day)") + xlab("Days after stress") + scale_color_aaas() + theme_bw()
AreaAGR_lgraph <- AreaAGR_lgraph + guides(color=guide_legend(title="Treatment")) + theme(legend.position = c(0.1, 0.7))
AreaAGR_lgraph
## Warning: Removed 533 rows containing non-finite values (`stat_summary()`).
## Removed 533 rows containing non-finite values (`stat_summary()`).
## Warning: Removed 533 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 531 rows containing missing values (`geom_line()`).

AreaRGR_lgraph <- ggplot(data=long, aes(x= Days.after.Salting, y=Area.smooth.RGR, group = Snapshot.ID.Tag, color = Treatment.1)) 
AreaRGR_lgraph <- AreaRGR_lgraph + geom_line(alpha = 0.1) 
AreaRGR_lgraph <- AreaRGR_lgraph + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group= Treatment.1), alpha=0.3)
AreaRGR_lgraph <- AreaRGR_lgraph + stat_summary(fun=mean, aes(group= Treatment.1),  size=0.7, geom="line", linetype = "dashed")
AreaRGR_lgraph <- AreaRGR_lgraph + stat_compare_means(aes(group = Treatment.1), label = "p.signif", method = "aov", hide.ns = T)
AreaRGR_lgraph <- AreaRGR_lgraph + ylab("Relative Growth Rrate (kpixels / day)") + xlab("Days after stress") + scale_color_aaas() + theme_bw()
AreaRGR_lgraph <- AreaRGR_lgraph + guides(color=guide_legend(title="Treatment")) + theme(legend.position = "none")
AreaRGR_lgraph
## Warning: Removed 533 rows containing non-finite values (`stat_summary()`).
## Removed 533 rows containing non-finite values (`stat_summary()`).
## Warning: Removed 533 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 531 rows containing missing values (`geom_line()`).

Transpiration_lgraph <- ggplot(data=long, aes(x= Days.after.Salting, y=Transpiration.smooth, group = Snapshot.ID.Tag, color = Treatment.1)) 
Transpiration_lgraph <- Transpiration_lgraph + geom_line(alpha = 0.1) 
Transpiration_lgraph <- Transpiration_lgraph + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group= Treatment.1), alpha=0.3)
Transpiration_lgraph <- Transpiration_lgraph + stat_summary(fun=mean, aes(group= Treatment.1),  size=0.7, geom="line", linetype = "dashed")
Transpiration_lgraph <- Transpiration_lgraph + stat_compare_means(aes(group = Treatment.1), label = "p.signif", method = "aov", hide.ns = T)
Transpiration_lgraph <- Transpiration_lgraph + ylab("Transpiration Rrate (mL H2O / day)") + xlab("Days after stress") + scale_color_aaas() + theme_bw()
Transpiration_lgraph <- Transpiration_lgraph + guides(color=guide_legend(title="Treatment")) + theme(legend.position = "none")
Transpiration_lgraph
## Warning: Removed 784 rows containing non-finite values (`stat_summary()`).
## Removed 784 rows containing non-finite values (`stat_summary()`).
## Warning: Removed 784 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 564 rows containing missing values (`geom_line()`).

TUE_lgraph <- ggplot(data=long, aes(x= Days.after.Salting, y=Area.smooth.TUE, group = Snapshot.ID.Tag, color = Treatment.1)) 
TUE_lgraph <- TUE_lgraph + geom_line(alpha = 0.1) 
TUE_lgraph <- TUE_lgraph + stat_summary(fun.data = mean_se, geom="ribbon", linetype=0, aes(group= Treatment.1), alpha=0.3)
TUE_lgraph <- TUE_lgraph + stat_summary(fun=mean, aes(group= Treatment.1),  size=0.7, geom="line", linetype = "dashed")
TUE_lgraph <- TUE_lgraph + stat_compare_means(aes(group = Treatment.1), label = "p.signif", method = "aov", hide.ns = T)
TUE_lgraph <- TUE_lgraph + ylab("Transpiration Use Efficiency (kpixels / mL H2O )") + xlab("Days after stress") + scale_color_aaas() + theme_bw()
TUE_lgraph <- TUE_lgraph + guides(color=guide_legend(title="Treatment")) + theme(legend.position = "none")
TUE_lgraph
## Warning: Removed 784 rows containing non-finite values (`stat_summary()`).
## Removed 784 rows containing non-finite values (`stat_summary()`).
## Warning: Removed 784 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 564 rows containing missing values (`geom_line()`).

OK - now let’s get to the destructivelly collected data:

list.files("Analysis_Graphs/Terminal_Violin_Plots/")
## [1] "Final_TPAScript_TerminalViolinPlots.R"      
## [2] "NaKratio violinplot.pdf"                    
## [3] "SDM violinplot.pdf"                         
## [4] "SFM violinplot_noleg.pdf"                   
## [5] "SFM violinplot.pdf"                         
## [6] "TissueK violinplot.pdf"                     
## [7] "TissueNa violinplot.pdf"                    
## [8] "TPAData_Corrected+SFM+FlameMeans_rmM104.csv"
FW_data <- read.csv("Analysis_Graphs/Terminal_Violin_Plots/TPAData_Corrected+SFM+FlameMeans_rmM104.csv")
FW_data
# install.packages("see")
library(see)
## 
## Attaching package: 'see'
## The following objects are masked from 'package:ggsci':
## 
##     scale_color_material, scale_colour_material, scale_fill_material
library(datasets)
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
FW_violin_paired <- ggplot(data = FW_data, mapping = aes(x = Treatment.1, y = SFM_me, fill = Treatment.1)) 
FW_violin_paired <- FW_violin_paired + geom_line(mapping = aes(group = Genotype.ID), alpha = 0.3, position = position_dodge(0.1))
FW_violin_paired <- FW_violin_paired + geom_violindot(dots_size = 0.08, position_dots = position_dodge(0.1), flip = c(1)) 
## Warning in geom_dotplot(binaxis = "y", mapping = mapping, data = data, dotsize =
## size_dots, : Ignoring unknown parameters: `flip`
FW_violin_paired <- FW_violin_paired + geom_point(mapping = aes(fill = Treatment.1, group = Genotype.ID), size = 1.5, shape = 21, position = position_dodge(0.1))
FW_violin_paired <- FW_violin_paired + stat_compare_means(aes(group = Treatment.1), label = "p.signif", method = "aov", hide.ns = T)
FW_violin_paired <- FW_violin_paired + theme_bw() + scale_fill_aaas() + theme(legend.position = "none") + ylab("Shoot Fresh Mass (g)") + xlab("") + scale_color_aaas()
FW_violin_paired  
## Warning: Removed 1 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 1 rows containing missing values (`stat_bindot()`).
## Warning: Removed 1 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 1 rows containing missing values (`geom_point()`).

summary(lm(SFM_me ~ Treatment.1, data = FW_data))
## 
## Call:
## lm(formula = SFM_me ~ Treatment.1, data = FW_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -31.424  -8.366  -1.514   7.522  45.907 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      57.7741     0.8353   69.17   <2e-16 ***
## Treatment.1SALT -27.7767     1.1827  -23.49   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.39 on 437 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.558,  Adjusted R-squared:  0.557 
## F-statistic: 551.6 on 1 and 437 DF,  p-value: < 2.2e-16
DW_violin_paired <- ggplot(data = FW_data, mapping = aes(x = Treatment.1, y = SDM_me, fill = Treatment.1)) 
DW_violin_paired <- DW_violin_paired + geom_line(mapping = aes(group = Genotype.ID), alpha = 0.3, position = position_dodge(0.1))
DW_violin_paired <- DW_violin_paired + geom_violindot(dots_size = 0.08, position_dots = position_dodge(0.1), flip = c(1)) 
## Warning in geom_dotplot(binaxis = "y", mapping = mapping, data = data, dotsize =
## size_dots, : Ignoring unknown parameters: `flip`
DW_violin_paired <- DW_violin_paired + geom_point(mapping = aes(fill = Treatment.1, group = Genotype.ID), size = 1.5, shape = 21, position = position_dodge(0.1))
DW_violin_paired <- DW_violin_paired + stat_compare_means(aes(group = Treatment.1), label = "p.signif", method = "aov", hide.ns = T)
DW_violin_paired <- DW_violin_paired + scale_fill_aaas() + theme_bw()
DW_violin_paired <- DW_violin_paired + theme(legend.position = "none") + ylab("Shoot Dry Mass (g)") + xlab("")
DW_violin_paired   
## Warning: Removed 1 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 1 rows containing missing values (`stat_bindot()`).
## Warning: Removed 1 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 1 rows containing missing values (`geom_point()`).

FW_data$TissueNa_me <- as.numeric(FW_data$TissueNa_me)
Na_violin_paired <- ggplot(data = FW_data, mapping = aes(x = Treatment.1, y = TissueNa_me, fill = Treatment.1)) 
Na_violin_paired <- Na_violin_paired + geom_line(mapping = aes(group = Genotype.ID), alpha = 0.3, position = position_dodge(0.1))
Na_violin_paired <- Na_violin_paired + geom_violindot(dots_size = 0.01, position_dots = position_dodge(0.1), flip = c(1)) 
## Warning in geom_dotplot(binaxis = "y", mapping = mapping, data = data, dotsize =
## size_dots, : Ignoring unknown parameters: `flip`
Na_violin_paired <- Na_violin_paired + geom_point(mapping = aes(fill = Treatment.1, group = Genotype.ID), size = 1.5, shape = 21, position = position_dodge(0.1))
Na_violin_paired <- Na_violin_paired + stat_compare_means(aes(group = Treatment.1), label = "p.signif", method = "aov", hide.ns = T)
Na_violin_paired <- Na_violin_paired + scale_fill_aaas() + theme_bw()
Na_violin_paired <- Na_violin_paired + theme(legend.position = "none") + ylab("Tissue [Na+] (mmol / g DM)") + xlab("")
Na_violin_paired
## Warning: Removed 144 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 144 rows containing missing values (`stat_bindot()`).
## Warning: Removed 144 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 144 rows containing missing values (`geom_line()`).
## Warning: Removed 144 rows containing missing values (`geom_point()`).

summary(lm(TissueNa_me ~ Treatment.1, data = FW_data))
## 
## Call:
## lm(formula = TissueNa_me ~ Treatment.1, data = FW_data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.26643 -0.06143 -0.00958  0.04732  0.56357 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.25940    0.01317   19.69   <2e-16 ***
## Treatment.1SALT  0.21702    0.01535   14.14   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1163 on 294 degrees of freedom
##   (144 observations deleted due to missingness)
## Multiple R-squared:  0.4048, Adjusted R-squared:  0.4027 
## F-statistic: 199.9 on 1 and 294 DF,  p-value: < 2.2e-16
FW_data$TissueK_me <- as.numeric(FW_data$TissueK_me)
K_violin_paired <- ggplot(data = FW_data, mapping = aes(x = Treatment.1, y = TissueK_me, fill = Treatment.1)) 
K_violin_paired <- K_violin_paired + geom_line(mapping = aes(group = Genotype.ID), alpha = 0.3, position = position_dodge(0.1))
K_violin_paired <- K_violin_paired + geom_violindot(dots_size = 0.01, position_dots = position_dodge(0.1), flip = c(1)) 
## Warning in geom_dotplot(binaxis = "y", mapping = mapping, data = data, dotsize =
## size_dots, : Ignoring unknown parameters: `flip`
K_violin_paired <- K_violin_paired + geom_point(mapping = aes(fill = Treatment.1, group = Genotype.ID), size = 1.5, shape = 21, position = position_dodge(0.1))
K_violin_paired <- K_violin_paired + scale_color_aaas() + theme_bw()
K_violin_paired <- K_violin_paired + stat_compare_means(aes(group = Treatment.1), label = "p.signif", method = "aov", hide.ns = T)
K_violin_paired <- K_violin_paired + theme(legend.position = "none") + scale_fill_aaas() + ylab("Tissue [K+] (mmol / g DM)") + xlab("")
K_violin_paired
## Warning: Removed 144 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 144 rows containing missing values (`stat_bindot()`).
## Warning: Removed 144 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 144 rows containing missing values (`geom_line()`).
## Warning: Removed 144 rows containing missing values (`geom_point()`).

summary(lm(TissueK_me ~ Treatment.1, data = FW_data))
## 
## Call:
## lm(formula = TissueK_me ~ Treatment.1, data = FW_data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.42205 -0.11205 -0.01944  0.10222  0.60056 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      1.57205    0.01948  80.697   <2e-16 ***
## Treatment.1SALT  0.02072    0.02270   0.913    0.362    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1721 on 294 degrees of freedom
##   (144 observations deleted due to missingness)
## Multiple R-squared:  0.002827,   Adjusted R-squared:  -0.0005648 
## F-statistic: 0.8335 on 1 and 294 DF,  p-value: 0.362
library(cowplot)
## 
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggpubr':
## 
##     get_legend
TPA_fig_long <- plot_grid(AreaAGR_lgraph, AreaRGR_lgraph, Transpiration_lgraph, TUE_lgraph, labels = "AUTO", ncol = 1)
## Warning: Removed 533 rows containing non-finite values (`stat_summary()`).
## Removed 533 rows containing non-finite values (`stat_summary()`).
## Warning: Removed 533 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 531 rows containing missing values (`geom_line()`).
## Warning: Removed 533 rows containing non-finite values (`stat_summary()`).
## Removed 533 rows containing non-finite values (`stat_summary()`).
## Warning: Removed 533 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 531 rows containing missing values (`geom_line()`).
## Warning: Removed 784 rows containing non-finite values (`stat_summary()`).
## Removed 784 rows containing non-finite values (`stat_summary()`).
## Warning: Removed 784 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 564 rows containing missing values (`geom_line()`).
## Warning: Removed 784 rows containing non-finite values (`stat_summary()`).
## Removed 784 rows containing non-finite values (`stat_summary()`).
## Warning: Removed 784 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 564 rows containing missing values (`geom_line()`).
TPA_fig_long

pdf("TPA_fig_long.pdf", height = 10, width = 5)
plot(TPA_fig_long)
dev.off()   
## quartz_off_screen 
##                 2
TPA_terminal.harvest <- plot_grid(FW_violin_paired, DW_violin_paired, Na_violin_paired, K_violin_paired, ncol = 2, labels = "AUTO")
## Warning: Removed 1 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 1 rows containing missing values (`stat_bindot()`).
## Warning: Removed 1 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 1 rows containing missing values (`geom_point()`).
## Warning: Removed 1 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 1 rows containing missing values (`stat_bindot()`).
## Warning: Removed 1 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 1 rows containing missing values (`geom_point()`).
## Warning: Removed 144 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 144 rows containing missing values (`stat_bindot()`).
## Warning: Removed 144 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 144 rows containing missing values (`geom_line()`).
## Warning: Removed 144 rows containing missing values (`geom_point()`).
## Warning: Removed 144 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 144 rows containing missing values (`stat_bindot()`).
## Warning: Removed 144 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 144 rows containing missing values (`geom_line()`).
## Warning: Removed 144 rows containing missing values (`geom_point()`).
TPA_terminal.harvest

pdf("TPA_terminal.harvest.pdf", height = 8, width = 8)
plot(TPA_terminal.harvest)
dev.off()   
## quartz_off_screen 
##                 2

Correlations

Let’s look if there is a correlation between the Projected shoot area and the FSM

long
colnames(long)
##  [1] "X"                                 "Snapshot.ID.Tag"                  
##  [3] "Days"                              "xDays"                            
##  [5] "Smarthouse"                        "Evap.Cart"                        
##  [7] "Lane"                              "Position"                         
##  [9] "Snapshot.Time.Stamp"               "xPosn"                            
## [11] "Reps"                              "Hour"                             
## [13] "Genotype.ID"                       "Treatment.1"                      
## [15] "Weight.Before"                     "Weight.After"                     
## [17] "Water.Amount"                      "Water.Loss"                       
## [19] "Area"                              "Area.SV1"                         
## [21] "Area.SV2"                          "Area.TV"                          
## [23] "Boundary.Points.To.Area.Ratio.SV1" "Boundary.Points.To.Area.Ratio.SV2"
## [25] "Boundary.Points.To.Area.Ratio.TV"  "Caliper.Length.SV1"               
## [27] "Caliper.Length.SV2"                "Caliper.Length.TV"                
## [29] "Compactness.SV1"                   "Compactness.SV2"                  
## [31] "Compactness.TV"                    "Convex.Hull.Area.SV1"             
## [33] "Convex.Hull.Area.SV2"              "Convex.Hull.Area.TV"              
## [35] "Center.Of.Mass.Y.SV1"              "Center.Of.Mass.Y.SV2"             
## [37] "Max.Dist.Above.Horizon.Line.SV1"   "Max.Dist.Above.Horizon.Line.SV2"  
## [39] "Evaporation"                       "Days.after.Salting"               
## [41] "Transpiration"                     "Days.diffs"                       
## [43] "Area.AGR"                          "Area.RGR"                         
## [45] "Area.TUE"                          "Transpiration.rate"               
## [47] "TUE.cum"                           "Transpiration.Cum"                
## [49] "Transpiration.rate.smooth"         "Area.smooth"                      
## [51] "Area.smooth.AGR"                   "Area.smooth.RGR"                  
## [53] "Transpiration.smooth"              "Area.smooth.TUE"
cur <- read.csv("TPAData_Corrected+SFM+FlameMeans_rmM104.csv")
dim(cur)
## [1] 440  34
cur <- cur[,c(1:2, 33:34)]
cur
long2 <- long[,c(13, 40,14,19)]
long2
library(doBy)
## 
## Attaching package: 'doBy'
## The following object is masked from 'package:dplyr':
## 
##     order_by
long2s <- summaryBy(Area ~ Genotype.ID + Treatment.1 + Days.after.Salting, data = long2)
long2s <- subset(long2s, long2s$Days.after.Salting == 14)
unique(long2s$Days)
## [1] 14
## Levels: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
all_together <- merge(cur, long2s, by = c("Genotype.ID", "Treatment.1"))
all_together.nona <- na.omit(all_together)
PSA_vs_SFM <- ggscatter(all_together, x = "SFM_me", y = "Area.mean",
                        add = "reg.line", xlab = "SFM (g)", ylab = "PSA (a.u.)",
                        color = "Treatment.1", palette = "aaas",  
                        rug = TRUE) + stat_cor(aes(color = Treatment.1), label.x = 3)
PSA_vs_SFM
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 83 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 83 rows containing non-finite values (`stat_cor()`).
## Warning: Removed 83 rows containing missing values (`geom_point()`).

PSA_vs_SDM <- ggscatter(all_together, x = "SDM_me", y = "Area.mean",
                        add = "reg.line", xlab = "SDM (g)", ylab = "PSA (a.u.)",
                        color = "Treatment.1", palette = "aaas",  
                        rug = TRUE) + stat_cor(aes(color = Treatment.1), label.x = 3)
PSA_vs_SDM
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 83 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 83 rows containing non-finite values (`stat_cor()`).
## Warning: Removed 83 rows containing missing values (`geom_point()`).

pdf("Fig.S.ShootFreshMass_vs_PSA.pdf", width = 10, height = 5)
plot_grid(PSA_vs_SFM, PSA_vs_SDM, labels = "AUTO", ncol = 2)
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 83 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 83 rows containing non-finite values (`stat_cor()`).
## Warning: Removed 83 rows containing missing values (`geom_point()`).
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 83 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 83 rows containing non-finite values (`stat_cor()`).
## Warning: Removed 83 rows containing missing values (`geom_point()`).
dev.off()
## quartz_off_screen 
##                 2

INDICES and Best accessions

Start with the appropriate data:

TPA<-read.csv("TPAData_Corrected+SFM+FlameMeans_rmM104.csv", header=TRUE, sep=",")
TPA<-TPA[,c(1,2,4,5,7,9,10,12,14,15,17,19,20,22,25,27,33)]
TPA

separate into two files to calculate indices:

TPA.C <- subset(TPA, TPA$Treatment.1 == "CONTROL")
TPA.S <- subset(TPA, TPA$Treatment.1 == "SALT")
colnames(TPA.C)[3:17] <- paste(colnames(TPA.C)[3:17], ".C")
colnames(TPA.S)[3:17] <- paste(colnames(TPA.S)[3:17], ".S")
TPA.C <- TPA.C[2:17]
TPA.S <- TPA.S[2:17]
TPA.f <- merge(TPA.C, TPA.S, by = "Genotype.ID")
TPA.f

then - let’s calculate the indices:

ST1: STI1 = S/C ST2: TOL = C-S ST3: MP = (C+S)/2 ST4: GMP = sqrt(CxS) ST5: SSI = ( (C-S)/C ) / ( (C.me-S.me)/C.me ) ST6: STI2 = (C*S)/(C.me)^2 ST7: SWP = S/sqrt(C)

colnames(TPA.f) <- gsub(" ", "", colnames(TPA.f))
colnames(TPA.f)
##  [1] "Genotype.ID"                            
##  [2] "Area.smooth.AGR.0to5.BLUE.C"            
##  [3] "Area.smooth.AGR.6to9.BLUE.C"            
##  [4] "Area.smooth.AGR.10to14.BLUE.C"          
##  [5] "Area.smooth.RGR.0to5.BLUE.C"            
##  [6] "Area.smooth.RGR.6to9.BLUE.C"            
##  [7] "Area.smooth.RGR.10to14.BLUE.C"          
##  [8] "Area.smooth.TUE.0to5.BLUE.C"            
##  [9] "Area.smooth.TUE.6to9.BLUE.C"            
## [10] "Area.smooth.TUE.10to14.BLUE.C"          
## [11] "Transpiration.smooth.rate.0to5.BLUE.C"  
## [12] "Transpiration.smooth.rate.6to9.BLUE.C"  
## [13] "Transpiration.smooth.rate.10to14.BLUE.C"
## [14] "TissueK_me.C"                           
## [15] "TissueNa_me.C"                          
## [16] "SFM_me.C"                               
## [17] "Area.smooth.AGR.0to5.BLUE.S"            
## [18] "Area.smooth.AGR.6to9.BLUE.S"            
## [19] "Area.smooth.AGR.10to14.BLUE.S"          
## [20] "Area.smooth.RGR.0to5.BLUE.S"            
## [21] "Area.smooth.RGR.6to9.BLUE.S"            
## [22] "Area.smooth.RGR.10to14.BLUE.S"          
## [23] "Area.smooth.TUE.0to5.BLUE.S"            
## [24] "Area.smooth.TUE.6to9.BLUE.S"            
## [25] "Area.smooth.TUE.10to14.BLUE.S"          
## [26] "Transpiration.smooth.rate.0to5.BLUE.S"  
## [27] "Transpiration.smooth.rate.6to9.BLUE.S"  
## [28] "Transpiration.smooth.rate.10to14.BLUE.S"
## [29] "TissueK_me.S"                           
## [30] "TissueNa_me.S"                          
## [31] "SFM_me.S"
TPA.f$AGR.0to5.ST1 <- TPA.f$Area.smooth.AGR.0to5.BLUE.S / TPA.f$Area.smooth.AGR.0to5.BLUE.C
TPA.f$AGR.0to5.ST2 <- TPA.f$Area.smooth.AGR.0to5.BLUE.C - TPA.f$Area.smooth.AGR.0to5.BLUE.S
TPA.f$AGR.0to5.ST3 <- (TPA.f$Area.smooth.AGR.0to5.BLUE.C + TPA.f$Area.smooth.AGR.0to5.BLUE.S)/2
TPA.f$AGR.0to5.ST4 <- sqrt(TPA.f$Area.smooth.AGR.0to5.BLUE.C * TPA.f$Area.smooth.AGR.0to5.BLUE.S)
TPA.f$AGR.0to5.ST5 <- ((TPA.f$Area.smooth.AGR.0to5.BLUE.C + TPA.f$Area.smooth.AGR.0to5.BLUE.S)/TPA.f$Area.smooth.AGR.0to5.BLUE.C) / ((mean(na.omit(TPA.f$Area.smooth.AGR.0to5.BLUE.C)) - mean(na.omit(TPA.f$Area.smooth.AGR.0to5.BLUE.S)))/mean(na.omit(TPA.f$Area.smooth.AGR.0to5.BLUE.C)))
TPA.f$AGR.0to5.ST6 <- ((TPA.f$Area.smooth.AGR.0to5.BLUE.C * TPA.f$Area.smooth.AGR.0to5.BLUE.S)/(mean(na.omit(TPA.f$Area.smooth.AGR.0to5.BLUE.C))^2))
TPA.f$AGR.0to5.ST7 <- TPA.f$Area.smooth.AGR.0to5.BLUE.S / sqrt(TPA.f$Area.smooth.AGR.0to5.BLUE.C)

TPA.f$AGR.6to9.ST1 <- TPA.f$Area.smooth.AGR.6to9.BLUE.S / TPA.f$Area.smooth.AGR.6to9.BLUE.C
TPA.f$AGR.6to9.ST2 <- TPA.f$Area.smooth.AGR.6to9.BLUE.C - TPA.f$Area.smooth.AGR.6to9.BLUE.S
TPA.f$AGR.6to9.ST3 <- (TPA.f$Area.smooth.AGR.6to9.BLUE.C + TPA.f$Area.smooth.AGR.6to9.BLUE.S)/2
TPA.f$AGR.6to9.ST4 <- sqrt(TPA.f$Area.smooth.AGR.6to9.BLUE.C * TPA.f$Area.smooth.AGR.6to9.BLUE.S)
TPA.f$AGR.6to9.ST5 <- ((TPA.f$Area.smooth.AGR.6to9.BLUE.C + TPA.f$Area.smooth.AGR.6to9.BLUE.S)/TPA.f$Area.smooth.AGR.6to9.BLUE.C) / ((mean(na.omit(TPA.f$Area.smooth.AGR.6to9.BLUE.C)) - mean(na.omit(TPA.f$Area.smooth.AGR.6to9.BLUE.S)))/mean(na.omit(TPA.f$Area.smooth.AGR.6to9.BLUE.C)))
TPA.f$AGR.6to9.ST6 <- ((TPA.f$Area.smooth.AGR.6to9.BLUE.C * TPA.f$Area.smooth.AGR.6to9.BLUE.S)/(mean(na.omit(TPA.f$Area.smooth.AGR.6to9.BLUE.C))^2))
TPA.f$AGR.6to9.ST7 <- TPA.f$Area.smooth.AGR.6to9.BLUE.S / sqrt(TPA.f$Area.smooth.AGR.6to9.BLUE.C)

TPA.f$AGR.10to14.ST1 <- TPA.f$Area.smooth.AGR.10to14.BLUE.S / TPA.f$Area.smooth.AGR.10to14.BLUE.C
TPA.f$AGR.10to14.ST2 <- TPA.f$Area.smooth.AGR.10to14.BLUE.C - TPA.f$Area.smooth.AGR.10to14.BLUE.S
TPA.f$AGR.10to14.ST3 <- (TPA.f$Area.smooth.AGR.10to14.BLUE.C + TPA.f$Area.smooth.AGR.10to14.BLUE.S)/2
TPA.f$AGR.10to14.ST4 <- sqrt(TPA.f$Area.smooth.AGR.10to14.BLUE.C * TPA.f$Area.smooth.AGR.10to14.BLUE.S)
TPA.f$AGR.10to14.ST5 <- ((TPA.f$Area.smooth.AGR.10to14.BLUE.C + TPA.f$Area.smooth.AGR.10to14.BLUE.S)/TPA.f$Area.smooth.AGR.10to14.BLUE.C) / ((mean(na.omit(TPA.f$Area.smooth.AGR.10to14.BLUE.C)) - mean(na.omit(TPA.f$Area.smooth.AGR.10to14.BLUE.S)))/mean(na.omit(TPA.f$Area.smooth.AGR.10to14.BLUE.C)))
TPA.f$AGR.10to14.ST6 <- ((TPA.f$Area.smooth.AGR.10to14.BLUE.C * TPA.f$Area.smooth.AGR.10to14.BLUE.S)/(mean(na.omit(TPA.f$Area.smooth.AGR.10to14.BLUE.C))^2))
TPA.f$AGR.10to14.ST7 <- TPA.f$Area.smooth.AGR.10to14.BLUE.S / sqrt(TPA.f$Area.smooth.AGR.10to14.BLUE.C)

TPA.f$RGR.0to5.ST1 <- TPA.f$Area.smooth.RGR.0to5.BLUE.S / TPA.f$Area.smooth.RGR.0to5.BLUE.C
TPA.f$RGR.0to5.ST2 <- TPA.f$Area.smooth.RGR.0to5.BLUE.C - TPA.f$Area.smooth.RGR.0to5.BLUE.S
TPA.f$RGR.0to5.ST3 <- (TPA.f$Area.smooth.RGR.0to5.BLUE.C + TPA.f$Area.smooth.RGR.0to5.BLUE.S)/2
TPA.f$RGR.0to5.ST4 <- sqrt(TPA.f$Area.smooth.RGR.0to5.BLUE.C * TPA.f$Area.smooth.RGR.0to5.BLUE.S)
TPA.f$RGR.0to5.ST5 <- ((TPA.f$Area.smooth.RGR.0to5.BLUE.C + TPA.f$Area.smooth.RGR.0to5.BLUE.S)/TPA.f$Area.smooth.RGR.0to5.BLUE.C) / ((mean(na.omit(TPA.f$Area.smooth.RGR.0to5.BLUE.C)) - mean(na.omit(TPA.f$Area.smooth.RGR.0to5.BLUE.S)))/mean(na.omit(TPA.f$Area.smooth.RGR.0to5.BLUE.C)))
TPA.f$RGR.0to5.ST6 <- ((TPA.f$Area.smooth.RGR.0to5.BLUE.C * TPA.f$Area.smooth.RGR.0to5.BLUE.S)/(mean(na.omit(TPA.f$Area.smooth.RGR.0to5.BLUE.C))^2))
TPA.f$RGR.0to5.ST7 <- TPA.f$Area.smooth.RGR.0to5.BLUE.S / sqrt(TPA.f$Area.smooth.RGR.0to5.BLUE.C)

TPA.f$RGR.6to9.ST1 <- TPA.f$Area.smooth.RGR.6to9.BLUE.S / TPA.f$Area.smooth.RGR.6to9.BLUE.C
TPA.f$RGR.6to9.ST2 <- TPA.f$Area.smooth.RGR.6to9.BLUE.C - TPA.f$Area.smooth.RGR.6to9.BLUE.S
TPA.f$RGR.6to9.ST3 <- (TPA.f$Area.smooth.RGR.6to9.BLUE.C + TPA.f$Area.smooth.RGR.6to9.BLUE.S)/2
TPA.f$RGR.6to9.ST4 <- sqrt(TPA.f$Area.smooth.RGR.6to9.BLUE.C * TPA.f$Area.smooth.RGR.6to9.BLUE.S)
TPA.f$RGR.6to9.ST5 <- ((TPA.f$Area.smooth.RGR.6to9.BLUE.C + TPA.f$Area.smooth.RGR.6to9.BLUE.S)/TPA.f$Area.smooth.RGR.6to9.BLUE.C) / ((mean(na.omit(TPA.f$Area.smooth.RGR.6to9.BLUE.C)) - mean(TPA.f$Area.smooth.RGR.6to9.BLUE.S))/mean(na.omit(TPA.f$Area.smooth.RGR.6to9.BLUE.C)))
TPA.f$RGR.6to9.ST6 <- ((TPA.f$Area.smooth.RGR.6to9.BLUE.C * TPA.f$Area.smooth.RGR.6to9.BLUE.S)/(mean(na.omit(TPA.f$Area.smooth.RGR.6to9.BLUE.C))^2))
TPA.f$RGR.6to9.ST7 <- TPA.f$Area.smooth.RGR.6to9.BLUE.S / sqrt(TPA.f$Area.smooth.RGR.6to9.BLUE.C)

TPA.f$RGR.10to14.ST1 <- TPA.f$Area.smooth.RGR.10to14.BLUE.S / TPA.f$Area.smooth.RGR.10to14.BLUE.C
TPA.f$RGR.10to14.ST2 <- TPA.f$Area.smooth.RGR.10to14.BLUE.C - TPA.f$Area.smooth.RGR.10to14.BLUE.S
TPA.f$RGR.10to14.ST3 <- (TPA.f$Area.smooth.RGR.10to14.BLUE.C + TPA.f$Area.smooth.RGR.10to14.BLUE.S)/2
TPA.f$RGR.10to14.ST4 <- sqrt(TPA.f$Area.smooth.RGR.10to14.BLUE.C * TPA.f$Area.smooth.RGR.10to14.BLUE.S)
TPA.f$RGR.10to14.ST5 <- ((TPA.f$Area.smooth.RGR.10to14.BLUE.C + TPA.f$Area.smooth.RGR.10to14.BLUE.S)/TPA.f$Area.smooth.RGR.10to14.BLUE.C) / ((mean(na.omit(TPA.f$Area.smooth.RGR.10to14.BLUE.C)) - mean(na.omit(TPA.f$Area.smooth.RGR.10to14.BLUE.S)))/mean(na.omit(TPA.f$Area.smooth.RGR.10to14.BLUE.C)))
TPA.f$RGR.10to14.ST6 <- ((TPA.f$Area.smooth.RGR.10to14.BLUE.C * TPA.f$Area.smooth.RGR.10to14.BLUE.S)/(mean(na.omit(TPA.f$Area.smooth.RGR.10to14.BLUE.C))^2))
TPA.f$RGR.10to14.ST7 <- TPA.f$Area.smooth.RGR.10to14.BLUE.S / sqrt(TPA.f$Area.smooth.RGR.10to14.BLUE.C)

TPA.f$TUE.0to5.ST1 <- TPA.f$Area.smooth.TUE.0to5.BLUE.S / TPA.f$Area.smooth.TUE.0to5.BLUE.C
TPA.f$TUE.0to5.ST2 <- TPA.f$Area.smooth.TUE.0to5.BLUE.C - TPA.f$Area.smooth.TUE.0to5.BLUE.S
TPA.f$TUE.0to5.ST3 <- (TPA.f$Area.smooth.TUE.0to5.BLUE.C + TPA.f$Area.smooth.TUE.0to5.BLUE.S)/2
TPA.f$TUE.0to5.ST4 <- sqrt(TPA.f$Area.smooth.TUE.0to5.BLUE.C * TPA.f$Area.smooth.TUE.0to5.BLUE.S)
TPA.f$TUE.0to5.ST5 <- ((TPA.f$Area.smooth.TUE.0to5.BLUE.C + TPA.f$Area.smooth.TUE.0to5.BLUE.S)/TPA.f$Area.smooth.TUE.0to5.BLUE.C) / ((mean(na.omit(TPA.f$Area.smooth.TUE.0to5.BLUE.C)) - mean(na.omit(TPA.f$Area.smooth.TUE.0to5.BLUE.S)))/mean(na.omit(TPA.f$Area.smooth.TUE.0to5.BLUE.C)))
TPA.f$TUE.0to5.ST6 <- ((TPA.f$Area.smooth.TUE.0to5.BLUE.C * TPA.f$Area.smooth.TUE.0to5.BLUE.S)/(mean(na.omit(TPA.f$Area.smooth.TUE.0to5.BLUE.C))^2))
TPA.f$TUE.0to5.ST7 <- TPA.f$Area.smooth.TUE.0to5.BLUE.S / sqrt(TPA.f$Area.smooth.TUE.0to5.BLUE.C)

TPA.f$TUE.6to9.ST1 <- TPA.f$Area.smooth.TUE.6to9.BLUE.S / TPA.f$Area.smooth.TUE.6to9.BLUE.C
TPA.f$TUE.6to9.ST2 <- TPA.f$Area.smooth.TUE.6to9.BLUE.C - TPA.f$Area.smooth.TUE.6to9.BLUE.S
TPA.f$TUE.6to9.ST3 <- (TPA.f$Area.smooth.TUE.6to9.BLUE.C + TPA.f$Area.smooth.TUE.6to9.BLUE.S)/2
TPA.f$TUE.6to9.ST4 <- sqrt(TPA.f$Area.smooth.TUE.6to9.BLUE.C * TPA.f$Area.smooth.TUE.6to9.BLUE.S)
TPA.f$TUE.6to9.ST5 <- ((TPA.f$Area.smooth.TUE.6to9.BLUE.C + TPA.f$Area.smooth.TUE.6to9.BLUE.S)/TPA.f$Area.smooth.TUE.6to9.BLUE.C) / ((mean(na.omit(TPA.f$Area.smooth.TUE.6to9.BLUE.C)) - mean(na.omit(TPA.f$Area.smooth.TUE.6to9.BLUE.S)))/mean(na.omit(TPA.f$Area.smooth.TUE.6to9.BLUE.C)))
TPA.f$TUE.6to9.ST6 <- ((TPA.f$Area.smooth.TUE.6to9.BLUE.C * TPA.f$Area.smooth.TUE.6to9.BLUE.S)/(mean(na.omit(TPA.f$Area.smooth.TUE.6to9.BLUE.C))^2))
TPA.f$TUE.6to9.ST7 <- TPA.f$Area.smooth.TUE.6to9.BLUE.S / sqrt(TPA.f$Area.smooth.TUE.6to9.BLUE.C)

TPA.f$TUE.10to14.ST1 <- TPA.f$Area.smooth.TUE.10to14.BLUE.S / TPA.f$Area.smooth.TUE.10to14.BLUE.C
TPA.f$TUE.10to14.ST2 <- TPA.f$Area.smooth.TUE.10to14.BLUE.C - TPA.f$Area.smooth.TUE.10to14.BLUE.S
TPA.f$TUE.10to14.ST3 <- (TPA.f$Area.smooth.TUE.10to14.BLUE.C + TPA.f$Area.smooth.TUE.10to14.BLUE.S)/2
TPA.f$TUE.10to14.ST4 <- sqrt(TPA.f$Area.smooth.TUE.10to14.BLUE.C * TPA.f$Area.smooth.TUE.10to14.BLUE.S)
TPA.f$TUE.10to14.ST5 <- ((TPA.f$Area.smooth.TUE.10to14.BLUE.C + TPA.f$Area.smooth.TUE.10to14.BLUE.S)/TPA.f$Area.smooth.TUE.10to14.BLUE.C) / ((mean(na.omit(TPA.f$Area.smooth.TUE.10to14.BLUE.C)) - mean(na.omit(TPA.f$Area.smooth.TUE.10to14.BLUE.S)))/mean(na.omit(TPA.f$Area.smooth.TUE.10to14.BLUE.C)))
TPA.f$TUE.10to14.ST6 <- ((TPA.f$Area.smooth.TUE.10to14.BLUE.C * TPA.f$Area.smooth.TUE.10to14.BLUE.S)/(mean(na.omit(TPA.f$Area.smooth.TUE.10to14.BLUE.C))^2))
TPA.f$TUE.10to14.ST7 <- TPA.f$Area.smooth.TUE.10to14.BLUE.S / sqrt(TPA.f$Area.smooth.TUE.10to14.BLUE.C)

TPA.f$TSR.0to5.ST1 <- TPA.f$Transpiration.smooth.rate.0to5.BLUE.S / TPA.f$Transpiration.smooth.rate.0to5.BLUE.C
TPA.f$TSR.0to5.ST2 <- TPA.f$Transpiration.smooth.rate.0to5.BLUE.C - TPA.f$Transpiration.smooth.rate.0to5.BLUE.S
TPA.f$TSR.0to5.ST3 <- (TPA.f$Transpiration.smooth.rate.0to5.BLUE.C + TPA.f$Transpiration.smooth.rate.0to5.BLUE.S)/2
TPA.f$TSR.0to5.ST4 <- sqrt(TPA.f$Transpiration.smooth.rate.0to5.BLUE.C * TPA.f$Transpiration.smooth.rate.0to5.BLUE.S)
TPA.f$TSR.0to5.ST5 <- ((TPA.f$Transpiration.smooth.rate.0to5.BLUE.C + TPA.f$Transpiration.smooth.rate.0to5.BLUE.S)/TPA.f$Transpiration.smooth.rate.0to5.BLUE.C) / ((mean(na.omit(TPA.f$Transpiration.smooth.rate.0to5.BLUE.C)) - mean(na.omit(TPA.f$Transpiration.smooth.rate.0to5.BLUE.S)))/mean(na.omit(TPA.f$Transpiration.smooth.rate.0to5.BLUE.C)))
TPA.f$TSR.0to5.ST6 <- ((TPA.f$Transpiration.smooth.rate.0to5.BLUE.C * TPA.f$Transpiration.smooth.rate.0to5.BLUE.S)/(mean(na.omit(TPA.f$Transpiration.smooth.rate.0to5.BLUE.C))^2))
TPA.f$TSR.0to5.ST7 <- TPA.f$Transpiration.smooth.rate.0to5.BLUE.S / sqrt(TPA.f$Transpiration.smooth.rate.0to5.BLUE.C)

TPA.f$TSR.6to9.ST1 <- TPA.f$Transpiration.smooth.rate.6to9.BLUE.S / TPA.f$Transpiration.smooth.rate.6to9.BLUE.C
TPA.f$TSR.6to9.ST2 <- TPA.f$Transpiration.smooth.rate.6to9.BLUE.C - TPA.f$Transpiration.smooth.rate.6to9.BLUE.S
TPA.f$TSR.6to9.ST3 <- (TPA.f$Transpiration.smooth.rate.6to9.BLUE.C + TPA.f$Transpiration.smooth.rate.6to9.BLUE.S)/2
TPA.f$TSR.6to9.ST4 <- sqrt(TPA.f$Transpiration.smooth.rate.6to9.BLUE.C * TPA.f$Transpiration.smooth.rate.6to9.BLUE.S)
TPA.f$TSR.6to9.ST5 <- ((TPA.f$Transpiration.smooth.rate.6to9.BLUE.C + TPA.f$Transpiration.smooth.rate.6to9.BLUE.S)/TPA.f$Transpiration.smooth.rate.6to9.BLUE.C) / ((mean(na.omit(TPA.f$Transpiration.smooth.rate.6to9.BLUE.C)) - mean(na.omit(TPA.f$Transpiration.smooth.rate.6to9.BLUE.S)))/mean(na.omit(TPA.f$Transpiration.smooth.rate.6to9.BLUE.C)))
TPA.f$TSR.6to9.ST6 <- ((TPA.f$Transpiration.smooth.rate.6to9.BLUE.C * TPA.f$Transpiration.smooth.rate.6to9.BLUE.S)/(mean(na.omit(TPA.f$Transpiration.smooth.rate.6to9.BLUE.C))^2))
TPA.f$TSR.6to9.ST7 <- TPA.f$Transpiration.smooth.rate.6to9.BLUE.S / sqrt(TPA.f$Transpiration.smooth.rate.6to9.BLUE.C)

TPA.f$TSR.10to14.ST1 <- TPA.f$Transpiration.smooth.rate.10to14.BLUE.S / TPA.f$Transpiration.smooth.rate.10to14.BLUE.C
TPA.f$TSR.10to14.ST2 <- TPA.f$Transpiration.smooth.rate.10to14.BLUE.C - TPA.f$Transpiration.smooth.rate.10to14.BLUE.S
TPA.f$TSR.10to14.ST3 <- (TPA.f$Transpiration.smooth.rate.10to14.BLUE.C + TPA.f$Transpiration.smooth.rate.10to14.BLUE.S)/2
TPA.f$TSR.10to14.ST4 <- sqrt(TPA.f$Transpiration.smooth.rate.10to14.BLUE.C * TPA.f$Transpiration.smooth.rate.10to14.BLUE.S)
TPA.f$TSR.10to14.ST5 <- ((TPA.f$Transpiration.smooth.rate.10to14.BLUE.C + TPA.f$Transpiration.smooth.rate.10to14.BLUE.S)/TPA.f$Transpiration.smooth.rate.10to14.BLUE.C) / ((mean(na.omit(TPA.f$Transpiration.smooth.rate.10to14.BLUE.C)) - mean(na.omit(TPA.f$Transpiration.smooth.rate.10to14.BLUE.S)))/mean(na.omit(TPA.f$Transpiration.smooth.rate.10to14.BLUE.C)))
TPA.f$TSR.10to14.ST6 <- ((TPA.f$Transpiration.smooth.rate.10to14.BLUE.C * TPA.f$Transpiration.smooth.rate.10to14.BLUE.S)/(mean(na.omit(TPA.f$Transpiration.smooth.rate.10to14.BLUE.C))^2))
TPA.f$TSR.10to14.ST7 <- TPA.f$Transpiration.smooth.rate.10to14.BLUE.S / sqrt(TPA.f$Transpiration.smooth.rate.10to14.BLUE.C)

TPA.f$TissueK.ST1 <- TPA.f$TissueK_me.S / TPA.f$TissueK_me.C
TPA.f$TissueK.ST2 <- TPA.f$TissueK_me.C - TPA.f$TissueK_me.S
TPA.f$TissueK.ST3 <- (TPA.f$TissueK_me.C + TPA.f$TissueK_me.S)/2
TPA.f$TissueK.ST4 <- sqrt(TPA.f$TissueK_me.C * TPA.f$TissueK_me.S)
TPA.f$TissueK.ST5 <- ((TPA.f$TissueK_me.C + TPA.f$TissueK_me.S)/TPA.f$TissueK_me.C) / ((mean(na.omit(TPA.f$TissueK_me.C)) - mean(na.omit(TPA.f$TissueK_me.S)))/mean(na.omit(TPA.f$TissueK_me.C)))
TPA.f$TissueK.ST6 <- ((TPA.f$TissueK_me.C * TPA.f$TissueK_me.S)/(mean(na.omit(TPA.f$TissueK_me.C))^2))
TPA.f$TissueK.ST7 <- TPA.f$TissueK_me.S / sqrt(TPA.f$TissueK_me.C)

TPA.f$TissueNa.ST1 <- TPA.f$TissueNa_me.S / TPA.f$TissueNa_me.C
TPA.f$TissueNa.ST2 <- TPA.f$TissueNa_me.C - TPA.f$TissueNa_me.S
TPA.f$TissueNa.ST3 <- (TPA.f$TissueNa_me.C + TPA.f$TissueNa_me.S)/2
TPA.f$TissueNa.ST4 <- sqrt(TPA.f$TissueNa_me.C * TPA.f$TissueNa_me.S)
TPA.f$TissueNa.ST5 <- ((TPA.f$TissueNa_me.C + TPA.f$TissueNa_me.S)/TPA.f$TissueNa_me.C) / ((mean(na.omit(TPA.f$TissueNa_me.C)) - mean(na.omit(TPA.f$TissueNa_me.S)))/mean(na.omit(TPA.f$TissueNa_me.C)))
TPA.f$TissueNa.ST6 <- ((TPA.f$TissueNa_me.C * TPA.f$TissueNa_me.S)/(mean(na.omit(TPA.f$TissueNa_me.C))^2))
TPA.f$TissueNa.ST7 <- TPA.f$TissueNa_me.S / sqrt(TPA.f$TissueNa_me.C)
     
TPA.f$SFM_me.ST1 <- TPA.f$SFM_me.S / TPA.f$SFM_me.C
TPA.f$SFM_me.ST2 <- TPA.f$SFM_me.C - TPA.f$SFM_me.S
TPA.f$SFM_me.ST3 <- (TPA.f$SFM_me.C + TPA.f$SFM_me.S)/2
TPA.f$SFM_me.ST4 <- sqrt(TPA.f$SFM_me.C * TPA.f$SFM_me.S)
TPA.f$SFM_me.ST5 <- ((TPA.f$SFM_me.C + TPA.f$SFM_me.S)/TPA.f$SFM_me.C) / ((mean(na.omit(TPA.f$SFM_me.C)) - mean(na.omit(TPA.f$SFM_me.S)))/mean(na.omit(TPA.f$SFM_me.C)))
TPA.f$SFM_me.ST6 <- ((TPA.f$SFM_me.C * TPA.f$SFM_me.S)/mean(na.omit(TPA.f$SFM_me.C))^2)
TPA.f$SFM_me.ST7 <- TPA.f$SFM_me.S / sqrt(TPA.f$SFM_me.C)

mean(na.omit(TPA.f$SFM_me.S))
## [1] 29.98792
TPA.f
write.csv(TPA.f, "TPA.stress.indices.all.traits.csv", row.names = FALSE)

now - let’s plot the indices for each trait over each interval

colnames(TPA.f)
##   [1] "Genotype.ID"                            
##   [2] "Area.smooth.AGR.0to5.BLUE.C"            
##   [3] "Area.smooth.AGR.6to9.BLUE.C"            
##   [4] "Area.smooth.AGR.10to14.BLUE.C"          
##   [5] "Area.smooth.RGR.0to5.BLUE.C"            
##   [6] "Area.smooth.RGR.6to9.BLUE.C"            
##   [7] "Area.smooth.RGR.10to14.BLUE.C"          
##   [8] "Area.smooth.TUE.0to5.BLUE.C"            
##   [9] "Area.smooth.TUE.6to9.BLUE.C"            
##  [10] "Area.smooth.TUE.10to14.BLUE.C"          
##  [11] "Transpiration.smooth.rate.0to5.BLUE.C"  
##  [12] "Transpiration.smooth.rate.6to9.BLUE.C"  
##  [13] "Transpiration.smooth.rate.10to14.BLUE.C"
##  [14] "TissueK_me.C"                           
##  [15] "TissueNa_me.C"                          
##  [16] "SFM_me.C"                               
##  [17] "Area.smooth.AGR.0to5.BLUE.S"            
##  [18] "Area.smooth.AGR.6to9.BLUE.S"            
##  [19] "Area.smooth.AGR.10to14.BLUE.S"          
##  [20] "Area.smooth.RGR.0to5.BLUE.S"            
##  [21] "Area.smooth.RGR.6to9.BLUE.S"            
##  [22] "Area.smooth.RGR.10to14.BLUE.S"          
##  [23] "Area.smooth.TUE.0to5.BLUE.S"            
##  [24] "Area.smooth.TUE.6to9.BLUE.S"            
##  [25] "Area.smooth.TUE.10to14.BLUE.S"          
##  [26] "Transpiration.smooth.rate.0to5.BLUE.S"  
##  [27] "Transpiration.smooth.rate.6to9.BLUE.S"  
##  [28] "Transpiration.smooth.rate.10to14.BLUE.S"
##  [29] "TissueK_me.S"                           
##  [30] "TissueNa_me.S"                          
##  [31] "SFM_me.S"                               
##  [32] "AGR.0to5.ST1"                           
##  [33] "AGR.0to5.ST2"                           
##  [34] "AGR.0to5.ST3"                           
##  [35] "AGR.0to5.ST4"                           
##  [36] "AGR.0to5.ST5"                           
##  [37] "AGR.0to5.ST6"                           
##  [38] "AGR.0to5.ST7"                           
##  [39] "AGR.6to9.ST1"                           
##  [40] "AGR.6to9.ST2"                           
##  [41] "AGR.6to9.ST3"                           
##  [42] "AGR.6to9.ST4"                           
##  [43] "AGR.6to9.ST5"                           
##  [44] "AGR.6to9.ST6"                           
##  [45] "AGR.6to9.ST7"                           
##  [46] "AGR.10to14.ST1"                         
##  [47] "AGR.10to14.ST2"                         
##  [48] "AGR.10to14.ST3"                         
##  [49] "AGR.10to14.ST4"                         
##  [50] "AGR.10to14.ST5"                         
##  [51] "AGR.10to14.ST6"                         
##  [52] "AGR.10to14.ST7"                         
##  [53] "RGR.0to5.ST1"                           
##  [54] "RGR.0to5.ST2"                           
##  [55] "RGR.0to5.ST3"                           
##  [56] "RGR.0to5.ST4"                           
##  [57] "RGR.0to5.ST5"                           
##  [58] "RGR.0to5.ST6"                           
##  [59] "RGR.0to5.ST7"                           
##  [60] "RGR.6to9.ST1"                           
##  [61] "RGR.6to9.ST2"                           
##  [62] "RGR.6to9.ST3"                           
##  [63] "RGR.6to9.ST4"                           
##  [64] "RGR.6to9.ST5"                           
##  [65] "RGR.6to9.ST6"                           
##  [66] "RGR.6to9.ST7"                           
##  [67] "RGR.10to14.ST1"                         
##  [68] "RGR.10to14.ST2"                         
##  [69] "RGR.10to14.ST3"                         
##  [70] "RGR.10to14.ST4"                         
##  [71] "RGR.10to14.ST5"                         
##  [72] "RGR.10to14.ST6"                         
##  [73] "RGR.10to14.ST7"                         
##  [74] "TUE.0to5.ST1"                           
##  [75] "TUE.0to5.ST2"                           
##  [76] "TUE.0to5.ST3"                           
##  [77] "TUE.0to5.ST4"                           
##  [78] "TUE.0to5.ST5"                           
##  [79] "TUE.0to5.ST6"                           
##  [80] "TUE.0to5.ST7"                           
##  [81] "TUE.6to9.ST1"                           
##  [82] "TUE.6to9.ST2"                           
##  [83] "TUE.6to9.ST3"                           
##  [84] "TUE.6to9.ST4"                           
##  [85] "TUE.6to9.ST5"                           
##  [86] "TUE.6to9.ST6"                           
##  [87] "TUE.6to9.ST7"                           
##  [88] "TUE.10to14.ST1"                         
##  [89] "TUE.10to14.ST2"                         
##  [90] "TUE.10to14.ST3"                         
##  [91] "TUE.10to14.ST4"                         
##  [92] "TUE.10to14.ST5"                         
##  [93] "TUE.10to14.ST6"                         
##  [94] "TUE.10to14.ST7"                         
##  [95] "TSR.0to5.ST1"                           
##  [96] "TSR.0to5.ST2"                           
##  [97] "TSR.0to5.ST3"                           
##  [98] "TSR.0to5.ST4"                           
##  [99] "TSR.0to5.ST5"                           
## [100] "TSR.0to5.ST6"                           
## [101] "TSR.0to5.ST7"                           
## [102] "TSR.6to9.ST1"                           
## [103] "TSR.6to9.ST2"                           
## [104] "TSR.6to9.ST3"                           
## [105] "TSR.6to9.ST4"                           
## [106] "TSR.6to9.ST5"                           
## [107] "TSR.6to9.ST6"                           
## [108] "TSR.6to9.ST7"                           
## [109] "TSR.10to14.ST1"                         
## [110] "TSR.10to14.ST2"                         
## [111] "TSR.10to14.ST3"                         
## [112] "TSR.10to14.ST4"                         
## [113] "TSR.10to14.ST5"                         
## [114] "TSR.10to14.ST6"                         
## [115] "TSR.10to14.ST7"                         
## [116] "TissueK.ST1"                            
## [117] "TissueK.ST2"                            
## [118] "TissueK.ST3"                            
## [119] "TissueK.ST4"                            
## [120] "TissueK.ST5"                            
## [121] "TissueK.ST6"                            
## [122] "TissueK.ST7"                            
## [123] "TissueNa.ST1"                           
## [124] "TissueNa.ST2"                           
## [125] "TissueNa.ST3"                           
## [126] "TissueNa.ST4"                           
## [127] "TissueNa.ST5"                           
## [128] "TissueNa.ST6"                           
## [129] "TissueNa.ST7"                           
## [130] "SFM_me.ST1"                             
## [131] "SFM_me.ST2"                             
## [132] "SFM_me.ST3"                             
## [133] "SFM_me.ST4"                             
## [134] "SFM_me.ST5"                             
## [135] "SFM_me.ST6"                             
## [136] "SFM_me.ST7"
AGR.data <- TPA.f[,c(1:4, 17:19, 32:52)]
RGR.data <- TPA.f[,c(1, 5:7, 20:22, 53:73)]
TUE.data <- TPA.f[,c(1, 8:10, 23:25, 74:94)]
TSR.data <- TPA.f[,c(1, 11:13, 26:28, 95:115)]
ion.data <- TPA.f[,c(1, 14:15, 29:30, 116:129)]
SFM.data <- TPA.f[,c(1, 16, 31, 130:136)]

Let’s start with SFM data because this is going to be the simplest one:

ST1: STI = S/C ST2: TOL = C-S ST3: MP = (C+S)/2 ST4: GMP = sqrt(CxS) ST5: SSI = ( (C-S)/C ) / ( (C.me-S.me)/C.me ) ST6: STI2 = (C*S)/(C.me)^2 ST7: STI3 = S/sqrt(C)

SFM.data
SFM.ST0 <- ggscatter(SFM.data, x = "SFM_me.C", y = "SFM_me.S", , xlab = "SFM at Control (g)", 
                     ylab = "SFM at Salt (g)")
SFM.ST0 <- SFM.ST0  + stat_cor(method = "spearman", label.x = 30, label.y = 50) 
SFM.ST0
## Warning: Removed 1 rows containing non-finite values (`stat_cor()`).
## Warning: Removed 1 rows containing missing values (`geom_point()`).

SFM.ST1 <- ggscatter(SFM.data, x = "SFM_me.C", y = "SFM_me.S",
               color = "SFM_me.ST1", xlab = "SFM at Control (g)", ylab = "SFM at Salt (g)")
SFM.ST1 <- SFM.ST1 + gradient_color(c("blue", "white", "red")) + theme(legend.position = c(0.9, 0.3)) 
SFM.ST1 <- SFM.ST1 + guides(color=guide_legend(title="STI1 = C / S"))
SFM.ST1
## Warning: Removed 1 rows containing missing values (`geom_point()`).

SFM.ST2 <- ggscatter(SFM.data, x = "SFM_me.C", y = "SFM_me.S",
               color = "SFM_me.ST2", xlab = "SFM at Control (g)", ylab = "SFM at Salt (g)")
SFM.ST2 <- SFM.ST2 + gradient_color(c("blue", "white", "red")) + theme(legend.position = c(0.9, 0.3)) 
SFM.ST2 <- SFM.ST2 + guides(color=guide_legend(title="TOL = C - S"))
SFM.ST2
## Warning: Removed 1 rows containing missing values (`geom_point()`).

SFM.ST3 <- ggscatter(SFM.data, x = "SFM_me.C", y = "SFM_me.S",
               color = "SFM_me.ST3", xlab = "SFM at Control (g)", ylab = "SFM at Salt (g)")
SFM.ST3 <- SFM.ST3 + gradient_color(c("blue", "white", "red")) + theme(legend.position = c(0.9, 0.3))
SFM.ST3 <- SFM.ST3 + guides(color=guide_legend(title="MP = (C + S) / 2"))
SFM.ST3
## Warning: Removed 1 rows containing missing values (`geom_point()`).

SFM.ST4 <- ggscatter(SFM.data, x = "SFM_me.C", y = "SFM_me.S",
               color = "SFM_me.ST4", xlab = "SFM at Control (g)", ylab = "SFM at Salt (g)")
SFM.ST4 <- SFM.ST4 + gradient_color(c("blue", "white", "red")) + theme(legend.position = c(0.9, 0.3))
SFM.ST4 <- SFM.ST4 + guides(color=guide_legend(title="GMP = sqrt(CxS)"))
SFM.ST4
## Warning: Removed 1 rows containing missing values (`geom_point()`).

SFM.ST5 <- ggscatter(SFM.data, x = "SFM_me.C", y = "SFM_me.S",
               color = "SFM_me.ST5", xlab = "SFM at Control (g)", ylab = "SFM at Salt (g)")
SFM.ST5 <- SFM.ST5 + gradient_color(c("blue", "white", "red")) + theme(legend.position = c(0.9, 0.3))
SFM.ST5 <- SFM.ST5 + guides(color=guide_legend(title="SSI = ( (C-S)/C ) / ( (C.m-S.m)/C.m )"))
SFM.ST5
## Warning: Removed 1 rows containing missing values (`geom_point()`).

SFM.ST6 <- ggscatter(SFM.data, x = "SFM_me.C", y = "SFM_me.S",
               color = "SFM_me.ST6", xlab = "SFM at Control (g)", ylab = "SFM at Salt (g)")
SFM.ST6 <- SFM.ST6 + gradient_color(c("blue", "white", "red")) + theme(legend.position = c(0.9, 0.3))
SFM.ST6 <- SFM.ST6 + guides(color=guide_legend(title="STI2 = (C*S)/(C.m)^2"))
SFM.ST6
## Warning: Removed 1 rows containing missing values (`geom_point()`).

SFM.ST7 <- ggscatter(SFM.data, x = "SFM_me.C", y = "SFM_me.S",
               color = "SFM_me.ST7", xlab = "SFM at Control (g)", ylab = "SFM at Salt (g)")
SFM.ST7 <- SFM.ST7 + gradient_color(c("blue", "white", "red")) + theme(legend.position = c(0.9, 0.3))
SFM.ST7 <- SFM.ST7 + guides(color=guide_legend(title="STI3 = S/sqrt(C)"))
SFM.ST7
## Warning: Removed 1 rows containing missing values (`geom_point()`).

OK - now let’s save it all into one figure file:

pdf("Fig.SFM_indices.pdf", width = 18, height = 10)
plot_grid(SFM.ST0, SFM.ST1, SFM.ST2, SFM.ST3, SFM.ST4, SFM.ST5, SFM.ST6, SFM.ST7, cols = 4, labels = "AUTO")
## Warning in plot_grid(SFM.ST0, SFM.ST1, SFM.ST2, SFM.ST3, SFM.ST4, SFM.ST5, :
## Argument 'cols' is deprecated. Use 'ncol' instead.
## Warning: Removed 1 rows containing non-finite values (`stat_cor()`).
## Warning: Removed 1 rows containing missing values (`geom_point()`).
## Removed 1 rows containing missing values (`geom_point()`).
## Removed 1 rows containing missing values (`geom_point()`).
## Removed 1 rows containing missing values (`geom_point()`).
## Removed 1 rows containing missing values (`geom_point()`).
## Removed 1 rows containing missing values (`geom_point()`).
## Removed 1 rows containing missing values (`geom_point()`).
## Removed 1 rows containing missing values (`geom_point()`).
dev.off()
## quartz_off_screen 
##                 2

Let’s make another graph focusing on SFM C vs S with highlighting Na+ and K+ under salt stress:

colnames(TPA.f)
##   [1] "Genotype.ID"                            
##   [2] "Area.smooth.AGR.0to5.BLUE.C"            
##   [3] "Area.smooth.AGR.6to9.BLUE.C"            
##   [4] "Area.smooth.AGR.10to14.BLUE.C"          
##   [5] "Area.smooth.RGR.0to5.BLUE.C"            
##   [6] "Area.smooth.RGR.6to9.BLUE.C"            
##   [7] "Area.smooth.RGR.10to14.BLUE.C"          
##   [8] "Area.smooth.TUE.0to5.BLUE.C"            
##   [9] "Area.smooth.TUE.6to9.BLUE.C"            
##  [10] "Area.smooth.TUE.10to14.BLUE.C"          
##  [11] "Transpiration.smooth.rate.0to5.BLUE.C"  
##  [12] "Transpiration.smooth.rate.6to9.BLUE.C"  
##  [13] "Transpiration.smooth.rate.10to14.BLUE.C"
##  [14] "TissueK_me.C"                           
##  [15] "TissueNa_me.C"                          
##  [16] "SFM_me.C"                               
##  [17] "Area.smooth.AGR.0to5.BLUE.S"            
##  [18] "Area.smooth.AGR.6to9.BLUE.S"            
##  [19] "Area.smooth.AGR.10to14.BLUE.S"          
##  [20] "Area.smooth.RGR.0to5.BLUE.S"            
##  [21] "Area.smooth.RGR.6to9.BLUE.S"            
##  [22] "Area.smooth.RGR.10to14.BLUE.S"          
##  [23] "Area.smooth.TUE.0to5.BLUE.S"            
##  [24] "Area.smooth.TUE.6to9.BLUE.S"            
##  [25] "Area.smooth.TUE.10to14.BLUE.S"          
##  [26] "Transpiration.smooth.rate.0to5.BLUE.S"  
##  [27] "Transpiration.smooth.rate.6to9.BLUE.S"  
##  [28] "Transpiration.smooth.rate.10to14.BLUE.S"
##  [29] "TissueK_me.S"                           
##  [30] "TissueNa_me.S"                          
##  [31] "SFM_me.S"                               
##  [32] "AGR.0to5.ST1"                           
##  [33] "AGR.0to5.ST2"                           
##  [34] "AGR.0to5.ST3"                           
##  [35] "AGR.0to5.ST4"                           
##  [36] "AGR.0to5.ST5"                           
##  [37] "AGR.0to5.ST6"                           
##  [38] "AGR.0to5.ST7"                           
##  [39] "AGR.6to9.ST1"                           
##  [40] "AGR.6to9.ST2"                           
##  [41] "AGR.6to9.ST3"                           
##  [42] "AGR.6to9.ST4"                           
##  [43] "AGR.6to9.ST5"                           
##  [44] "AGR.6to9.ST6"                           
##  [45] "AGR.6to9.ST7"                           
##  [46] "AGR.10to14.ST1"                         
##  [47] "AGR.10to14.ST2"                         
##  [48] "AGR.10to14.ST3"                         
##  [49] "AGR.10to14.ST4"                         
##  [50] "AGR.10to14.ST5"                         
##  [51] "AGR.10to14.ST6"                         
##  [52] "AGR.10to14.ST7"                         
##  [53] "RGR.0to5.ST1"                           
##  [54] "RGR.0to5.ST2"                           
##  [55] "RGR.0to5.ST3"                           
##  [56] "RGR.0to5.ST4"                           
##  [57] "RGR.0to5.ST5"                           
##  [58] "RGR.0to5.ST6"                           
##  [59] "RGR.0to5.ST7"                           
##  [60] "RGR.6to9.ST1"                           
##  [61] "RGR.6to9.ST2"                           
##  [62] "RGR.6to9.ST3"                           
##  [63] "RGR.6to9.ST4"                           
##  [64] "RGR.6to9.ST5"                           
##  [65] "RGR.6to9.ST6"                           
##  [66] "RGR.6to9.ST7"                           
##  [67] "RGR.10to14.ST1"                         
##  [68] "RGR.10to14.ST2"                         
##  [69] "RGR.10to14.ST3"                         
##  [70] "RGR.10to14.ST4"                         
##  [71] "RGR.10to14.ST5"                         
##  [72] "RGR.10to14.ST6"                         
##  [73] "RGR.10to14.ST7"                         
##  [74] "TUE.0to5.ST1"                           
##  [75] "TUE.0to5.ST2"                           
##  [76] "TUE.0to5.ST3"                           
##  [77] "TUE.0to5.ST4"                           
##  [78] "TUE.0to5.ST5"                           
##  [79] "TUE.0to5.ST6"                           
##  [80] "TUE.0to5.ST7"                           
##  [81] "TUE.6to9.ST1"                           
##  [82] "TUE.6to9.ST2"                           
##  [83] "TUE.6to9.ST3"                           
##  [84] "TUE.6to9.ST4"                           
##  [85] "TUE.6to9.ST5"                           
##  [86] "TUE.6to9.ST6"                           
##  [87] "TUE.6to9.ST7"                           
##  [88] "TUE.10to14.ST1"                         
##  [89] "TUE.10to14.ST2"                         
##  [90] "TUE.10to14.ST3"                         
##  [91] "TUE.10to14.ST4"                         
##  [92] "TUE.10to14.ST5"                         
##  [93] "TUE.10to14.ST6"                         
##  [94] "TUE.10to14.ST7"                         
##  [95] "TSR.0to5.ST1"                           
##  [96] "TSR.0to5.ST2"                           
##  [97] "TSR.0to5.ST3"                           
##  [98] "TSR.0to5.ST4"                           
##  [99] "TSR.0to5.ST5"                           
## [100] "TSR.0to5.ST6"                           
## [101] "TSR.0to5.ST7"                           
## [102] "TSR.6to9.ST1"                           
## [103] "TSR.6to9.ST2"                           
## [104] "TSR.6to9.ST3"                           
## [105] "TSR.6to9.ST4"                           
## [106] "TSR.6to9.ST5"                           
## [107] "TSR.6to9.ST6"                           
## [108] "TSR.6to9.ST7"                           
## [109] "TSR.10to14.ST1"                         
## [110] "TSR.10to14.ST2"                         
## [111] "TSR.10to14.ST3"                         
## [112] "TSR.10to14.ST4"                         
## [113] "TSR.10to14.ST5"                         
## [114] "TSR.10to14.ST6"                         
## [115] "TSR.10to14.ST7"                         
## [116] "TissueK.ST1"                            
## [117] "TissueK.ST2"                            
## [118] "TissueK.ST3"                            
## [119] "TissueK.ST4"                            
## [120] "TissueK.ST5"                            
## [121] "TissueK.ST6"                            
## [122] "TissueK.ST7"                            
## [123] "TissueNa.ST1"                           
## [124] "TissueNa.ST2"                           
## [125] "TissueNa.ST3"                           
## [126] "TissueNa.ST4"                           
## [127] "TissueNa.ST5"                           
## [128] "TissueNa.ST6"                           
## [129] "TissueNa.ST7"                           
## [130] "SFM_me.ST1"                             
## [131] "SFM_me.ST2"                             
## [132] "SFM_me.ST3"                             
## [133] "SFM_me.ST4"                             
## [134] "SFM_me.ST5"                             
## [135] "SFM_me.ST6"                             
## [136] "SFM_me.ST7"
SFM.ions.data <- TPA.f[,c(1, 14:16, 29:31)]
SFM.ions.data
SFM.Na.S <- ggscatter(SFM.ions.data, x = "SFM_me.C", y = "SFM_me.S",
               color = "TissueNa_me.S", xlab = "SFM at Control (g)", ylab = "SFM at Salt (g)")
SFM.Na.S <- SFM.Na.S + gradient_color(c("blue", "white", "red")) + theme(legend.position = c(0.9, 0.3))
SFM.Na.S <- SFM.Na.S + guides(color=guide_legend(title="Tissue [Na+] (mmol / g DW)"))
SFM.Na.S
## Warning: Removed 1 rows containing missing values (`geom_point()`).

SFM.K.S <- ggscatter(SFM.ions.data, x = "SFM_me.C", y = "SFM_me.S",
               color = "TissueK_me.S", xlab = "SFM at Control (g)", ylab = "SFM at Salt (g)")
SFM.K.S <- SFM.K.S + gradient_color(c("blue", "white", "red")) + theme(legend.position = c(0.9, 0.3))
SFM.K.S <- SFM.K.S + guides(color=guide_legend(title="Tissue [K+] (mmol / g DW)"))
SFM.K.S
## Warning: Removed 1 rows containing missing values (`geom_point()`).

pdf("Fig.SFM_ions.pdf", width = 9, height = 5)
plot_grid(SFM.Na.S, SFM.K.S, cols = 2, labels = "AUTO")
## Warning in plot_grid(SFM.Na.S, SFM.K.S, cols = 2, labels = "AUTO"): Argument
## 'cols' is deprecated. Use 'ncol' instead.

## Warning in plot_grid(SFM.Na.S, SFM.K.S, cols = 2, labels = "AUTO"): Removed 1
## rows containing missing values (`geom_point()`).

## Warning in plot_grid(SFM.Na.S, SFM.K.S, cols = 2, labels = "AUTO"): Removed 1
## rows containing missing values (`geom_point()`).
dev.off()
## quartz_off_screen 
##                 2

regression analysis

TPA.reg <- TPA.f
colnames(TPA.reg) <- gsub("Area.smooth.AGR", "AGR", colnames(TPA.reg))
colnames(TPA.reg) <- gsub("Area.smooth.RGR", "RGR", colnames(TPA.reg))
colnames(TPA.reg) <- gsub("Area.smooth.TUE", "TUE", colnames(TPA.reg))
colnames(TPA.reg) <- gsub("Transpiration.smooth.rate", "TR", colnames(TPA.reg))
colnames(TPA.reg) <- gsub(".BLUE", "", colnames(TPA.reg))
colnames(TPA.reg) <- gsub("_me", "", colnames(TPA.reg))
TPA.reg <- TPA.reg[,c(1:7, 11:13, 8:10, 14:22, 26:28, 23:25, 29:31, 130:136)]
colnames(TPA.reg)
##  [1] "Genotype.ID"  "AGR.0to5.C"   "AGR.6to9.C"   "AGR.10to14.C" "RGR.0to5.C"  
##  [6] "RGR.6to9.C"   "RGR.10to14.C" "TR.0to5.C"    "TR.6to9.C"    "TR.10to14.C" 
## [11] "TUE.0to5.C"   "TUE.6to9.C"   "TUE.10to14.C" "TissueK.C"    "TissueNa.C"  
## [16] "SFM.C"        "AGR.0to5.S"   "AGR.6to9.S"   "AGR.10to14.S" "RGR.0to5.S"  
## [21] "RGR.6to9.S"   "RGR.10to14.S" "TR.0to5.S"    "TR.6to9.S"    "TR.10to14.S" 
## [26] "TUE.0to5.S"   "TUE.6to9.S"   "TUE.10to14.S" "TissueK.S"    "TissueNa.S"  
## [31] "SFM.S"        "SFM.ST1"      "SFM.ST2"      "SFM.ST3"      "SFM.ST4"     
## [36] "SFM.ST5"      "SFM.ST6"      "SFM.ST7"

let’s calculate the correlation matrix between all of the measured variables:

library(ggcorrplot)
TPA.corr <- TPA.reg[,2:38]
TPA.corr <- na.omit(TPA.corr)
dim(TPA.corr)
## [1] 74 37
corr <- cor(TPA.corr, method = c("pearson"))
head(corr[, 1:6])
##              AGR.0to5.C  AGR.6to9.C AGR.10to14.C  RGR.0to5.C  RGR.6to9.C
## AGR.0to5.C    1.0000000  0.95853135   0.89024119 -0.18994286 -0.17401076
## AGR.6to9.C    0.9585313  1.00000000   0.95219981 -0.05734557  0.07028892
## AGR.10to14.C  0.8902412  0.95219981   1.00000000  0.00312935  0.16512885
## RGR.0to5.C   -0.1899429 -0.05734557   0.00312935  1.00000000  0.78688768
## RGR.6to9.C   -0.1740108  0.07028892   0.16512885  0.78688768  1.00000000
## RGR.10to14.C -0.5800072 -0.45531806  -0.22143806  0.54064709  0.57856861
##              RGR.10to14.C
## AGR.0to5.C     -0.5800072
## AGR.6to9.C     -0.4553181
## AGR.10to14.C   -0.2214381
## RGR.0to5.C      0.5406471
## RGR.6to9.C      0.5785686
## RGR.10to14.C    1.0000000
p.mat <- cor_pmat(corr)
head(p.mat[,1:5])
##                AGR.0to5.C   AGR.6to9.C AGR.10to14.C   RGR.0to5.C   RGR.6to9.C
## AGR.0to5.C   0.000000e+00 2.938338e-35 8.237586e-25 2.217800e-06 1.933539e-06
## AGR.6to9.C   2.938338e-35 0.000000e+00 1.764016e-31 2.473231e-05 4.306389e-05
## AGR.10to14.C 8.237586e-25 1.764016e-31 0.000000e+00 3.702008e-04 5.372587e-04
## RGR.0to5.C   2.217800e-06 2.473231e-05 3.702008e-04 0.000000e+00 7.373627e-21
## RGR.6to9.C   1.933539e-06 4.306389e-05 5.372587e-04 7.373627e-21 0.000000e+00
## RGR.10to14.C 1.086871e-12 9.265774e-11 5.086937e-08 1.532074e-14 1.029376e-13
Correlation_plot_TPA <- ggcorrplot(corr, p.mat = p.mat, type = "lower", outline.col = "white", 
                                       colors = c("#6D9EC1", "white", "#E46726"), 
                                       ggtheme = ggplot2::theme_gray)
Correlation_plot_TPA

pdf("TPA_correlation_pearson.pdf", width = 10, height= 10)
plot(Correlation_plot_TPA)
dev.off()
## quartz_off_screen 
##                 2
corr <- cor(TPA.corr, method = c("spearman"))
head(corr[, 1:6])
##              AGR.0to5.C  AGR.6to9.C AGR.10to14.C  RGR.0to5.C  RGR.6to9.C
## AGR.0to5.C    1.0000000  0.95080341   0.86867086 -0.20927064 -0.13463162
## AGR.6to9.C    0.9508034  1.00000000   0.94730840 -0.11235839  0.09325435
## AGR.10to14.C  0.8686709  0.94730840   1.00000000 -0.03845983  0.20817475
## RGR.0to5.C   -0.2092706 -0.11235839  -0.03845983  1.00000000  0.71684561
## RGR.6to9.C   -0.1346316  0.09325435   0.20817475  0.71684561  1.00000000
## RGR.10to14.C -0.5619993 -0.44518327  -0.22582747  0.51378008  0.52319882
##              RGR.10to14.C
## AGR.0to5.C     -0.5619993
## AGR.6to9.C     -0.4451833
## AGR.10to14.C   -0.2258275
## RGR.0to5.C      0.5137801
## RGR.6to9.C      0.5231988
## RGR.10to14.C    1.0000000
p.mat <- cor_pmat(corr)
head(p.mat[,1:5])
##                AGR.0to5.C   AGR.6to9.C AGR.10to14.C   RGR.0to5.C   RGR.6to9.C
## AGR.0to5.C   0.000000e+00 1.235516e-35 1.577590e-24 2.082309e-06 2.907719e-05
## AGR.6to9.C   1.235516e-35 0.000000e+00 1.791738e-31 1.399338e-05 3.078169e-04
## AGR.10to14.C 1.577590e-24 1.791738e-31 0.000000e+00 2.631404e-04 3.158579e-03
## RGR.0to5.C   2.082309e-06 1.399338e-05 2.631404e-04 0.000000e+00 3.818209e-17
## RGR.6to9.C   2.907719e-05 3.078169e-04 3.158579e-03 3.818209e-17 0.000000e+00
## RGR.10to14.C 6.512834e-12 2.912931e-10 1.320133e-07 2.143801e-14 1.809468e-11
Correlation_plot_TPA <- ggcorrplot(corr, p.mat = p.mat, type = "lower", outline.col = "white", 
                                       colors = c("#6D9EC1", "white", "#E46726"), 
                                       ggtheme = ggplot2::theme_gray)
Correlation_plot_TPA

pdf("TPA_correlation_spearman.pdf", width = 10, height= 10)
plot(Correlation_plot_TPA)
dev.off()
## quartz_off_screen 
##                 2

OK - I think that the Pearson’s correlations are looking better - a bit more insignificant correlations - and thus - somewhat stricter. Based on the nature of all measured traits - the normal distribution can be assumed.

OK - let’s get to the regression itself! But - if we calculate regression for each combination it will be easier. SO - let’s go!

colnames(TPA.reg)
##  [1] "Genotype.ID"  "AGR.0to5.C"   "AGR.6to9.C"   "AGR.10to14.C" "RGR.0to5.C"  
##  [6] "RGR.6to9.C"   "RGR.10to14.C" "TR.0to5.C"    "TR.6to9.C"    "TR.10to14.C" 
## [11] "TUE.0to5.C"   "TUE.6to9.C"   "TUE.10to14.C" "TissueK.C"    "TissueNa.C"  
## [16] "SFM.C"        "AGR.0to5.S"   "AGR.6to9.S"   "AGR.10to14.S" "RGR.0to5.S"  
## [21] "RGR.6to9.S"   "RGR.10to14.S" "TR.0to5.S"    "TR.6to9.S"    "TR.10to14.S" 
## [26] "TUE.0to5.S"   "TUE.6to9.S"   "TUE.10to14.S" "TissueK.S"    "TissueNa.S"  
## [31] "SFM.S"        "SFM.ST1"      "SFM.ST2"      "SFM.ST3"      "SFM.ST4"     
## [36] "SFM.ST5"      "SFM.ST6"      "SFM.ST7"
TPA.Rsq = matrix(, nrow = 37, ncol = 37)
TPA.Adj.Rsq = matrix(, nrow = 37, ncol = 37)
TPA.pval = matrix(, nrow = 37, ncol = 37)
TPA.RSE = matrix(, nrow = 37, ncol = 37)
TPA.DF = matrix(, nrow = 37, ncol = 37)

colnames(TPA.Rsq) <- colnames(TPA.reg)[2:38]
rownames(TPA.Rsq) <- colnames(TPA.reg)[2:38]

colnames(TPA.Adj.Rsq) <- colnames(TPA.reg)[2:38]
rownames(TPA.Adj.Rsq) <- colnames(TPA.reg)[2:38]

colnames(TPA.pval) <- colnames(TPA.reg)[2:38]
rownames(TPA.pval) <- colnames(TPA.reg)[2:38]

colnames(TPA.RSE) <- colnames(TPA.reg)[2:38]
rownames(TPA.RSE) <- colnames(TPA.reg)[2:38]

colnames(TPA.DF) <- colnames(TPA.reg)[2:38]
rownames(TPA.DF) <- colnames(TPA.reg)[2:38]
# I want to explain each trait -- colnames(TPA.reg)[1:38] -- by each trait -- colnames(TPA.reg)[1:38]
for(x in 2:38){
  trait.y <- colnames(TPA.reg)[x]
  for(y in 2:38){
    trait.x <- colnames(TPA.reg)[y]
    TPA.Adj.Rsq[y-1,x-1]<- summary(lm(paste(trait.y, "~", trait.x), data = TPA.reg))$adj.r.squared
    TPA.Rsq[y-1,x-1]<- summary(lm(paste(trait.y, "~", trait.x), data = TPA.reg))$r.squared
    pval_table <- summary(lm(paste(trait.y, "~", trait.x), data = TPA.reg))$coefficients
    if(dim(pval_table)[1] > 1){
     TPA.pval[y-1,x-1]<- summary(lm(paste(trait.y, "~", trait.x), data = TPA.reg))$coefficients[2,4] 
    } else {
      TPA.pval[y-1,x-1]<- "N.A."
    }
    TPA.RSE[y-1,x-1]<- summary(lm(paste(trait.y, "~", trait.x), data = TPA.reg))$sigma
  }}

trait.x
## [1] "SFM.ST7"
trait.y
## [1] "SFM.ST7"
TPA.Adj.Rsq
##                AGR.0to5.C    AGR.6to9.C AGR.10to14.C   RGR.0to5.C    RGR.6to9.C
## AGR.0to5.C    0.000000000  0.8987103078  0.773388918  0.050512151  0.0371167575
## AGR.6to9.C    0.898710308  0.0000000000  0.888478982  0.017261002  0.0005222067
## AGR.10to14.C  0.773388918  0.8884789823  0.000000000  0.014734867  0.0017024029
## RGR.0to5.C    0.050512151  0.0172610021  0.014734867  0.000000000  0.3448872315
## RGR.6to9.C    0.037116757  0.0005222067  0.001702403  0.344887231  0.0000000000
## RGR.10to14.C  0.264517928  0.1422661900  0.021618288  0.150123864  0.3002890352
## TR.0to5.C     0.755527683  0.6729451049  0.569885135  0.277245627  0.0977046771
## TR.6to9.C     0.763335238  0.7725857388  0.674744456  0.170620397  0.0223698169
## TR.10to14.C   0.687405882  0.7424729464  0.727681157  0.143407121  0.0039030476
## TUE.0to5.C    0.200458036  0.1950838812  0.182865065  0.268717129  0.0322772817
## TUE.6to9.C    0.119958843  0.2036940541  0.189534112  0.267782517  0.2399393994
## TUE.10to14.C  0.015836882  0.0325205928  0.082310766  0.189327737  0.1010653545
## TissueK.C    -0.013208806 -0.0053268144 -0.009831356  0.017300870  0.0418102993
## TissueNa.C    0.150011207  0.1839475898  0.213922217  0.009133451 -0.0093961572
## SFM.C         0.796820846  0.8528424605  0.787055529  0.049436279 -0.0040359042
## AGR.0to5.S    0.773844706  0.7259675878  0.667027340  0.047339657  0.0139507846
## AGR.6to9.S    0.665732609  0.7249864518  0.638999444  0.007089316 -0.0014905277
## AGR.10to14.S  0.583978876  0.6514184095  0.589106903  0.002714419  0.0023526448
## RGR.0to5.S    0.086943520  0.0315770032  0.024879354  0.535666029  0.3177206357
## RGR.6to9.S    0.016729274 -0.0046294431 -0.004502615  0.249658391  0.3207616562
## RGR.10to14.S  0.047289649  0.0063426057  0.004435643  0.134879540  0.1996670924
## TR.0to5.S     0.515375750  0.4809241521  0.446581673  0.248835885  0.0481976607
## TR.6to9.S     0.482151864  0.5067094618  0.450602768  0.152921585  0.0047285776
## TR.10to14.S   0.407311198  0.4456571729  0.411177268  0.086547737 -0.0034832749
## TUE.0to5.S    0.103388803  0.1061265268  0.091149900  0.211016834  0.0293720582
## TUE.6to9.S    0.175000567  0.2254024349  0.201208133  0.208614847  0.0977102796
## TUE.10to14.S  0.080118684  0.1119345445  0.103531501  0.203967064  0.1091013160
## TissueK.S     0.065875430  0.0480609064  0.044398940  0.080917206  0.0537848471
## TissueNa.S    0.029572027  0.0326415981  0.034130602 -0.003614275 -0.0046016210
## SFM.S         0.661483494  0.6888119202  0.610531878  0.051218530  0.0007505103
## SFM.ST1       0.001187499  0.0063092834  0.013894237 -0.004581188  0.0070043780
## SFM.ST2       0.550057435  0.6036872726  0.583591681  0.025227894 -0.0039335913
## SFM.ST3       0.802008805  0.8499714158  0.774641657  0.054317835 -0.0027701444
## SFM.ST4       0.781536783  0.8262739386  0.748289578  0.055767059 -0.0021951289
## SFM.ST5       0.001187499  0.0063092834  0.013894237 -0.004581188  0.0070043780
## SFM.ST6       0.765152311  0.8069955053  0.708012302  0.042940323 -0.0032268214
## SFM.ST7       0.353307563  0.3548202508  0.301731336  0.034264472  0.0069114260
##               RGR.10to14.C     TR.0to5.C     TR.6to9.C  TR.10to14.C
## AGR.0to5.C    0.2645179282  0.7555276829  0.7633352377  0.687405882
## AGR.6to9.C    0.1422661900  0.6729451049  0.7725857388  0.742472946
## AGR.10to14.C  0.0216182882  0.5698851346  0.6747444556  0.727681157
## RGR.0to5.C    0.1501238636  0.2772456267  0.1706203966  0.143407121
## RGR.6to9.C    0.3002890352  0.0977046771  0.0223698169  0.003903048
## RGR.10to14.C  0.0000000000  0.2917321694  0.2146817608  0.118174177
## TR.0to5.C     0.2917321694  0.0000000000  0.9216764434  0.752046207
## TR.6to9.C     0.2146817608  0.9216764434  0.0000000000  0.842797565
## TR.10to14.C   0.1181741772  0.7520462070  0.8427975649  0.000000000
## TUE.0to5.C   -0.0004623195 -0.0043423864 -0.0003007496  0.009151506
## TUE.6to9.C    0.0031919092 -0.0001322575 -0.0045875163  0.001758795
## TUE.10to14.C  0.1655267047  0.0354661580  0.0235143232  0.014341270
## TissueK.C    -0.0132360640 -0.0046163593 -0.0128925667 -0.012755466
## TissueNa.C    0.0029770642  0.1568878468  0.1836530228  0.241008654
## SFM.C         0.1419177497  0.6391353529  0.7375257634  0.753092529
## AGR.0to5.S    0.1702580898  0.5362039488  0.5507583851  0.531045339
## AGR.6to9.S    0.1193345868  0.4380399472  0.5235208374  0.496523648
## AGR.10to14.S  0.0853648764  0.3825196056  0.4723658296  0.437832433
## RGR.0to5.S    0.1437210628  0.2547594280  0.1585511591  0.131712624
## RGR.6to9.S    0.0678385489  0.0671346018  0.0146889028  0.010746605
## RGR.10to14.S  0.0969773898  0.0796542288  0.0282616514  0.024136349
## TR.0to5.S     0.1609331657  0.6540737497  0.6352542499  0.560681113
## TR.6to9.S     0.1335873098  0.5732628060  0.6189259038  0.557713090
## TR.10to14.S   0.0817656743  0.4561443864  0.5105131423  0.465340404
## TUE.0to5.S   -0.0024281531 -0.0013524822 -0.0045640760 -0.003871124
## TUE.6to9.S   -0.0021345382 -0.0013307273  0.0141830534  0.022714540
## TUE.10to14.S -0.0037106426 -0.0040971767 -0.0025930684 -0.004199981
## TissueK.S     0.0648016574  0.1419719704  0.1042699981  0.082330525
## TissueNa.S    0.0029997482  0.0234137136  0.0226174633  0.032430688
## SFM.S         0.1752756853  0.5187676674  0.5892381591  0.547623038
## SFM.ST1       0.0061275482  0.0040605388  0.0059829285  0.029649235
## SFM.ST2       0.0587083718  0.4537811414  0.5300218850  0.592316810
## SFM.ST3       0.1644935521  0.6400564518  0.7337629967  0.726477443
## SFM.ST4       0.1703843513  0.6226530113  0.7122071246  0.696345382
## SFM.ST5       0.0061275482  0.0040605388  0.0059829285  0.029649235
## SFM.ST6       0.1787933999  0.5789974036  0.6704051944  0.652078401
## SFM.ST7       0.1305580823  0.2740805703  0.3066791700  0.248531867
##                 TUE.0to5.C    TUE.6to9.C  TUE.10to14.C     TissueK.C
## AGR.0to5.C    0.2004580359  0.1199588432  0.0158368820 -0.0132088056
## AGR.6to9.C    0.1950838812  0.2036940541  0.0325205928 -0.0053268144
## AGR.10to14.C  0.1828650650  0.1895341119  0.0823107664 -0.0098313561
## RGR.0to5.C    0.2687171286  0.2677825175  0.1893277375  0.0173008697
## RGR.6to9.C    0.0322772817  0.2399393994  0.1010653545  0.0418102993
## RGR.10to14.C -0.0004623195  0.0031919092  0.1655267047 -0.0132360640
## TR.0to5.C    -0.0043423864 -0.0001322575  0.0354661580 -0.0046163593
## TR.6to9.C    -0.0003007496 -0.0045875163  0.0235143232 -0.0128925667
## TR.10to14.C   0.0091515057  0.0017587949  0.0143412704 -0.0127554664
## TUE.0to5.C    0.0000000000  0.7363181016  0.4472242421  0.0205607081
## TUE.6to9.C    0.7363181016  0.0000000000  0.5520144762  0.0229645374
## TUE.10to14.C  0.4472242421  0.5520144762  0.0000000000 -0.0009291984
## TissueK.C     0.0205607081  0.0229645374 -0.0009291984  0.0000000000
## TissueNa.C   -0.0091301418 -0.0014778551 -0.0132248444  0.0023425166
## SFM.C         0.1322033201  0.1119242467  0.0113037513 -0.0087955733
## AGR.0to5.S    0.1897128631  0.1483095246  0.0455140351 -0.0088432241
## AGR.6to9.S    0.2088475023  0.1994529125  0.0458640021  0.0024620408
## AGR.10to14.S  0.1941849318  0.1836091270  0.0419647033  0.0098879009
## RGR.0to5.S    0.1110198693  0.1620901466  0.1121437256  0.0052321534
## RGR.6to9.S    0.0553605712  0.1054512740  0.0317245851  0.0284691176
## RGR.10to14.S  0.0082172290  0.0266007344  0.0096382339  0.0327483989
## TR.0to5.S    -0.0045836743 -0.0038006117  0.0080836942 -0.0117701010
## TR.6to9.S    -0.0019455808 -0.0029547808  0.0045953395 -0.0097391721
## TR.10to14.S   0.0043451559  0.0034374898 -0.0001438407  0.0041901735
## TUE.0to5.S    0.6758243194  0.5446294786  0.3269037001  0.0120112354
## TUE.6to9.S    0.6398941444  0.6357078550  0.3265728113  0.0271557697
## TUE.10to14.S  0.4617996191  0.4727299834  0.3479560833 -0.0053832218
## TissueK.S     0.0170258613  0.0107186252  0.0261484892  0.2098799706
## TissueNa.S    0.0090438074  0.0036259669 -0.0028677856 -0.0106223444
## SFM.S         0.1271110199  0.0975143799  0.0131329315  0.0063852712
## SFM.ST1      -0.0037101924 -0.0043875710 -0.0032272633  0.0187621358
## SFM.ST2       0.0760042370  0.0714258824  0.0031414125 -0.0134510450
## SFM.ST3       0.1400582299  0.1146081107  0.0130529550 -0.0041620824
## SFM.ST4       0.1385140276  0.1125880146  0.0134284102 -0.0014448652
## SFM.ST5      -0.0037101924 -0.0043875710 -0.0032272633  0.0187621358
## SFM.ST6       0.1527685773  0.1216830019  0.0155757878  0.0044708056
## SFM.ST7       0.0752917537  0.0496400210  0.0081919281  0.0179209209
##                TissueNa.C        SFM.C   AGR.0to5.S   AGR.6to9.S AGR.10to14.S
## AGR.0to5.C    0.150011207  0.796820846  0.773844706  0.665732609  0.583978876
## AGR.6to9.C    0.183947590  0.852842460  0.725967588  0.724986452  0.651418410
## AGR.10to14.C  0.213922217  0.787055529  0.667027340  0.638999444  0.589106903
## RGR.0to5.C    0.009133451  0.049436279  0.047339657  0.007089316  0.002714419
## RGR.6to9.C   -0.009396157 -0.004035904  0.013950785 -0.001490528  0.002352645
## RGR.10to14.C  0.002977064  0.141917750  0.170258090  0.119334587  0.085364876
## TR.0to5.C     0.156887847  0.639135353  0.536203949  0.438039947  0.382519606
## TR.6to9.C     0.183653023  0.737525763  0.550758385  0.523520837  0.472365830
## TR.10to14.C   0.241008654  0.753092529  0.531045339  0.496523648  0.437832433
## TUE.0to5.C   -0.009130142  0.132203320  0.189712863  0.208847502  0.194184932
## TUE.6to9.C   -0.001477855  0.111924247  0.148309525  0.199452913  0.183609127
## TUE.10to14.C -0.013224844  0.011303751  0.045514035  0.045864002  0.041964703
## TissueK.C     0.002342517 -0.008795573 -0.008843224  0.002462041  0.009887901
## TissueNa.C    0.000000000  0.211470710  0.196407159  0.197537775  0.185430816
## SFM.C         0.211470710  0.000000000  0.666029434  0.638316683  0.562100270
## AGR.0to5.S    0.196407159  0.666029434  0.000000000  0.814312270  0.717297346
## AGR.6to9.S    0.197537775  0.638316683  0.814312270  0.000000000  0.934504821
## AGR.10to14.S  0.185430816  0.562100270  0.717297346  0.934504821  0.000000000
## RGR.0to5.S   -0.012626368  0.048280742  0.042625160  0.001028987  0.001058581
## RGR.6to9.S    0.005780608 -0.003007352  0.016328994  0.050432311  0.074018783
## RGR.10to14.S -0.012102650  0.009732131  0.045619202  0.004415238  0.061725864
## TR.0to5.S     0.168770640  0.482652367  0.703988109  0.573046639  0.505172746
## TR.6to9.S     0.168392880  0.483934186  0.639893725  0.720268820  0.668460333
## TR.10to14.S   0.151349534  0.417023260  0.540130196  0.691540885  0.717002376
## TUE.0to5.S    0.003288201  0.068607871  0.107567054  0.088223992  0.079777873
## TUE.6to9.S    0.045858998  0.158707697  0.160493776  0.298938196  0.301088733
## TUE.10to14.S  0.003398870  0.061461623  0.071787446  0.116819143  0.148064502
## TissueK.S     0.002009822  0.033104799  0.102904587  0.039409192  0.031339881
## TissueNa.S    0.358901026  0.032791303  0.044932618  0.022957593  0.034596932
## SFM.S         0.258072465  0.729764503  0.772735324  0.796436973  0.744203536
## SFM.ST1      -0.005463368  0.032736532  0.027859747  0.051391298  0.072223776
## SFM.ST2       0.122962398  0.776479092  0.305667535  0.262182276  0.208975832
## SFM.ST3       0.256348067  0.963721030  0.753169048  0.741820994  0.668309309
## SFM.ST4       0.261166090  0.925400631  0.775495181  0.773771568  0.703759118
## SFM.ST5      -0.005463368  0.032736532  0.027859747  0.051391298  0.072223776
## SFM.ST6       0.246891638  0.895791367  0.760198948  0.770632287  0.684802438
## SFM.ST7       0.198818100  0.333323982  0.570292336  0.618459367  0.614323371
##                RGR.0to5.S    RGR.6to9.S  RGR.10to14.S    TR.0to5.S
## AGR.0to5.C    0.086943520  0.0167292744  0.0472896493  0.515375750
## AGR.6to9.C    0.031577003 -0.0046294431  0.0063426057  0.480924152
## AGR.10to14.C  0.024879354 -0.0045026152  0.0044356431  0.446581673
## RGR.0to5.C    0.535666029  0.2496583907  0.1348795403  0.248835885
## RGR.6to9.C    0.317720636  0.3207616562  0.1996670924  0.048197661
## RGR.10to14.C  0.143721063  0.0678385489  0.0969773898  0.160933166
## TR.0to5.C     0.254759428  0.0671346018  0.0796542288  0.654073750
## TR.6to9.C     0.158551159  0.0146889028  0.0282616514  0.635254250
## TR.10to14.C   0.131712624  0.0107466048  0.0241363494  0.560681113
## TUE.0to5.C    0.111019869  0.0553605712  0.0082172290 -0.004583674
## TUE.6to9.C    0.162090147  0.1054512740  0.0266007344 -0.003800612
## TUE.10to14.C  0.112143726  0.0317245851  0.0096382339  0.008083694
## TissueK.C     0.005232153  0.0284691176  0.0327483989 -0.011770101
## TissueNa.C   -0.012626368  0.0057806076 -0.0121026503  0.168770640
## SFM.C         0.048280742 -0.0030073519  0.0097321310  0.482652367
## AGR.0to5.S    0.042625160  0.0163289944  0.0456192018  0.703988109
## AGR.6to9.S    0.001028987  0.0504323106  0.0044152378  0.573046639
## AGR.10to14.S  0.001058581  0.0740187830  0.0617258641  0.505172746
## RGR.0to5.S    0.000000000  0.4298472513  0.1637779342  0.179179158
## RGR.6to9.S    0.429847251  0.0000000000  0.6423438592  0.052912372
## RGR.10to14.S  0.163777934  0.6423438592  0.0000000000  0.062162471
## TR.0to5.S     0.179179158  0.0529123720  0.0621624708  0.000000000
## TR.6to9.S     0.079483817 -0.0026086429 -0.0039498809  0.854220576
## TR.10to14.S   0.044044991  0.0250331798  0.0148339400  0.647245165
## TUE.0to5.S    0.142045741  0.0191141689 -0.0036780611  0.032013326
## TUE.6to9.S    0.157234994  0.2556087867  0.1237763197 -0.003909064
## TUE.10to14.S  0.095873840  0.0850917752  0.0885198104  0.004688455
## TissueK.S     0.076880947  0.1079387204  0.0843535266  0.204772835
## TissueNa.S   -0.002794753  0.0059869425 -0.0044379392  0.014648834
## SFM.S         0.039845659 -0.0035995188 -0.0044950484  0.598756048
## SFM.ST1      -0.003676959  0.0168341773  0.0442341308  0.035941341
## SFM.ST2       0.031428248  0.0045910381  0.0308299299  0.199551853
## SFM.ST3       0.048751206 -0.0043996186  0.0024878318  0.559775227
## SFM.ST4       0.047308606 -0.0046249121 -0.0002476356  0.583509810
## SFM.ST5      -0.003676959  0.0168341773  0.0442341308  0.035941341
## SFM.ST6       0.036231626 -0.0042330707 -0.0001829948  0.535119293
## SFM.ST7       0.021745819  0.0009865449  0.0020788386  0.479309515
##                  TR.6to9.S   TR.10to14.S   TUE.0to5.S    TUE.6to9.S
## AGR.0to5.C    0.4821518639  0.4073111976  0.103388803  0.1750005675
## AGR.6to9.C    0.5067094618  0.4456571729  0.106126527  0.2254024349
## AGR.10to14.C  0.4506027685  0.4111772678  0.091149900  0.2012081330
## RGR.0to5.C    0.1529215855  0.0865477367  0.211016834  0.2086148472
## RGR.6to9.C    0.0047285776 -0.0034832749  0.029372058  0.0977102796
## RGR.10to14.C  0.1335873098  0.0817656743 -0.002428153 -0.0021345382
## TR.0to5.C     0.5732628060  0.4561443864 -0.001352482 -0.0013307273
## TR.6to9.C     0.6189259038  0.5105131423 -0.004564076  0.0141830534
## TR.10to14.C   0.5577130903  0.4653404039 -0.003871124  0.0227145397
## TUE.0to5.C   -0.0019455808  0.0043451559  0.675824319  0.6398941444
## TUE.6to9.C   -0.0029547808  0.0034374898  0.544629479  0.6357078550
## TUE.10to14.C  0.0045953395 -0.0001438407  0.326903700  0.3265728113
## TissueK.C    -0.0097391721  0.0041901735  0.012011235  0.0271557697
## TissueNa.C    0.1683928799  0.1513495340  0.003288201  0.0458589984
## SFM.C         0.4839341860  0.4170232601  0.068607871  0.1587076967
## AGR.0to5.S    0.6398937252  0.5401301962  0.107567054  0.1604937763
## AGR.6to9.S    0.7202688204  0.6915408853  0.088223992  0.2989381959
## AGR.10to14.S  0.6684603334  0.7170023757  0.079777873  0.3010887325
## RGR.0to5.S    0.0794838168  0.0440449913  0.142045741  0.1572349944
## RGR.6to9.S   -0.0026086429  0.0250331798  0.019114169  0.2556087867
## RGR.10to14.S -0.0039498809  0.0148339400 -0.003678061  0.1237763197
## TR.0to5.S     0.8542205761  0.6472451648  0.032013326 -0.0039090639
## TR.6to9.S     0.0000000000  0.8693122212  0.012591398 -0.0005411012
## TR.10to14.S   0.8693122212  0.0000000000 -0.002147497  0.0161317995
## TUE.0to5.S    0.0125913980 -0.0021474965  0.000000000  0.5809116826
## TUE.6to9.S   -0.0005411012  0.0161317995  0.580911683  0.0000000000
## TUE.10to14.S  0.0026466136  0.0022891416  0.452579773  0.6536937047
## TissueK.S     0.1446617337  0.1124247824  0.024579144  0.0390692213
## TissueNa.S    0.0105858431  0.0216284649  0.037543576  0.0117205440
## SFM.S         0.6692101611  0.6184974328  0.061946461  0.1538631718
## SFM.ST1       0.0735718648  0.0953071781 -0.004577459 -0.0030064213
## SFM.ST2       0.1661714107  0.1246661354  0.041336369  0.0905781055
## SFM.ST3       0.5852556548  0.5185704169  0.071245641  0.1684648450
## SFM.ST4       0.6214631847  0.5571556194  0.069881464  0.1682747775
## SFM.ST5       0.0735718648  0.0953071781 -0.004577459 -0.0030064213
## SFM.ST6       0.5755518383  0.5122011930  0.083325143  0.1902613435
## SFM.ST7       0.5758437196  0.5623963704  0.031767976  0.0915178824
##              TUE.10to14.S    TissueK.S   TissueNa.S         SFM.S       SFM.ST1
## AGR.0to5.C    0.080118684  0.065875430  0.029572027  0.6614834938  0.0011874991
## AGR.6to9.C    0.111934544  0.048060906  0.032641598  0.6888119202  0.0063092834
## AGR.10to14.C  0.103531501  0.044398940  0.034130602  0.6105318785  0.0138942374
## RGR.0to5.C    0.203967064  0.080917206 -0.003614275  0.0512185298 -0.0045811875
## RGR.6to9.C    0.109101316  0.053784847 -0.004601621  0.0007505103  0.0070043780
## RGR.10to14.C -0.003710643  0.064801657  0.002999748  0.1752756853  0.0061275482
## TR.0to5.C    -0.004097177  0.141971970  0.023413714  0.5187676674  0.0040605388
## TR.6to9.C    -0.002593068  0.104269998  0.022617463  0.5892381591  0.0059829285
## TR.10to14.C  -0.004199981  0.082330525  0.032430688  0.5476230378  0.0296492352
## TUE.0to5.C    0.461799619  0.017025861  0.009043807  0.1271110199 -0.0037101924
## TUE.6to9.C    0.472729983  0.010718625  0.003625967  0.0975143799 -0.0043875710
## TUE.10to14.C  0.347956083  0.026148489 -0.002867786  0.0131329315 -0.0032272633
## TissueK.C    -0.005383222  0.209879971 -0.010622344  0.0063852712  0.0187621358
## TissueNa.C    0.003398870  0.002009822  0.358901026  0.2580724652 -0.0054633684
## SFM.C         0.061461623  0.033104799  0.032791303  0.7297645030  0.0327365315
## AGR.0to5.S    0.071787446  0.102904587  0.044932618  0.7727353238  0.0278597469
## AGR.6to9.S    0.116819143  0.039409192  0.022957593  0.7964369728  0.0513912984
## AGR.10to14.S  0.148064502  0.031339881  0.034596932  0.7442035362  0.0722237760
## RGR.0to5.S    0.095873840  0.076880947 -0.002794753  0.0398456589 -0.0036769589
## RGR.6to9.S    0.085091775  0.107938720  0.005986942 -0.0035995188  0.0168341773
## RGR.10to14.S  0.088519810  0.084353527 -0.004437939 -0.0044950484  0.0442341308
## TR.0to5.S     0.004688455  0.204772835  0.014648834  0.5987560481  0.0359413412
## TR.6to9.S     0.002646614  0.144661734  0.010585843  0.6692101611  0.0735718648
## TR.10to14.S   0.002289142  0.112424782  0.021628465  0.6184974328  0.0953071781
## TUE.0to5.S    0.452579773  0.024579144  0.037543576  0.0619464608 -0.0045774589
## TUE.6to9.S    0.653693705  0.039069221  0.011720544  0.1538631718 -0.0030064213
## TUE.10to14.S  0.000000000  0.043970909  0.006283877  0.0446406092 -0.0041663703
## TissueK.S     0.043970909  0.000000000 -0.004628996  0.0673013611  0.0216501888
## TissueNa.S    0.006283877 -0.004628996  0.000000000  0.0364629320 -0.0017031640
## SFM.S         0.044640609  0.067301361  0.036462932  0.0000000000  0.1029083416
## SFM.ST1      -0.004166370  0.021650189 -0.001703164  0.1029083416  0.0000000000
## SFM.ST2       0.045867697  0.001563499  0.014075712  0.2559197186  0.3785317730
## SFM.ST3       0.059476200  0.047405402  0.036825067  0.8792306881 -0.0045473425
## SFM.ST4       0.056951009  0.053379428  0.036549000  0.9284198298  0.0005158669
## SFM.ST5      -0.004166370  0.021650189 -0.001703164  0.1029083416  1.0000000000
## SFM.ST6       0.066541301  0.033644956  0.028625955  0.9080172091  0.0004763369
## SFM.ST7       0.017917394  0.081178908  0.030246409  0.8352648246  0.4557166832
##                   SFM.ST2      SFM.ST3       SFM.ST4       SFM.ST5
## AGR.0to5.C    0.550057435  0.802008805  0.7815367832  0.0011874991
## AGR.6to9.C    0.603687273  0.849971416  0.8262739386  0.0063092834
## AGR.10to14.C  0.583591681  0.774641657  0.7482895775  0.0138942374
## RGR.0to5.C    0.025227894  0.054317835  0.0557670588 -0.0045811875
## RGR.6to9.C   -0.003933591 -0.002770144 -0.0021951289  0.0070043780
## RGR.10to14.C  0.058708372  0.164493552  0.1703843513  0.0061275482
## TR.0to5.C     0.453781141  0.640056452  0.6226530113  0.0040605388
## TR.6to9.C     0.530021885  0.733762997  0.7122071246  0.0059829285
## TR.10to14.C   0.592316810  0.726477443  0.6963453819  0.0296492352
## TUE.0to5.C    0.076004237  0.140058230  0.1385140276 -0.0037101924
## TUE.6to9.C    0.071425882  0.114608111  0.1125880146 -0.0043875710
## TUE.10to14.C  0.003141413  0.013052955  0.0134284102 -0.0032272633
## TissueK.C    -0.013451045 -0.004162082 -0.0014448652  0.0187621358
## TissueNa.C    0.122962398  0.256348067  0.2611660898 -0.0054633684
## SFM.C         0.776479092  0.963721030  0.9254006307  0.0327365315
## AGR.0to5.S    0.305667535  0.753169048  0.7754951806  0.0278597469
## AGR.6to9.S    0.262182276  0.741820994  0.7737715682  0.0513912984
## AGR.10to14.S  0.208975832  0.668309309  0.7037591179  0.0722237760
## RGR.0to5.S    0.031428248  0.048751206  0.0473086060 -0.0036769589
## RGR.6to9.S    0.004591038 -0.004399619 -0.0046249121  0.0168341773
## RGR.10to14.S  0.030829930  0.002487832 -0.0002476356  0.0442341308
## TR.0to5.S     0.199551853  0.559775227  0.5835098096  0.0359413412
## TR.6to9.S     0.166171411  0.585255655  0.6214631847  0.0735718648
## TR.10to14.S   0.124666135  0.518570417  0.5571556194  0.0953071781
## TUE.0to5.S    0.041336369  0.071245641  0.0698814637 -0.0045774589
## TUE.6to9.S    0.090578106  0.168464845  0.1682747775 -0.0030064213
## TUE.10to14.S  0.045867697  0.059476200  0.0569510094 -0.0041663703
## TissueK.S     0.001563499  0.047405402  0.0533794281  0.0216501888
## TissueNa.S    0.014075712  0.036825067  0.0365490002 -0.0017031640
## SFM.S         0.255919719  0.879230688  0.9284198298  0.1029083416
## SFM.ST1       0.378531773 -0.004547342  0.0005158669  1.0000000000
## SFM.ST2       0.000000000  0.600430490  0.5162947992  0.3785317730
## SFM.ST3       0.600430490  0.000000000  0.9926119531 -0.0045473425
## SFM.ST4       0.516294799  0.992611953  0.0000000000  0.0005158669
## SFM.ST5       0.378531773 -0.004547342  0.0005158669  0.0000000000
## SFM.ST6       0.493424375  0.964380903  0.9733268505  0.0004763369
## SFM.ST7       0.012571926  0.520154808  0.6019915642  0.4557166832
##                    SFM.ST6      SFM.ST7
## AGR.0to5.C    0.7651523110 0.3533075631
## AGR.6to9.C    0.8069955053 0.3548202508
## AGR.10to14.C  0.7080123020 0.3017313363
## RGR.0to5.C    0.0429403230 0.0342644717
## RGR.6to9.C   -0.0032268214 0.0069114260
## RGR.10to14.C  0.1787933999 0.1305580823
## TR.0to5.C     0.5789974036 0.2740805703
## TR.6to9.C     0.6704051944 0.3066791700
## TR.10to14.C   0.6520784015 0.2485318674
## TUE.0to5.C    0.1527685773 0.0752917537
## TUE.6to9.C    0.1216830019 0.0496400210
## TUE.10to14.C  0.0155757878 0.0081919281
## TissueK.C     0.0044708056 0.0179209209
## TissueNa.C    0.2468916377 0.1988180999
## SFM.C         0.8957913666 0.3333239821
## AGR.0to5.S    0.7601989476 0.5702923365
## AGR.6to9.S    0.7706322870 0.6184593672
## AGR.10to14.S  0.6848024378 0.6143233709
## RGR.0to5.S    0.0362316264 0.0217458185
## RGR.6to9.S   -0.0042330707 0.0009865449
## RGR.10to14.S -0.0001829948 0.0020788386
## TR.0to5.S     0.5351192931 0.4793095155
## TR.6to9.S     0.5755518383 0.5758437196
## TR.10to14.S   0.5122011930 0.5623963704
## TUE.0to5.S    0.0833251429 0.0317679762
## TUE.6to9.S    0.1902613435 0.0915178824
## TUE.10to14.S  0.0665413006 0.0179173942
## TissueK.S     0.0336449561 0.0811789078
## TissueNa.S    0.0286259548 0.0302464093
## SFM.S         0.9080172091 0.8352648246
## SFM.ST1       0.0004763369 0.4557166832
## SFM.ST2       0.4934243745 0.0125719256
## SFM.ST3       0.9643809032 0.5201548080
## SFM.ST4       0.9733268505 0.6019915642
## SFM.ST5       0.0004763369 0.4557166832
## SFM.ST6       0.0000000000 0.5746511296
## SFM.ST7       0.5746511296 0.0000000000
dim(summary(lm(paste(trait.y, "~", trait.x), data = TPA.reg))$coefficients)[1]
## [1] 1

OK - this is great. Now - I would like to remove the values in TPA.Adj.Rsq table for all the coordinates that have the p-value > 0.01.

for(x in 1:37){
  for(y in 1:37){
    if(TPA.pval[x,y] == "N.A." | as.numeric(TPA.pval[x,y]) > 0.01){
      TPA.Adj.Rsq[x,y] <- NA
      TPA.Rsq[x,y] <- NA
    }else{
      TPA.Adj.Rsq[x,y] <- as.numeric(TPA.Adj.Rsq[x,y])
      TPA.Rsq[x,y] <- as.numeric(TPA.Rsq[x,y])}
  }}
## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion

## Warning: NAs introduced by coercion
write.csv(TPA.Adj.Rsq, "TPA.Adj.Rsq.csv")
write.csv(TPA.Rsq, "TPA.Rsq.csv")
write.csv(TPA.pval, "TPA.pval.csv")
write.csv(TPA.RSE, "TPA.RSE.csv")
TPA.Adj.Rsq2 <- read.csv("TPA.Adj.Rsq.csv")
head(TPA.Adj.Rsq2)
TPA.Adj.Rsq2$X
##  [1] "AGR.0to5.C"   "AGR.6to9.C"   "AGR.10to14.C" "RGR.0to5.C"   "RGR.6to9.C"  
##  [6] "RGR.10to14.C" "TR.0to5.C"    "TR.6to9.C"    "TR.10to14.C"  "TUE.0to5.C"  
## [11] "TUE.6to9.C"   "TUE.10to14.C" "TissueK.C"    "TissueNa.C"   "SFM.C"       
## [16] "AGR.0to5.S"   "AGR.6to9.S"   "AGR.10to14.S" "RGR.0to5.S"   "RGR.6to9.S"  
## [21] "RGR.10to14.S" "TR.0to5.S"    "TR.6to9.S"    "TR.10to14.S"  "TUE.0to5.S"  
## [26] "TUE.6to9.S"   "TUE.10to14.S" "TissueK.S"    "TissueNa.S"   "SFM.S"       
## [31] "SFM.ST1"      "SFM.ST2"      "SFM.ST3"      "SFM.ST4"      "SFM.ST5"     
## [36] "SFM.ST6"      "SFM.ST7"
TPA.Adj.Rsq2 <- TPA.Adj.Rsq2[1:30,1:37]
colnames(TPA.Adj.Rsq2)
##  [1] "X"            "AGR.0to5.C"   "AGR.6to9.C"   "AGR.10to14.C" "RGR.0to5.C"  
##  [6] "RGR.6to9.C"   "RGR.10to14.C" "TR.0to5.C"    "TR.6to9.C"    "TR.10to14.C" 
## [11] "TUE.0to5.C"   "TUE.6to9.C"   "TUE.10to14.C" "TissueK.C"    "TissueNa.C"  
## [16] "SFM.C"        "AGR.0to5.S"   "AGR.6to9.S"   "AGR.10to14.S" "RGR.0to5.S"  
## [21] "RGR.6to9.S"   "RGR.10to14.S" "TR.0to5.S"    "TR.6to9.S"    "TR.10to14.S" 
## [26] "TUE.0to5.S"   "TUE.6to9.S"   "TUE.10to14.S" "TissueK.S"    "TissueNa.S"  
## [31] "SFM.S"        "SFM.ST1"      "SFM.ST2"      "SFM.ST3"      "SFM.ST4"     
## [36] "SFM.ST5"      "SFM.ST6"
SFM.C <- TPA.Adj.Rsq2[,c(1,16)]
SFM.S <- TPA.Adj.Rsq2[,c(1,31)]
SFM.C <- na.omit(SFM.C)
SFM.S <- na.omit(SFM.S)

library(ggsci)
pal_aaas("default")(2)
## [1] "#3B4992FF" "#EE0000FF"
reg.plot_SFM_Salt <- ggbarplot(SFM.S, x = "X", y = "SFM.S", fill = "#EE0000FF",
                               sort.val = "desc", x.text.angle = 90, xlab = "", ylab = "Adjusted R square")

reg.plot_SFM_Control <- ggbarplot(SFM.C, x = "X", y = "SFM.C", fill = "#3B4992FF",
                              sort.val = "desc", x.text.angle = 90, xlab = "", ylab = "Adjusted R square")

TPA_SFM_regression <- plot_grid(reg.plot_SFM_Control, reg.plot_SFM_Salt, labels = "AUTO", ncol= 1)
TPA_SFM_regression

pdf("Regression_SFM.pdf", width = 10, height = 13)
plot(TPA_SFM_regression)
dev.off()
## quartz_off_screen 
##                 2

plot()

ploting interval data

library(reshape2)
colnames(AGR.data)
##  [1] "Genotype.ID"                   "Area.smooth.AGR.0to5.BLUE.C"  
##  [3] "Area.smooth.AGR.6to9.BLUE.C"   "Area.smooth.AGR.10to14.BLUE.C"
##  [5] "Area.smooth.AGR.0to5.BLUE.S"   "Area.smooth.AGR.6to9.BLUE.S"  
##  [7] "Area.smooth.AGR.10to14.BLUE.S" "AGR.0to5.ST1"                 
##  [9] "AGR.0to5.ST2"                  "AGR.0to5.ST3"                 
## [11] "AGR.0to5.ST4"                  "AGR.0to5.ST5"                 
## [13] "AGR.0to5.ST6"                  "AGR.0to5.ST7"                 
## [15] "AGR.6to9.ST1"                  "AGR.6to9.ST2"                 
## [17] "AGR.6to9.ST3"                  "AGR.6to9.ST4"                 
## [19] "AGR.6to9.ST5"                  "AGR.6to9.ST6"                 
## [21] "AGR.6to9.ST7"                  "AGR.10to14.ST1"               
## [23] "AGR.10to14.ST2"                "AGR.10to14.ST3"               
## [25] "AGR.10to14.ST4"                "AGR.10to14.ST5"               
## [27] "AGR.10to14.ST6"                "AGR.10to14.ST7"
AGR.data.int <- AGR.data[,c(1:7)]
mAGR.data.int <- melt(AGR.data.int)
## Using Genotype.ID as id variables
colnames(mAGR.data.int)[3] <- "AGR"
mAGR.data.int$treatment <- mAGR.data.int$variable
mAGR.data.int$treatment <- gsub("Area.smooth.AGR.0to5.BLUE.C", "Control", mAGR.data.int$treatment)
mAGR.data.int$treatment <- gsub("Area.smooth.AGR.0to5.BLUE.S", "Salt", mAGR.data.int$treatment)
mAGR.data.int$treatment <- gsub("Area.smooth.AGR.6to9.BLUE.C", "Control", mAGR.data.int$treatment)
mAGR.data.int$treatment <- gsub("Area.smooth.AGR.6to9.BLUE.S", "Salt", mAGR.data.int$treatment)
mAGR.data.int$treatment <- gsub("Area.smooth.AGR.10to14.BLUE.C", "Control", mAGR.data.int$treatment)
mAGR.data.int$treatment <- gsub("Area.smooth.AGR.10to14.BLUE.S", "Salt", mAGR.data.int$treatment)

mAGR.data.int$interval <- mAGR.data.int$variable
mAGR.data.int$interval <- gsub("Area.smooth.AGR.0to5.BLUE.C", "0.to.5", mAGR.data.int$interval)
mAGR.data.int$interval <- gsub("Area.smooth.AGR.0to5.BLUE.S", "0.to.5", mAGR.data.int$interval)
mAGR.data.int$interval <- gsub("Area.smooth.AGR.6to9.BLUE.C", "6.to.9", mAGR.data.int$interval)
mAGR.data.int$interval <- gsub("Area.smooth.AGR.6to9.BLUE.S", "6.to.9", mAGR.data.int$interval)
mAGR.data.int$interval <- gsub("Area.smooth.AGR.10to14.BLUE.C", "10.to.14", mAGR.data.int$interval)
mAGR.data.int$interval <- gsub("Area.smooth.AGR.10to14.BLUE.S", "10.to.14", mAGR.data.int$interval)

mAGR.data.int$interval <- factor(mAGR.data.int$interval, levels = c("0.to.5", "6.to.9", "10.to.14"))
AGR.int_violin_paired <- ggplot(data = mAGR.data.int, mapping = aes(x = treatment, y = AGR, fill = treatment)) 
AGR.int_violin_paired <- AGR.int_violin_paired + geom_line(mapping = aes(group = Genotype.ID), alpha = 0.3, position = position_dodge(0.1))
AGR.int_violin_paired <- AGR.int_violin_paired + geom_violindot(dots_size = 0.0, position_dots = position_dodge(0.1), flip = c(1)) + facet_wrap(~ interval)
## Warning in geom_dotplot(binaxis = "y", mapping = mapping, data = data, dotsize =
## size_dots, : Ignoring unknown parameters: `flip`
AGR.int_violin_paired <- AGR.int_violin_paired + geom_point(mapping = aes(fill = treatment, group = Genotype.ID), size = 1.5, shape = 21, position = position_dodge(0.1))
AGR.int_violin_paired <- AGR.int_violin_paired + stat_compare_means(aes(group = treatment), label = "p.signif", method = "aov", paired = TRUE)
AGR.int_violin_paired <- AGR.int_violin_paired + theme_bw() + theme(legend.position = "none") + ylab("AGR (pix. day)") + xlab("") + scale_fill_aaas()
AGR.int_violin_paired  
## Warning: Removed 6 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 6 rows containing missing values (`stat_bindot()`).
## Warning: Removed 6 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).

AGR1 <- subset(mAGR.data.int, mAGR.data.int$interval == "0.to.5")
summary(lm(AGR ~ treatment, data = AGR1))
## 
## Call:
## lm(formula = AGR ~ treatment, data = AGR1)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -22.035  -5.312  -0.612   4.518  35.619 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    37.6019     0.5494   68.44   <2e-16 ***
## treatmentSalt -12.6929     0.7779  -16.32   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.131 on 435 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.3797, Adjusted R-squared:  0.3782 
## F-statistic: 266.2 on 1 and 435 DF,  p-value: < 2.2e-16
AGR2 <- subset(mAGR.data.int, mAGR.data.int$interval == "6.to.9")
summary(lm(AGR ~ treatment, data = AGR2))
## 
## Call:
## lm(formula = AGR ~ treatment, data = AGR2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -46.076 -11.110  -2.137   8.822  70.065 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     85.228      1.177   72.41   <2e-16 ***
## treatmentSalt  -44.318      1.666  -26.59   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 17.42 on 435 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.6192, Adjusted R-squared:  0.6183 
## F-statistic: 707.3 on 1 and 435 DF,  p-value: < 2.2e-16
AGR3 <- subset(mAGR.data.int, mAGR.data.int$interval == "10.to.14")
summary(lm(AGR ~ treatment, data = AGR3))
## 
## Call:
## lm(formula = AGR ~ treatment, data = AGR3)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -78.824 -17.052  -1.479  15.584  97.847 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    144.164      1.772   81.37   <2e-16 ***
## treatmentSalt  -78.760      2.500  -31.51   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 26.04 on 432 degrees of freedom
##   (4 observations deleted due to missingness)
## Multiple R-squared:  0.6968, Adjusted R-squared:  0.6961 
## F-statistic: 992.7 on 1 and 432 DF,  p-value: < 2.2e-16
colnames(RGR.data)
##  [1] "Genotype.ID"                   "Area.smooth.RGR.0to5.BLUE.C"  
##  [3] "Area.smooth.RGR.6to9.BLUE.C"   "Area.smooth.RGR.10to14.BLUE.C"
##  [5] "Area.smooth.RGR.0to5.BLUE.S"   "Area.smooth.RGR.6to9.BLUE.S"  
##  [7] "Area.smooth.RGR.10to14.BLUE.S" "RGR.0to5.ST1"                 
##  [9] "RGR.0to5.ST2"                  "RGR.0to5.ST3"                 
## [11] "RGR.0to5.ST4"                  "RGR.0to5.ST5"                 
## [13] "RGR.0to5.ST6"                  "RGR.0to5.ST7"                 
## [15] "RGR.6to9.ST1"                  "RGR.6to9.ST2"                 
## [17] "RGR.6to9.ST3"                  "RGR.6to9.ST4"                 
## [19] "RGR.6to9.ST5"                  "RGR.6to9.ST6"                 
## [21] "RGR.6to9.ST7"                  "RGR.10to14.ST1"               
## [23] "RGR.10to14.ST2"                "RGR.10to14.ST3"               
## [25] "RGR.10to14.ST4"                "RGR.10to14.ST5"               
## [27] "RGR.10to14.ST6"                "RGR.10to14.ST7"
RGR.data.int <- RGR.data[,c(1:7)]
mRGR.data.int <- melt(RGR.data.int)
## Using Genotype.ID as id variables
colnames(mRGR.data.int)[3] <- "RGR"
mRGR.data.int$treatment <- mRGR.data.int$variable
mRGR.data.int$treatment <- gsub("Area.smooth.RGR.0to5.BLUE.C", "Control", mRGR.data.int$treatment)
mRGR.data.int$treatment <- gsub("Area.smooth.RGR.0to5.BLUE.S", "Salt", mRGR.data.int$treatment)
mRGR.data.int$treatment <- gsub("Area.smooth.RGR.6to9.BLUE.C", "Control", mRGR.data.int$treatment)
mRGR.data.int$treatment <- gsub("Area.smooth.RGR.6to9.BLUE.S", "Salt", mRGR.data.int$treatment)
mRGR.data.int$treatment <- gsub("Area.smooth.RGR.10to14.BLUE.C", "Control", mRGR.data.int$treatment)
mRGR.data.int$treatment <- gsub("Area.smooth.RGR.10to14.BLUE.S", "Salt", mRGR.data.int$treatment)

mRGR.data.int$interval <- mRGR.data.int$variable
mRGR.data.int$interval <- gsub("Area.smooth.RGR.0to5.BLUE.C", "0.to.5", mRGR.data.int$interval)
mRGR.data.int$interval <- gsub("Area.smooth.RGR.0to5.BLUE.S", "0.to.5", mRGR.data.int$interval)
mRGR.data.int$interval <- gsub("Area.smooth.RGR.6to9.BLUE.C", "6.to.9", mRGR.data.int$interval)
mRGR.data.int$interval <- gsub("Area.smooth.RGR.6to9.BLUE.S", "6.to.9", mRGR.data.int$interval)
mRGR.data.int$interval <- gsub("Area.smooth.RGR.10to14.BLUE.C", "10.to.14", mRGR.data.int$interval)
mRGR.data.int$interval <- gsub("Area.smooth.RGR.10to14.BLUE.S", "10.to.14", mRGR.data.int$interval)

mRGR.data.int$interval <- factor(mRGR.data.int$interval, levels = c("0.to.5", "6.to.9", "10.to.14"))

mRGR.data.int
RGR.int_violin_paired <- ggplot(data = mRGR.data.int, mapping = aes(x = treatment, y = RGR, fill = treatment)) 
RGR.int_violin_paired <- RGR.int_violin_paired + geom_line(mapping = aes(group = Genotype.ID), alpha = 0.3, position = position_dodge(0.1))
RGR.int_violin_paired <- RGR.int_violin_paired + geom_violindot(dots_size = 0.00, position_dots = position_dodge(0.1), flip = c(1)) + facet_wrap(~ interval)
## Warning in geom_dotplot(binaxis = "y", mapping = mapping, data = data, dotsize =
## size_dots, : Ignoring unknown parameters: `flip`
RGR.int_violin_paired <- RGR.int_violin_paired + geom_point(mapping = aes(fill = treatment, group = Genotype.ID), size = 1.5, shape = 21, position = position_dodge(0.1))
RGR.int_violin_paired <- RGR.int_violin_paired + stat_compare_means(aes(group = treatment), label = "p.signif", method = "aov", paired = TRUE)
RGR.int_violin_paired <- RGR.int_violin_paired + theme_bw() + theme(legend.position = "none") + ylab("RGR (pix. day)") + xlab("") + scale_fill_aaas()
RGR.int_violin_paired  
## Warning: Removed 6 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 6 rows containing missing values (`stat_bindot()`).
## Warning: Removed 6 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).

RGR1 <- subset(mRGR.data.int, mRGR.data.int$interval == "0.to.5")
summary(lm(RGR ~ treatment, data = RGR1))
## 
## Call:
## lm(formula = RGR ~ treatment, data = RGR1)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.053542 -0.012412 -0.000464  0.009860  0.065226 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    0.255140   0.001173  217.47   <2e-16 ***
## treatmentSalt -0.052792   0.001661  -31.78   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01736 on 435 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.699,  Adjusted R-squared:  0.6983 
## F-statistic:  1010 on 1 and 435 DF,  p-value: < 2.2e-16
RGR2 <- subset(mRGR.data.int, mRGR.data.int$interval == "6.to.9")
summary(lm(RGR ~ treatment, data = RGR2))
## 
## Call:
## lm(formula = RGR ~ treatment, data = RGR2)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.087547 -0.008505  0.000497  0.007944  0.054616 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    0.1956753  0.0009897  197.72   <2e-16 ***
## treatmentSalt -0.0526760  0.0014012  -37.59   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01465 on 435 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.7646, Adjusted R-squared:  0.7641 
## F-statistic:  1413 on 1 and 435 DF,  p-value: < 2.2e-16
RGR3 <- subset(mRGR.data.int, mRGR.data.int$interval == "10.to.14")
summary(lm(RGR ~ treatment, data = RGR3))
## 
## Call:
## lm(formula = RGR ~ treatment, data = RGR3)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.061929 -0.005597 -0.000357  0.006418  0.031709 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    0.1524814  0.0007028  216.95   <2e-16 ***
## treatmentSalt -0.0295306  0.0009917  -29.78   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01033 on 432 degrees of freedom
##   (4 observations deleted due to missingness)
## Multiple R-squared:  0.6724, Adjusted R-squared:  0.6717 
## F-statistic: 886.8 on 1 and 432 DF,  p-value: < 2.2e-16
colnames(TSR.data)
##  [1] "Genotype.ID"                            
##  [2] "Transpiration.smooth.rate.0to5.BLUE.C"  
##  [3] "Transpiration.smooth.rate.6to9.BLUE.C"  
##  [4] "Transpiration.smooth.rate.10to14.BLUE.C"
##  [5] "Transpiration.smooth.rate.0to5.BLUE.S"  
##  [6] "Transpiration.smooth.rate.6to9.BLUE.S"  
##  [7] "Transpiration.smooth.rate.10to14.BLUE.S"
##  [8] "TSR.0to5.ST1"                           
##  [9] "TSR.0to5.ST2"                           
## [10] "TSR.0to5.ST3"                           
## [11] "TSR.0to5.ST4"                           
## [12] "TSR.0to5.ST5"                           
## [13] "TSR.0to5.ST6"                           
## [14] "TSR.0to5.ST7"                           
## [15] "TSR.6to9.ST1"                           
## [16] "TSR.6to9.ST2"                           
## [17] "TSR.6to9.ST3"                           
## [18] "TSR.6to9.ST4"                           
## [19] "TSR.6to9.ST5"                           
## [20] "TSR.6to9.ST6"                           
## [21] "TSR.6to9.ST7"                           
## [22] "TSR.10to14.ST1"                         
## [23] "TSR.10to14.ST2"                         
## [24] "TSR.10to14.ST3"                         
## [25] "TSR.10to14.ST4"                         
## [26] "TSR.10to14.ST5"                         
## [27] "TSR.10to14.ST6"                         
## [28] "TSR.10to14.ST7"
TSR.data.int <- TSR.data[,c(1:7)]
mTSR.data.int <- melt(TSR.data.int)
## Using Genotype.ID as id variables
colnames(mTSR.data.int)[3] <- "TSR"
mTSR.data.int
mTSR.data.int$treatment <- mTSR.data.int$variable
mTSR.data.int$treatment <- gsub("Transpiration.smooth.rate.0to5.BLUE.C", "Control", mTSR.data.int$treatment)
mTSR.data.int$treatment <- gsub("Transpiration.smooth.rate.0to5.BLUE.S", "Salt", mTSR.data.int$treatment)
mTSR.data.int$treatment <- gsub("Transpiration.smooth.rate.6to9.BLUE.C", "Control", mTSR.data.int$treatment)
mTSR.data.int$treatment <- gsub("Transpiration.smooth.rate.6to9.BLUE.S", "Salt", mTSR.data.int$treatment)
mTSR.data.int$treatment <- gsub("Transpiration.smooth.rate.10to14.BLUE.C", "Control", mTSR.data.int$treatment)
mTSR.data.int$treatment <- gsub("Transpiration.smooth.rate.10to14.BLUE.S", "Salt", mTSR.data.int$treatment)

mTSR.data.int$interval <- mTSR.data.int$variable
mTSR.data.int$interval <- gsub("Transpiration.smooth.rate.0to5.BLUE.C", "0.to.5", mTSR.data.int$interval)
mTSR.data.int$interval <- gsub("Transpiration.smooth.rate.0to5.BLUE.S", "0.to.5", mTSR.data.int$interval)
mTSR.data.int$interval <- gsub("Transpiration.smooth.rate.6to9.BLUE.C", "6.to.9", mTSR.data.int$interval)
mTSR.data.int$interval <- gsub("Transpiration.smooth.rate.6to9.BLUE.S", "6.to.9", mTSR.data.int$interval)
mTSR.data.int$interval <- gsub("Transpiration.smooth.rate.10to14.BLUE.C", "10.to.14", mTSR.data.int$interval)
mTSR.data.int$interval <- gsub("Transpiration.smooth.rate.10to14.BLUE.S", "10.to.14", mTSR.data.int$interval)

mTSR.data.int$interval <- factor(mTSR.data.int$interval, levels = c("0.to.5", "6.to.9", "10.to.14"))

mTSR.data.int
TSR.int_violin_paired <- ggplot(data = mTSR.data.int, mapping = aes(x = treatment, y = TSR, fill = treatment)) 
TSR.int_violin_paired <- TSR.int_violin_paired + geom_line(mapping = aes(group = Genotype.ID), alpha = 0.3, position = position_dodge(0.1))
TSR.int_violin_paired <- TSR.int_violin_paired + geom_violindot(dots_size = 0.00, position_dots = position_dodge(0.1), flip = c(1)) + facet_wrap(~ interval)
## Warning in geom_dotplot(binaxis = "y", mapping = mapping, data = data, dotsize =
## size_dots, : Ignoring unknown parameters: `flip`
TSR.int_violin_paired <- TSR.int_violin_paired + geom_point(mapping = aes(fill = treatment, group = Genotype.ID), size = 1.5, shape = 21, position = position_dodge(0.1))
TSR.int_violin_paired <- TSR.int_violin_paired + stat_compare_means(aes(group = treatment), label = "p.signif", method = "aov", paired = TRUE)
TSR.int_violin_paired <- TSR.int_violin_paired + theme_bw() + theme(legend.position = "none") + ylab("Transpiration (g H2O / day)") + xlab("") + scale_fill_aaas()
TSR.int_violin_paired  
## Warning: Removed 6 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 6 rows containing missing values (`stat_bindot()`).
## Warning: Removed 6 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).

TSR1 <- subset(mTSR.data.int, mTSR.data.int$interval == "0.to.5")
summary(lm(TSR ~ treatment, data = TSR1))
## 
## Call:
## lm(formula = TSR ~ treatment, data = TSR1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -16.7374  -3.6604   0.3365   3.3273  18.7399 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    27.5464     0.3641   75.65   <2e-16 ***
## treatmentSalt -10.0261     0.5155  -19.45   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.388 on 435 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.4651, Adjusted R-squared:  0.4639 
## F-statistic: 378.2 on 1 and 435 DF,  p-value: < 2.2e-16
TSR2 <- subset(mTSR.data.int, mTSR.data.int$interval == "6.to.9")
summary(lm(TSR ~ treatment, data = TSR2))
## 
## Call:
## lm(formula = TSR ~ treatment, data = TSR2)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -37.333  -7.250  -0.477   6.599  43.150 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    65.9975     0.7894   83.61   <2e-16 ***
## treatmentSalt -34.5789     1.1176  -30.94   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.68 on 435 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.6876, Adjusted R-squared:  0.6868 
## F-statistic: 957.3 on 1 and 435 DF,  p-value: < 2.2e-16
TSR3 <- subset(mTSR.data.int, mTSR.data.int$interval == "10.to.14")
summary(lm(TSR ~ treatment, data = TSR3))
## 
## Call:
## lm(formula = TSR ~ treatment, data = TSR3)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -65.761 -11.354  -0.388  11.489  75.193 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    127.141      1.395   91.13   <2e-16 ***
## treatmentSalt  -74.326      1.969  -37.76   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 20.5 on 432 degrees of freedom
##   (4 observations deleted due to missingness)
## Multiple R-squared:  0.7674, Adjusted R-squared:  0.7669 
## F-statistic:  1426 on 1 and 432 DF,  p-value: < 2.2e-16
colnames(TUE.data)
##  [1] "Genotype.ID"                   "Area.smooth.TUE.0to5.BLUE.C"  
##  [3] "Area.smooth.TUE.6to9.BLUE.C"   "Area.smooth.TUE.10to14.BLUE.C"
##  [5] "Area.smooth.TUE.0to5.BLUE.S"   "Area.smooth.TUE.6to9.BLUE.S"  
##  [7] "Area.smooth.TUE.10to14.BLUE.S" "TUE.0to5.ST1"                 
##  [9] "TUE.0to5.ST2"                  "TUE.0to5.ST3"                 
## [11] "TUE.0to5.ST4"                  "TUE.0to5.ST5"                 
## [13] "TUE.0to5.ST6"                  "TUE.0to5.ST7"                 
## [15] "TUE.6to9.ST1"                  "TUE.6to9.ST2"                 
## [17] "TUE.6to9.ST3"                  "TUE.6to9.ST4"                 
## [19] "TUE.6to9.ST5"                  "TUE.6to9.ST6"                 
## [21] "TUE.6to9.ST7"                  "TUE.10to14.ST1"               
## [23] "TUE.10to14.ST2"                "TUE.10to14.ST3"               
## [25] "TUE.10to14.ST4"                "TUE.10to14.ST5"               
## [27] "TUE.10to14.ST6"                "TUE.10to14.ST7"
TUE.data.int <- TUE.data[,c(1:7)]
mTUE.data.int <- melt(TUE.data.int)
## Using Genotype.ID as id variables
colnames(mTUE.data.int)[3] <- "TUE"
mTUE.data.int
mTUE.data.int$treatment <- mTUE.data.int$variable
mTUE.data.int$treatment <- gsub("Area.smooth.TUE.0to5.BLUE.C", "Control", mTUE.data.int$treatment)
mTUE.data.int$treatment <- gsub("Area.smooth.TUE.0to5.BLUE.S", "Salt", mTUE.data.int$treatment)
mTUE.data.int$treatment <- gsub("Area.smooth.TUE.6to9.BLUE.C", "Control", mTUE.data.int$treatment)
mTUE.data.int$treatment <- gsub("Area.smooth.TUE.6to9.BLUE.S", "Salt", mTUE.data.int$treatment)
mTUE.data.int$treatment <- gsub("Area.smooth.TUE.10to14.BLUE.C", "Control", mTUE.data.int$treatment)
mTUE.data.int$treatment <- gsub("Area.smooth.TUE.10to14.BLUE.S", "Salt", mTUE.data.int$treatment)

mTUE.data.int$interval <- mTUE.data.int$variable
mTUE.data.int$interval <- gsub("Area.smooth.TUE.0to5.BLUE.C", "0.to.5", mTUE.data.int$interval)
mTUE.data.int$interval <- gsub("Area.smooth.TUE.0to5.BLUE.S", "0.to.5", mTUE.data.int$interval)
mTUE.data.int$interval <- gsub("Area.smooth.TUE.6to9.BLUE.C", "6.to.9", mTUE.data.int$interval)
mTUE.data.int$interval <- gsub("Area.smooth.TUE.6to9.BLUE.S", "6.to.9", mTUE.data.int$interval)
mTUE.data.int$interval <- gsub("Area.smooth.TUE.10to14.BLUE.C", "10.to.14", mTUE.data.int$interval)
mTUE.data.int$interval <- gsub("Area.smooth.TUE.10to14.BLUE.S", "10.to.14", mTUE.data.int$interval)

mTUE.data.int$interval <- factor(mTUE.data.int$interval, levels = c("0.to.5", "6.to.9", "10.to.14"))

mTUE.data.int
TUE.int_violin_paired <- ggplot(data = mTUE.data.int, mapping = aes(x = treatment, y = TUE, fill = treatment)) 
TUE.int_violin_paired <- TUE.int_violin_paired + geom_line(mapping = aes(group = Genotype.ID), alpha = 0.3, position = position_dodge(0.1))
TUE.int_violin_paired <- TUE.int_violin_paired + geom_violindot(dots_size = 0.00, position_dots = position_dodge(0.1), flip = c(1)) + facet_wrap(~ interval)
## Warning in geom_dotplot(binaxis = "y", mapping = mapping, data = data, dotsize =
## size_dots, : Ignoring unknown parameters: `flip`
TUE.int_violin_paired <- TUE.int_violin_paired + geom_point(mapping = aes(fill = treatment, group = Genotype.ID), size = 1.5, shape = 21, position = position_dodge(0.1))
TUE.int_violin_paired <- TUE.int_violin_paired + stat_compare_means(aes(group = treatment), label = "p.signif", method = "aov", paired = TRUE)
TUE.int_violin_paired <- TUE.int_violin_paired + theme_bw() + theme(legend.position = "none") + ylab("TUE (pix / g H2O)") + xlab("") + scale_fill_aaas()
TUE.int_violin_paired  
## Warning: Removed 6 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 6 rows containing missing values (`stat_bindot()`).
## Warning: Removed 6 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).

TUE1 <- subset(mTUE.data.int, mTUE.data.int$interval == "0.to.5")
summary(lm(TUE ~ treatment, data = TUE1))
## 
## Call:
## lm(formula = TUE ~ treatment, data = TUE1)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.40225 -0.12325 -0.00957  0.10675  0.56307 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    1.33339    0.01178 113.233   <2e-16 ***
## treatmentSalt  0.02311    0.01667   1.386    0.167    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1743 on 435 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.004396,   Adjusted R-squared:  0.002107 
## F-statistic: 1.921 on 1 and 435 DF,  p-value: 0.1665
TUE2 <- subset(mTUE.data.int, mTUE.data.int$interval == "6.to.9")
summary(lm(TUE ~ treatment, data = TUE2))
## 
## Call:
## lm(formula = TUE ~ treatment, data = TUE2)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.64051 -0.10082 -0.00144  0.11120  0.55113 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1.2924344  0.0117164 110.310   <2e-16 ***
## treatmentSalt 0.0006801  0.0165885   0.041    0.967    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1734 on 435 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  3.864e-06,  Adjusted R-squared:  -0.002295 
## F-statistic: 0.001681 on 1 and 435 DF,  p-value: 0.9673
TUE3 <- subset(mTUE.data.int, mTUE.data.int$interval == "10.to.14")
summary(lm(TUE ~ treatment, data = TUE3))
## 
## Call:
## lm(formula = TUE ~ treatment, data = TUE3)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.41180 -0.10117 -0.00716  0.09021  0.54269 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    1.17244    0.01110  105.62   <2e-16 ***
## treatmentSalt  0.18734    0.01566   11.96   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.1631 on 432 degrees of freedom
##   (4 observations deleted due to missingness)
## Multiple R-squared:  0.2488, Adjusted R-squared:  0.247 
## F-statistic: 143.1 on 1 and 432 DF,  p-value: < 2.2e-16
pdf("Fig.Interval.data.pdf", width=10, height = 10)
plot_grid(AGR.int_violin_paired, RGR.int_violin_paired, TSR.int_violin_paired, TUE.int_violin_paired,
          cols = 2, labels = "AUTO")
## Warning in plot_grid(AGR.int_violin_paired, RGR.int_violin_paired,
## TSR.int_violin_paired, : Argument 'cols' is deprecated. Use 'ncol' instead.
## Warning: Removed 6 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 6 rows containing missing values (`stat_bindot()`).
## Warning: Removed 6 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).
## Warning: Removed 6 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 6 rows containing missing values (`stat_bindot()`).
## Warning: Removed 6 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).
## Warning: Removed 6 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 6 rows containing missing values (`stat_bindot()`).
## Warning: Removed 6 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).
## Warning: Removed 6 rows containing non-finite values (`stat_ydensity()`).
## Warning: Removed 6 rows containing missing values (`stat_bindot()`).
## Warning: Removed 6 rows containing non-finite values (`stat_compare_means()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).
dev.off()
## quartz_off_screen 
##                 2