A function to do a t-test to determine if varias values in a linear model is significantly different than others. Arguments: reg = the linear model coefnum = 1 = intercept, 2 = beta … val = value you would like to test, the default lm tests if value is significantly different from zero.

This function will run a linear model of the percent relative growth, as well as correlations in both pearson and spearman and will also plot it in ggplot, if desired.

data = data.frame concentration = concentration plot = logical

RelGrowth.lm <- function(data, concentration, plot){
  lin.mod <- lm(data$ppmeanrelgrowth[data$conc == concentration] ~ data$odrelgrowth[data$conc == concentration])
  sum.linmod <- summary(lin.mod)
  pearson <- cor.test(data$ppmeanrelgrowth[data$conc == concentration], 
           data$odrelgrowth[data$conc == concentration], method = "pearson")
  spearman <- cor.test(data$ppmeanrelgrowth[data$conc == concentration], 
           data$odrelgrowth[data$conc == concentration], method = "spearman")
  beta <- ttest(lin.mod, 2, 1) # t-test for Beta significantly different than one
  bias <- (sum.linmod[[4]][2] - 1)*100 #percent Bias
  coeff.var <- (sum.linmod[[4]][4]/sum.linmod[[4]][2])*100

  if(plot == TRUE){
    library(ggplot2)
  p <- ggplot(data[data$conc == concentration,], aes(y = odrelgrowth, x = ppmeanrelgrowth)) +
    geom_point(aes(colour = factor(species))) +
    guides(colour = guide_legend(title = "Species")) +
    scale_y_continuous(limits = c(0, 110), breaks = c(0, 25, 50, 75, 100)) +
    scale_x_continuous(limits = c(0, 110), breaks = c(0, 25, 50, 75, 100)) +
    geom_smooth(method = "lm", se = FALSE, fullrange = TRUE, col = "black") +
    xlab("% Poison Plate Growth, relative to control") + 
    ylab("% Optical Density growth, relative to control") + 
    theme_bw() +
    theme(axis.text.x = element_text(size = 10, face = "bold"),
          axis.text.y = element_text(size = 10, face = "bold"),
          axis.title.x = element_text(size = 15, face = "bold"),
          axis.title.y = element_text(size = 15, face = "bold"),
          legend.text = element_text(size = 10, face = "bold.italic"),
          legend.key = element_blank(),
          legend.title = element_text(size = 15, face="bold"))
  results <- list(sum.linmod, pearson, spearman, beta, bias, coeff.var, p)
  names(results) <- c("lm", "pearson", "spearman", "beta.t", "per.bias","coeff.var", "plot")
  return(results)
  } else {
    results <- list(sum.linmod, pearson, spearman, beta, bias, coeff.var)
    names(results) <- c("lm", "pearson", "spearman", "beta.t", "per.bias", "coeff.var")
    return(results)
  }
}

We want to look at the correlation of the two methods, poison plate and optical density, to determine if the optical density method is any good.

Ethaboxam relative growth correlations

eth.cor.pp <- ddply(cor[cor$chem == "ethaboxam" & cor$method == "poison_plate",], c("is", "species", "conc"), 
      summarize, 
      ppmeanrelgrowth = 100*mean(relgrowth, na.rm = TRUE))
eth.cor.od <- ddply(cor[cor$chem == "ethaboxam" & cor$method == "optical_density",], c("is", "species", "conc"), 
      summarize, 
      odmeanrelgrowth = 100*mean(relgrowth, na.rm = TRUE))
eth.cor <- cbind.data.frame(eth.cor.pp, eth.cor.od$odmeanrelgrowth)
colnames(eth.cor) <- c("is", "species", "conc", "ppmeanrelgrowth", "odrelgrowth")
eth.001 <- RelGrowth.lm(eth.cor, concentration = 0.01, plot = TRUE)
eth.001
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -12.0305  -1.9817   0.2627   1.7828  10.3217 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                   9.87510    9.10676   1.084
## data$odrelgrowth[data$conc == concentration]  0.88127    0.09423   9.353
##                                                    Pr(>|t|)    
## (Intercept)                                           0.287    
## data$odrelgrowth[data$conc == concentration] 0.000000000413 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.003 on 28 degrees of freedom
## Multiple R-squared:  0.7575, Adjusted R-squared:  0.7489 
## F-statistic: 87.47 on 1 and 28 DF,  p-value: 0.0000000004127
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 9.3528, df = 28, p-value = 0.0000000004127
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.7430963 0.9368618
## sample estimates:
##       cor 
## 0.8703579 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 1734, p-value = 0.0004029
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##      rho 
## 0.614238 
## 
## 
## $beta.t
## [1] 0.2180441
## 
## $per.bias
## [1] -11.87307
## 
## $coeff.var
## [1] 10.69199
## 
## $plot

eth.01 <- RelGrowth.lm(eth.cor, concentration = 0.1, plot = TRUE)
eth.01
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -21.889  -7.973   2.162   5.245  23.011 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                  -25.9061     7.2021  -3.597
## data$odrelgrowth[data$conc == concentration]   1.1886     0.0814  14.602
##                                                        Pr(>|t|)    
## (Intercept)                                             0.00122 ** 
## data$odrelgrowth[data$conc == concentration] 0.0000000000000128 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9.086 on 28 degrees of freedom
## Multiple R-squared:  0.8839, Adjusted R-squared:  0.8798 
## F-statistic: 213.2 on 1 and 28 DF,  p-value: 0.00000000000001276
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 14.602, df = 28, p-value = 0.00000000000001288
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.8769341 0.9714102
## sample estimates:
##       cor 
## 0.9401724 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 606, p-value = 0.0000005663
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.8651835 
## 
## 
## $beta.t
## [1] 0.02804733
## 
## $per.bias
## [1] 18.85864
## 
## $coeff.var
## [1] 6.848325
## 
## $plot
## Warning: Removed 2 rows containing missing values (geom_smooth).

eth.05 <- RelGrowth.lm(eth.cor, concentration = 0.5, plot = TRUE)
eth.05
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -25.9634  -6.6009  -0.1541   5.9694  30.9924 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                  -9.53909    5.75551  -1.657
## data$odrelgrowth[data$conc == concentration]  1.03313    0.08329  12.404
##                                                      Pr(>|t|)    
## (Intercept)                                             0.109    
## data$odrelgrowth[data$conc == concentration] 0.00000000000068 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.62 on 28 degrees of freedom
## Multiple R-squared:  0.846,  Adjusted R-squared:  0.8405 
## F-statistic: 153.9 on 1 and 28 DF,  p-value: 0.0000000000006796
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 12.404, df = 28, p-value = 0.0000000000006795
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.8368378 0.9614634
## sample estimates:
##       cor 
## 0.9197995 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 586, p-value = 0.0000005246
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.8696329 
## 
## 
## $beta.t
## [1] 0.6937975
## 
## $per.bias
## [1] 3.313298
## 
## $coeff.var
## [1] 8.062027
## 
## $plot

eth.1 <- RelGrowth.lm(eth.cor, concentration = 1, plot = TRUE)
eth.1
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -24.60 -12.24  -3.15   8.12  38.86 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                    5.7876     6.0603   0.955
## data$odrelgrowth[data$conc == concentration]   0.9177     0.1172   7.832
##                                                  Pr(>|t|)    
## (Intercept)                                         0.348    
## data$odrelgrowth[data$conc == concentration] 0.0000000157 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 18.49 on 28 degrees of freedom
## Multiple R-squared:  0.6866, Adjusted R-squared:  0.6754 
## F-statistic: 61.34 on 1 and 28 DF,  p-value: 0.00000001569
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 7.8318, df = 28, p-value = 0.00000001569
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.6676330 0.9155582
## sample estimates:
##       cor 
## 0.8286008 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 1004, p-value = 0.000001908
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.7766407 
## 
## 
## $beta.t
## [1] 0.4884646
## 
## $per.bias
## [1] -8.226295
## 
## $coeff.var
## [1] 12.76849
## 
## $plot

eth.5 <- RelGrowth.lm(eth.cor, concentration = 5, plot = TRUE)
## Warning in cor.test.default(data$ppmeanrelgrowth[data$conc ==
## concentration], : Cannot compute exact p-value with ties
eth.5
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -14.5090  -2.7679  -0.7679   2.4037  18.6542 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                  -9.70995    1.67512  -5.797
## data$odrelgrowth[data$conc == concentration]  0.93803    0.04154  22.579
##                                                          Pr(>|t|)    
## (Intercept)                                            0.00000317 ***
## data$odrelgrowth[data$conc == concentration] < 0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 6.622 on 28 degrees of freedom
## Multiple R-squared:  0.9479, Adjusted R-squared:  0.9461 
## F-statistic: 509.8 on 1 and 28 DF,  p-value: < 0.00000000000000022
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 22.579, df = 28, p-value < 0.00000000000000022
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.9447310 0.9875068
## sample estimates:
##      cor 
## 0.973621 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 2067.7, p-value = 0.00207
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.5399933 
## 
## 
## $beta.t
## [1] 0.146986
## 
## $per.bias
## [1] -6.196723
## 
## $coeff.var
## [1] 4.428861
## 
## $plot
## Warning: Removed 9 rows containing missing values (geom_smooth).

eth.20 <- RelGrowth.lm(eth.cor, concentration = 20, plot = TRUE)
## Warning in cor.test.default(data$ppmeanrelgrowth[data$conc ==
## concentration], : Cannot compute exact p-value with ties
eth.20
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -15.383  -2.803   0.611   3.599   8.722 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                  -12.2340     1.5216   -8.04
## data$odrelgrowth[data$conc == concentration]   0.9993     0.0420   23.79
##                                                          Pr(>|t|)    
## (Intercept)                                         0.00000000936 ***
## data$odrelgrowth[data$conc == concentration] < 0.0000000000000002 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.954 on 28 degrees of freedom
## Multiple R-squared:  0.9529, Adjusted R-squared:  0.9512 
## F-statistic: 566.2 on 1 and 28 DF,  p-value: < 0.00000000000000022
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 23.794, df = 28, p-value < 0.00000000000000022
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.9499662 0.9887137
## sample estimates:
##       cor 
## 0.9761532 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 2402.7, p-value = 0.009538
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.4654791 
## 
## 
## $beta.t
## [1] 0.9862368
## 
## $per.bias
## [1] -0.0730954
## 
## $coeff.var
## [1] 4.202696
## 
## $plot
## Warning: Removed 6 rows containing missing values (geom_smooth).

Mefenoxam relative growth correlations

mef.cor.pp <- ddply(cor[cor$chem == "mefenoxam" & cor$method == "poison_plate",], c("is", "species", "conc"), 
      summarize, 
      ppmeanrelgrowth = 100*mean(relgrowth, na.rm = TRUE))
mef.cor.od <- ddply(cor[cor$chem == "mefenoxam" & cor$method == "optical_density",], c("is", "species", "conc"), 
      summarize, 
      odmeanrelgrowth = 100*mean(relgrowth, na.rm = TRUE))
mef.cor.od <- mef.cor.od[!mef.cor.od$conc == 100,]
mef.cor.pp <- mef.cor.pp[!mef.cor.pp$conc == 100,]
mef.cor <- cbind.data.frame(mef.cor.pp, mef.cor.od$odmeanrelgrowth)
colnames(mef.cor) <- c("is", "species", "conc", "ppmeanrelgrowth", "odrelgrowth")
mef.001 <- RelGrowth.lm(mef.cor, concentration = 0.01, plot = TRUE)
mef.001
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -19.7226  -2.4279   0.2544   4.7137  11.5604 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                  52.53813    8.14792   6.448
## data$odrelgrowth[data$conc == concentration]  0.40612    0.08881   4.573
##                                                Pr(>|t|)    
## (Intercept)                                  0.00000217 ***
## data$odrelgrowth[data$conc == concentration]   0.000165 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.191 on 21 degrees of freedom
## Multiple R-squared:  0.4989, Adjusted R-squared:  0.4751 
## F-statistic: 20.91 on 1 and 21 DF,  p-value: 0.0001652
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 4.5729, df = 21, p-value = 0.0001652
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.4149891 0.8663221
## sample estimates:
##       cor 
## 0.7063615 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 628, p-value = 0.000388
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.6897233 
## 
## 
## $beta.t
## [1] 0.00000128355
## 
## $per.bias
## [1] -59.38804
## 
## $coeff.var
## [1] 21.86781
## 
## $plot
## Warning: Removed 2 rows containing non-finite values (stat_smooth).
## Warning: Removed 2 rows containing missing values (geom_point).
## Warning: Removed 17 rows containing missing values (geom_smooth).

mef.01 <- RelGrowth.lm(mef.cor, concentration = 0.1, plot = TRUE)
mef.01
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -30.4901  -9.9562   0.6523   9.6580  28.9574 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                   -6.2375     7.1482  -0.873
## data$odrelgrowth[data$conc == concentration]   0.9262     0.1184   7.825
##                                                 Pr(>|t|)    
## (Intercept)                                        0.393    
## data$odrelgrowth[data$conc == concentration] 0.000000117 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 15.31 on 21 degrees of freedom
## Multiple R-squared:  0.7446, Adjusted R-squared:  0.7325 
## F-statistic: 61.23 on 1 and 21 DF,  p-value: 0.0000001171
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 7.8253, df = 21, p-value = 0.0000001171
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.6995462 0.9405659
## sample estimates:
##       cor 
## 0.8629212 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 406, p-value = 0.000006679
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.7994071 
## 
## 
## $beta.t
## [1] 0.5398335
## 
## $per.bias
## [1] -7.377004
## 
## $coeff.var
## [1] 12.77914
## 
## $plot
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
## Warning: Removed 1 rows containing missing values (geom_point).

mef.05 <- RelGrowth.lm(mef.cor, concentration = 0.5, plot = TRUE)
## Warning in cor.test.default(data$ppmeanrelgrowth[data$conc ==
## concentration], : Cannot compute exact p-value with ties
mef.05
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -18.970  -6.336  -3.075   5.887  23.732 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                  -1.24754    3.25583  -0.383
## data$odrelgrowth[data$conc == concentration]  1.03001    0.08439  12.205
##                                                     Pr(>|t|)    
## (Intercept)                                            0.705    
## data$odrelgrowth[data$conc == concentration] 0.0000000000532 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.17 on 21 degrees of freedom
## Multiple R-squared:  0.8764, Adjusted R-squared:  0.8706 
## F-statistic:   149 on 1 and 21 DF,  p-value: 0.00000000005324
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 12.205, df = 21, p-value = 0.00000000005324
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.8532511 0.9729345
## sample estimates:
##       cor 
## 0.9361856 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 654.61, p-value = 0.0003928
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.6765746 
## 
## 
## $beta.t
## [1] 0.7257129
## 
## $per.bias
## [1] 3.000686
## 
## $coeff.var
## [1] 8.193344
## 
## $plot

mef.1 <- RelGrowth.lm(mef.cor, concentration = 1, plot = TRUE)
## Warning in cor.test.default(data$ppmeanrelgrowth[data$conc ==
## concentration], : Cannot compute exact p-value with ties
mef.1
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -18.2073  -5.1524  -0.6551   6.1889  16.6888 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                  -2.75342    2.41411  -1.141
## data$odrelgrowth[data$conc == concentration]  0.95967    0.06523  14.711
##                                                      Pr(>|t|)    
## (Intercept)                                             0.267    
## data$odrelgrowth[data$conc == concentration] 0.00000000000156 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 8.912 on 21 degrees of freedom
## Multiple R-squared:  0.9115, Adjusted R-squared:  0.9073 
## F-statistic: 216.4 on 1 and 21 DF,  p-value: 0.000000000001565
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 14.711, df = 21, p-value = 0.000000000001565
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.8946287 0.9809135
## sample estimates:
##       cor 
## 0.9547498 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 769.79, p-value = 0.001613
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##     rho 
## 0.61967 
## 
## 
## $beta.t
## [1] 0.5430472
## 
## $per.bias
## [1] -4.033238
## 
## $coeff.var
## [1] 6.797615
## 
## $plot

mef.10 <- RelGrowth.lm(mef.cor, concentration = 10, plot = TRUE)
## Warning in cor.test.default(data$ppmeanrelgrowth[data$conc ==
## concentration], : Cannot compute exact p-value with ties
mef.10
## $lm
## 
## Call:
## lm(formula = data$ppmeanrelgrowth[data$conc == concentration] ~ 
##     data$odrelgrowth[data$conc == concentration])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -15.708  -3.826   1.015   4.699  14.033 
## 
## Coefficients:
##                                              Estimate Std. Error t value
## (Intercept)                                  -3.32081    2.01807  -1.646
## data$odrelgrowth[data$conc == concentration]  0.92239    0.05793  15.923
##                                                       Pr(>|t|)    
## (Intercept)                                              0.115    
## data$odrelgrowth[data$conc == concentration] 0.000000000000338 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 7.963 on 21 degrees of freedom
## Multiple R-squared:  0.9235, Adjusted R-squared:  0.9199 
## F-statistic: 253.6 on 1 and 21 DF,  p-value: 0.0000000000003381
## 
## 
## $pearson
## 
##  Pearson's product-moment correlation
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## t = 15.923, df = 21, p-value = 0.000000000000338
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.9087863 0.9835784
## sample estimates:
##       cor 
## 0.9609959 
## 
## 
## $spearman
## 
##  Spearman's rank correlation rho
## 
## data:  data$ppmeanrelgrowth[data$conc == concentration] and data$odrelgrowth[data$conc == concentration]
## S = 828.94, p-value = 0.003016
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.5904454 
## 
## 
## $beta.t
## [1] 0.1946402
## 
## $per.bias
## [1] -7.760812
## 
## $coeff.var
## [1] 6.280042
## 
## $plot
## Warning: Removed 1 rows containing non-finite values (stat_smooth).

## Warning: Removed 1 rows containing missing values (geom_point).

This code iterates through every isolate and generates a relative and absolute EC50 using the LL.4 model of drc and saves the output. I already went through and picked out the isolates for both mefenoxam and ethaboxam that have an EC50 beyond the concentration range tested in this study.

# briefly we are going to split up the data frame into each concentration to make it easier to take out individual isolates
cor_eth <- cor[cor$chem == "ethaboxam",]
cor_mef <- cor[cor$chem == "mefenoxam",]

# taking out insensitive isolates, otherwise convergence would not occur with the ll.4 model
insens_iso_eth <- c("MISO_8-29.1", "C-MNSO2_2-21", "NDSO_L-8-6", "ILSO_6-15C")
insens_iso_mef <- c("V-MISO2_6-46", "23.4B", "1.18A")

cor_eth <- cor_eth[!cor_eth$is %in% insens_iso_eth,]
cor_mef <- cor_mef[!cor_mef$is %in% insens_iso_mef,]
cor_eth$is <- factor(cor_eth$is)
cor_mef$is <- factor(cor_mef$is)

cor <- rbind.data.frame(cor_eth, cor_mef)

relative <- function(data){
  EC50.pp.rel <- data.frame(ED(data, 
                             respLev = c(50), 
                             type = "relative",
                             interval = "delta"),
                          level = 0.95)
rel.ec50.pp <- EC50.pp.rel[1][[1]]
return(rel.ec50.pp)
}
absolute <- function(data){
  EC50.pp.abs <- data.frame(ED(data, 
                             respLev = c(50), 
                             type = "absolute",
                             interval = "delta"),
                          level = 0.95)
abs.ec50.pp <- EC50.pp.abs[1][[1]]
return(abs.ec50.pp)
}
plug_EC <- function(chemistry){
  nm <- unique(cor$is[cor$chem == as.character(chemistry)])
dataframe_names <- c("is", "species", "method", "trial", "chem", "absolute", "relative")
meth.cor <- NULL
for (i in seq_along(nm)){
mefcor.pp.drc <- drm(100*relgrowth ~ conc, data = cor[cor$is == nm[[i]] & cor$method == "poison_plate" & cor$chem == as.character(chemistry),], curveid = trial, fct = LL.4(), na.action = na.omit)
mefcor.od.drc <- drm(100*relgrowth ~ conc, data = cor[cor$is == nm[[i]] & cor$method == "optical_density" & cor$chem == as.character(chemistry),], curveid = trial, fct = LL.4(), na.action = na.omit)
paste(print(nm[[i]]))
# RELATIVE 
rel.pp.mef <- relative(mefcor.pp.drc)
rel.od.mef <- relative(mefcor.od.drc)

# ABSOLUTE 
abs.pp.mef <- absolute(mefcor.pp.drc)
abs.od.mef <- absolute(mefcor.od.drc)

mef.cor_od <- data.frame(cbind.data.frame( 
                  nm[[i]], 
                  as.character(unique(cor$species[cor$is == nm[[i]]])),
                  as.character(unique(cor$method[cor$is == nm[[i]] & cor$method == "optical_density"])),
                  unique(cor$trial[cor$is == nm[[i]] & cor$method == "optical_density"]),
                  as.character(chemistry),
                  as.numeric(abs.od.mef),
                  as.numeric(rel.od.mef)))
colnames(mef.cor_od) <- dataframe_names
mef.cor_pp <- data.frame(cbind.data.frame( 
                  nm[[i]], 
                  as.character(unique(cor$species[cor$is == nm[[i]]])),
                  as.character(unique(cor$method[cor$is == nm[[i]] & cor$method == "poison_plate"])),
                  unique(cor$trial[cor$is == nm[[i]] & cor$method == "poison_plate"]),
                  as.character(chemistry),
                  as.numeric(abs.pp.mef),
                  as.numeric(rel.pp.mef)))
colnames(mef.cor_pp) <- dataframe_names

meth.cor <- rbind.data.frame(meth.cor, mef.cor_od, mef.cor_pp)
  }
return(meth.cor)
}

mefenoxam_ec50 <- plug_EC("mefenoxam")
ethaboxam_ec50 <- plug_EC("ethaboxam")

ec50_cor <- rbind.data.frame(ethaboxam_ec50, mefenoxam_ec50)

# not sure why one of the isolates had duplicates but they did, so this code will find duplicates in the absolute ec50s and delete the entire row. 
ec50_cor <- ec50_cor[-which(duplicated(ec50_cor$absolute)),] 

Table of EC50 values for every isolate tested for both mefenoxam and ethaboxam on both poison plate and optical density method.

is species chem method mean.abs std.abs mean.rel std.rel
AR_127.S.2.3.A Pythium irregulare ethaboxam optical_density 0.6017397 0.4608413 0.3258476 0.2118367
AR_127.S.2.3.A Pythium irregulare ethaboxam poison_plate 0.6474189 0.0242181 0.7462384 0.1600082
AR_127.S.2.3.A Pythium irregulare mefenoxam optical_density 0.1831292 0.0722302 0.1036954 0.0178995
AR_127.S.2.3.A Pythium irregulare mefenoxam poison_plate 0.1259046 0.0503855 0.1228201 0.0557412
AR_262.S.1.6.A Pythium aphanidermatum ethaboxam optical_density 0.4890281 0.0532135 0.4472674 0.0672784
AR_262.S.1.6.A Pythium aphanidermatum ethaboxam poison_plate 0.2093399 0.0147487 0.1991737 0.0172343
ARS_284.S1.4.A Pythium lutarium ethaboxam optical_density 0.2669444 0.0983561 0.2488793 0.0977931
ARS_284.S1.4.A Pythium lutarium ethaboxam poison_plate 0.2260918 0.0293079 0.1949081 0.0054857
C-NDSO2_1-11 Pythium perplexum ethaboxam optical_density 0.1673536 0.0045666 0.1324687 0.0026915
C-NDSO2_1-11 Pythium perplexum ethaboxam poison_plate 0.0983410 0.0112713 0.0977276 0.0100928
IASO_10-37.8RT Pythium aff. dissotocum ethaboxam optical_density 1.1413192 0.3019554 1.0115718 0.2570090
IASO_10-37.8RT Pythium aff. dissotocum ethaboxam poison_plate 1.0220161 0.6068654 1.0072584 0.5928676
IASO_10-38.14RT Pythium aff. dissotocum ethaboxam optical_density 1.0125252 0.2669542 0.9121016 0.1950198
IASO_10-38.14RT Pythium aff. dissotocum ethaboxam poison_plate 1.7250786 0.2861206 1.8877662 0.3800344
IASO_10-39.16rt Pythium aff. dissotocum ethaboxam optical_density 0.6248467 0.0759800 0.5562301 0.0206426
IASO_10-39.16rt Pythium aff. dissotocum ethaboxam poison_plate 1.6056028 0.1531086 1.7370847 0.1606027
IASO_6-10.15h Pythium oopapillum ethaboxam optical_density 0.5136203 0.0286944 0.4836774 0.0102900
IASO_6-10.15h Pythium oopapillum ethaboxam poison_plate 1.1130479 0.2173577 1.0919763 0.2239991
ILSO_1-31 Pythium irregulare ethaboxam optical_density 0.8616940 0.1247902 0.8372427 0.0556342
ILSO_1-31 Pythium irregulare ethaboxam poison_plate 0.8058171 0.0387544 1.0671747 0.0765512
ILSO_3-48C Pythium irregulare ethaboxam optical_density 0.9968918 0.2276545 0.5450930 0.1574642
ILSO_3-48C Pythium irregulare ethaboxam poison_plate 0.7286362 0.0211646 0.9552630 0.0460969
ILSO_3-48C Pythium irregulare mefenoxam optical_density 0.2218693 0.0780914 0.1509015 0.0575959
ILSO_3-48C Pythium irregulare mefenoxam poison_plate 0.1263038 0.0133000 0.1136575 0.0248296
ILSO_5-42C Pythium oopapillum ethaboxam optical_density 1.0026325 0.4214322 0.9374770 0.3795077
ILSO_5-42C Pythium oopapillum ethaboxam poison_plate 1.3388329 0.0166538 1.5284298 0.1501364
ILSO_5-42C Pythium oopapillum mefenoxam optical_density 0.0934891 0.0727647 0.0828173 0.0621251
ILSO_5-42C Pythium oopapillum mefenoxam poison_plate 0.0176811 0.0013969 0.0190659 0.0028424
ILSO_6-2B Pythium oopapillum ethaboxam optical_density 0.7590296 0.0573760 0.6391139 0.0124021
ILSO_6-2B Pythium oopapillum ethaboxam poison_plate 0.9836553 0.0599357 0.9708861 0.0039751
ILSO_6-2B Pythium oopapillum mefenoxam optical_density 0.1616391 0.0430944 0.1512861 0.0385509
ILSO_6-2B Pythium oopapillum mefenoxam poison_plate 0.1374047 0.0218105 0.1122750 0.0353251
INSO_1-10C Pythium sylvaticum ethaboxam optical_density 0.6021485 0.2261376 0.4896181 0.2288380
INSO_1-10C Pythium sylvaticum ethaboxam poison_plate 0.1023615 0.0310532 0.1085730 0.0178761
INSO_1-10C Pythium sylvaticum mefenoxam optical_density 0.0556356 0.0142788 0.0540463 0.0146426
INSO_1-10C Pythium sylvaticum mefenoxam poison_plate 0.0240773 0.0109447 0.0240587 0.0109250
INSO_1-8A Pythium lutarium ethaboxam optical_density 0.6975005 0.1292836 0.6548995 0.0999101
INSO_1-8A Pythium lutarium ethaboxam poison_plate 1.4568919 0.1234575 1.5417715 0.0704994
KSSO_6-1 Pythium ultimum var. ultimum ethaboxam optical_density 2.1738744 0.1268949 1.8935903 0.0802024
KSSO_6-1 Pythium ultimum var. ultimum ethaboxam poison_plate 1.4760269 0.1444716 1.6207549 0.0955815
KSSO_6-47 Phytophthora sansomeana ethaboxam optical_density 0.0634017 0.0315296 0.0526138 0.0286371
KSSO_6-47 Phytophthora sansomeana ethaboxam poison_plate 0.0324276 0.0043185 0.0324150 0.0039692
MISO_1-4 Pythium lutarium ethaboxam optical_density 0.9515964 0.1695581 0.8880759 0.1894814
MISO_1-4 Pythium lutarium ethaboxam poison_plate 0.6058080 0.0382837 0.6033125 0.0375648
MISO_5-19H Pythium torulosum ethaboxam optical_density 1.3033651 0.3326300 0.9839949 0.2931130
MISO_5-19H Pythium torulosum ethaboxam poison_plate 1.1133215 0.0441768 1.1914970 0.0877672
MISO_8-10 Pythium ultimum var. ultimum ethaboxam optical_density 0.7494623 0.2384325 0.6596120 0.2148583
MISO_8-10 Pythium ultimum var. ultimum ethaboxam poison_plate 1.2705559 0.0327570 1.3791302 0.0529770
NDSO_1-42 Pythium sylvaticum ethaboxam optical_density 0.5083377 0.0455087 0.4342847 0.0397514
NDSO_1-42 Pythium sylvaticum ethaboxam poison_plate 0.5029008 0.0315540 0.5163838 0.0454677
NDSO_1-42 Pythium sylvaticum mefenoxam optical_density 0.0843794 0.0395403 0.0776105 0.0309785
NDSO_1-42 Pythium sylvaticum mefenoxam poison_plate 0.0584407 0.0271372 0.0592125 0.0288098
NESO_2-13 Pythium sylvaticum ethaboxam optical_density 0.5351099 0.1587134 0.4859459 0.1842366
NESO_2-13 Pythium sylvaticum ethaboxam poison_plate 0.2755640 0.0195702 0.3037442 0.0022381
NESO_2-13 Pythium sylvaticum mefenoxam optical_density 0.1626739 0.0513231 0.1500946 0.0446556
NESO_2-13 Pythium sylvaticum mefenoxam poison_plate 0.0659475 0.0136608 0.0657198 0.0179300
NESO_4-29 Pythium perplexum ethaboxam optical_density 0.0997645 0.0070532 0.0880328 0.0143253
NESO_4-29 Pythium perplexum ethaboxam poison_plate 0.1238281 0.0031861 0.1199439 0.0006862
V-KSSO2_1-7 Phytophthora sansomeana ethaboxam optical_density 0.0477238 0.0204292 0.0408790 0.0145521
V-KSSO2_1-7 Phytophthora sansomeana ethaboxam poison_plate 0.0164446 0.0004557 0.0161274 0.0007975
V-KSSO2_3-6 Phytophthora sansomeana ethaboxam optical_density 0.0527088 0.0075370 0.0435138 0.0123592
V-KSSO2_3-6 Phytophthora sansomeana ethaboxam poison_plate 0.0331940 0.0092453 0.0336671 0.0089418
V-MISO2_2-57 Pythium perplexum ethaboxam optical_density 0.1575673 0.0323676 0.1342038 0.0319532
V-MISO2_2-57 Pythium perplexum ethaboxam poison_plate 0.0746280 0.0000147 0.0735610 0.0014948
WISO_4-13 Pythium ultimum var. ultimum ethaboxam optical_density 1.4114181 0.3025662 1.2496867 0.2475802
WISO_4-13 Pythium ultimum var. ultimum ethaboxam poison_plate 1.6811566 0.0761205 1.7426576 0.0073123
AR_96.S.2.1.A Pythium spinosum mefenoxam optical_density 0.0640711 0.0155281 0.0552741 0.0148170
AR_96.S.2.1.A Pythium spinosum mefenoxam poison_plate 0.0408055 0.0210795 0.0416514 0.0219245
C-KSSO2_1-25 Phytopythium litorale mefenoxam optical_density 1.1289415 0.2611411 0.6216587 0.0899566
C-KSSO2_1-25 Phytopythium litorale mefenoxam poison_plate 0.9949350 0.1711380 0.6115304 0.1309216
C-SDSO2_5-35 Pythium intermedium mefenoxam optical_density 0.1038246 0.0015915 0.1042345 0.0085674
C-SDSO2_5-35 Pythium intermedium mefenoxam poison_plate 0.2039187 0.0848682 0.1791958 0.0740958
IASO_3-41.17 Phytophthora sojae mefenoxam optical_density 0.0564770 0.0357976 0.0646445 0.0374231
IASO_3-41.17 Phytophthora sojae mefenoxam poison_plate 0.0193404 0.0062906 0.0193835 0.0063338
IASO_6-10.15H Pythium oopapillum mefenoxam optical_density 0.2521354 0.0684946 0.2051422 0.0498267
IASO_6-10.15H Pythium oopapillum mefenoxam poison_plate 0.1369200 0.0624607 0.1212678 0.0535314
ILSO_3-21A Pythium ultimum var. sporangiiferum mefenoxam optical_density 0.0171647 0.0110661 0.0164300 0.0103643
ILSO_3-21A Pythium ultimum var. sporangiiferum mefenoxam poison_plate 0.0444185 0.0319651 0.0486010 0.0361461
INSO_3-10 Pythium pleroticum mefenoxam optical_density 0.0354960 0.0029223 0.0307489 0.0010692
INSO_3-10 Pythium pleroticum mefenoxam poison_plate 0.0199470 0.0063061 0.0201349 0.0064933
INSO_3-43 Pythium spinosum mefenoxam optical_density 0.2043519 0.0807916 0.1498540 0.0461110
INSO_3-43 Pythium spinosum mefenoxam poison_plate 0.0983442 0.0584485 0.0984697 0.0614379
INSO_4-40 Pythium spinosum mefenoxam optical_density 0.0905818 0.0403220 0.0878968 0.0396769
INSO_4-40 Pythium spinosum mefenoxam poison_plate 0.0502867 0.0279427 0.0467290 0.0252301
INSO_5-50 Pythium ultimum var. sporangiiferum mefenoxam optical_density 0.0193989 0.0011695 0.0195310 0.0012364
INSO_5-50 Pythium ultimum var. sporangiiferum mefenoxam poison_plate 0.0394601 0.0130432 0.0409852 0.0183301
KSSO_6-30 Pythium ultimum var. sporangiiferum mefenoxam optical_density 0.0155855 0.0055027 0.0140713 0.0044018
KSSO_6-30 Pythium ultimum var. sporangiiferum mefenoxam poison_plate 0.0729989 0.0409378 0.0843618 0.0553740
V-IASO2_6-55_1 Phytopythium litorale mefenoxam optical_density 0.9960691 0.2530901 0.4135866 0.1211882
V-IASO2_6-55_1 Phytopythium litorale mefenoxam poison_plate 2.4032623 0.9107058 0.9779876 0.5341688
V-SDSO2_1-53 Phytophthora sojae mefenoxam optical_density 0.0846261 0.0036287 0.0807847 0.0015759
V-SDSO2_1-53 Phytophthora sojae mefenoxam poison_plate 0.0525604 0.0387617 0.0529119 0.0391127

Lets do an ANOVA for each chemistry and the effect of method. We have log transformed these data for homogeneity of variance.

model 1: method as fixed effect and isolate as random effect

We are treating isolate as a random effect because we we sampled these isolates from a larger possible population of isolates and we want to generalize over all isolates

lm_mef <- lmer(absolute ~ method + (1|is), data = ec50_cor[ec50_cor$chem == "mefenoxam",])

car::Anova(lm_mef, test.statistic="F", type = 2) # using type II ANOVA for unbalanced data. Some isolates have more technical replicates than others. So the mean over all isolates is different.  
## Analysis of Deviance Table (Type II Wald F tests with Kenward-Roger df)
## 
## Response: absolute
##             F Df Df.res Pr(>F)
## method 0.8358  1 84.598 0.3632
plot(lm_mef, type = c("p", "smooth"), id = 0.05) # regression diagnostics

lsmeans_mef <- lsmeans::lsmeans(lm_mef, "method")
plot(lsmeans_mef)

This is what we expected, no significant differnces for the method.

Lets do the same for ethaboxam.

lm_eth <- lmer(absolute ~ method + (1|is), data = ec50_cor[ec50_cor$chem == "ethaboxam",])
car::Anova(lm_eth, test.statistic="F", type = 2) # using type II ANOVA for unbalanced data. Some isolates have more technical replicates than others. So the mean over all isolates is different.  
## Analysis of Deviance Table (Type II Wald F tests with Kenward-Roger df)
## 
## Response: absolute
##             F Df Df.res Pr(>F)
## method 1.1121  1 82.098 0.2947
plot(lm_eth, type = c("p", "smooth"), id = 0.05)# regression diagnostics

lsmeans_eth <- lsmeans::lsmeans(lm_eth, "method")
plot(lsmeans_eth)

Lets do correlation analysis between the two methods separated by chemistry.

We are testing the correlation of the absolute EC50s between the two methods. We are going to use spearman’s correlation coeffiecient since it is rank based it can handle outliers with high leverage.

cor_mef <- lm(mean.abs.pp ~ mean.abs.od, data = EC50[EC50$chem == "mefenoxam",])
summary(cor_mef)
## 
## Call:
## lm(formula = mean.abs.pp ~ mean.abs.od, data = EC50[EC50$chem == 
##     "mefenoxam", ])
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.69793 -0.08873  0.00269  0.05529  0.91905 
## 
## Coefficients:
##             Estimate Std. Error t value    Pr(>|t|)    
## (Intercept) -0.07988    0.07755  -1.030       0.317    
## mean.abs.od  1.57027    0.21667   7.247 0.000000972 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2866 on 18 degrees of freedom
## Multiple R-squared:  0.7448, Adjusted R-squared:  0.7306 
## F-statistic: 52.52 on 1 and 18 DF,  p-value: 0.000000972
par(mfrow = c(2,2))
plot(cor_mef)

ttest(cor_mef, 1, 0) # tests if intercept is significantly different than 0
## [1] 0.3166105
ttest(cor_mef, 2, 1) # tests if slope (beta) is significantly different than 1
## [1] 0.01692273

There is a significant linear relationship between the mean absolute EC50 using either method. Since it looked like there were some points with a bit of leverage we will use spearman’s correlation to test the significance of the correlation.We will also look at the spearman:pearson correlation ratio to see if the correlation is more monotonic or linear.

spear.cor <- cor.test(EC50$mean.abs.pp[EC50$chem == "mefenoxam"], 
         EC50$mean.abs.od[EC50$chem == "mefenoxam"], 
         method = "spearman")
pear.cor <- cor.test(EC50$mean.abs.pp[EC50$chem == "mefenoxam"], 
         EC50$mean.abs.od[EC50$chem == "mefenoxam"], 
         method = "pearson")
spear.cor
## 
##  Spearman's rank correlation rho
## 
## data:  EC50$mean.abs.pp[EC50$chem == "mefenoxam"] and EC50$mean.abs.od[EC50$chem == "mefenoxam"]
## S = 358, p-value = 0.0003757
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.7308271
pear.cor
## 
##  Pearson's product-moment correlation
## 
## data:  EC50$mean.abs.pp[EC50$chem == "mefenoxam"] and EC50$mean.abs.od[EC50$chem == "mefenoxam"]
## t = 7.2471, df = 18, p-value = 0.000000972
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.6802565 0.9447289
## sample estimates:
##       cor 
## 0.8629927

Since the spearman correlation coeficient is lower than the pearson coefficient, this indicates we have more of a linear relationship than a monotonic one. This is a good thing because we would expect a perfect linear relationship between the methods.

cor_eth <- lm(mean.abs.pp ~ mean.abs.od, data = EC50[EC50$chem == "ethaboxam",])
summary(cor_eth)
## 
## Call:
## lm(formula = mean.abs.pp ~ mean.abs.od, data = EC50[EC50$chem == 
##     "ethaboxam", ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -0.5862 -0.1956 -0.1347  0.2654  0.9172 
## 
## Coefficients:
##             Estimate Std. Error t value  Pr(>|t|)    
## (Intercept)   0.1342     0.1364   0.984     0.335    
## mean.abs.od   0.8869     0.1625   5.457 0.0000131 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.4029 on 24 degrees of freedom
## Multiple R-squared:  0.5538, Adjusted R-squared:  0.5352 
## F-statistic: 29.78 on 1 and 24 DF,  p-value: 0.00001312
par(mfrow = c(2,2))
plot(cor_eth)

ttest(cor_eth, 1, 0) # tests if intercept is significantly different than 0
## [1] 0.3350091
ttest(cor_eth, 2, 1) # tests if slope (beta) is significantly different than 1
## [1] 0.4931334

There is a significant linear relationship between the mean absolute EC50 using either method. Since it looked like there were some points with a bit of leverage we will use spearman’s correlation to test the significance of the correlation.

spear.cor <- cor.test(EC50$mean.abs.pp[EC50$chem == "ethaboxam"], 
         EC50$mean.abs.od[EC50$chem == "ethaboxam"], 
         method = "spearman")
pear.cor <- cor.test(EC50$mean.abs.pp[EC50$chem == "ethaboxam"], 
         EC50$mean.abs.od[EC50$chem == "ethaboxam"], 
         method = "pearson")

spear.cor
## 
##  Spearman's rank correlation rho
## 
## data:  EC50$mean.abs.pp[EC50$chem == "ethaboxam"] and EC50$mean.abs.od[EC50$chem == "ethaboxam"]
## S = 482, p-value = 0.000001932
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
##       rho 
## 0.8352137
pear.cor
## 
##  Pearson's product-moment correlation
## 
## data:  EC50$mean.abs.pp[EC50$chem == "ethaboxam"] and EC50$mean.abs.od[EC50$chem == "ethaboxam"]
## t = 5.4573, df = 24, p-value = 0.00001312
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.5012888 0.8783242
## sample estimates:
##       cor 
## 0.7441461

Since the spearman correlation coeficient is higher than the pearson coefficient, this indicates we have more of a monotonic relationship than a linear one. This is ok, but we would like to see it flipped around.

Lets look at the correlation of the relative growth values

ggplot(EC50, aes(mean.abs.pp, mean.abs.od)) + 
  geom_point(aes(colour = species_od)) +
  #geom_errorbarh(aes(xmax = mean.rel.pp + std.rel.pp, xmin = mean.rel.pp - std.rel.pp, height = .01)) +
  #geom_errorbar(aes(ymax = mean.rel.od + std.rel.od, ymin = mean.rel.od - std.rel.od, width = .01)) +
  geom_smooth(method = "lm", se = FALSE) + 
  theme_bw() + 
  facet_wrap(~chem)

EC50_spec <- ddply(EC50, c("species_od","chem", "method"), 
      summarize, 
      mean.abs.pp = mean(mean.abs.pp, na.rm = TRUE),
      std.abs.pp = std.error(std.abs.pp, na.rm = TRUE),
      mean.abs.od = mean(mean.abs.od, na.rm = TRUE),
      std.abs.od = std.error(std.abs.od, na.rm = TRUE))

ggplot(EC50_spec, aes(mean.abs.pp, mean.abs.od)) + 
  geom_point(aes(colour = species_od, shape = chem)) +
  #geom_errorbarh(aes(xmax = mean.abs.pp + std.abs.pp, xmin = mean.abs.pp - std.abs.pp, height = .01)) +
  #geom_errorbar(aes(ymax = mean.abs.od + std.abs.od, ymin = mean.abs.od - std.abs.od, width = .01)) +
  geom_smooth(method = "lm", se = FALSE) + 
  theme_bw() +
  facet_wrap(~chem)

summary(lm(mean.abs.pp ~ mean.abs.od, data = EC50_spec))
## 
## Call:
## lm(formula = mean.abs.pp ~ mean.abs.od, data = EC50_spec)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.36128 -0.11452 -0.02151  0.06983  0.50524 
## 
## Coefficients:
##             Estimate Std. Error t value     Pr(>|t|)    
## (Intercept) -0.04456    0.07842  -0.568        0.577    
## mean.abs.od  1.16557    0.12007   9.707 0.0000000239 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2351 on 17 degrees of freedom
## Multiple R-squared:  0.8472, Adjusted R-squared:  0.8382 
## F-statistic: 94.23 on 1 and 17 DF,  p-value: 0.00000002389