setwd("~/Library/CloudStorage/GoogleDrive-icarounam@gmail.com/Mi unidad/Agrosavia/Env_muestra/data")
datos<-read.table("granofin.csv", header=T, sep=',')
datos$curva <- factor(datos$curva, levels = c("1", "2", "3"),
labels = c("P3", "P1", "P2"))
datos$gen<-as.factor(datos$gen)
datos$curva<-as.factor(datos$curva)
datos$id<-as.factor(datos$id)
datos$muestra<-as.factor(datos$muestra)
datos$dia<-as.factor(datos$dia)
library(ggplot2)
library(Rmisc)
## Loading required package: lattice
## Loading required package: plyr
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plyr':
##
## arrange, count, desc, failwith, id, mutate, rename, summarise,
## summarize
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
## ✓ tibble 3.1.6 ✓ purrr 0.3.4
## ✓ tidyr 1.1.4 ✓ stringr 1.4.0
## ✓ readr 2.1.1 ✓ forcats 0.5.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::arrange() masks plyr::arrange()
## x purrr::compact() masks plyr::compact()
## x dplyr::count() masks plyr::count()
## x dplyr::failwith() masks plyr::failwith()
## x dplyr::filter() masks stats::filter()
## x dplyr::id() masks plyr::id()
## x dplyr::lag() masks stats::lag()
## x dplyr::mutate() masks plyr::mutate()
## x dplyr::rename() masks plyr::rename()
## x dplyr::summarise() masks plyr::summarise()
## x dplyr::summarize() masks plyr::summarize()
library(ggpubr)
##
## Attaching package: 'ggpubr'
## The following object is masked from 'package:plyr':
##
## mutate
library(rstatix)
##
## Attaching package: 'rstatix'
## The following objects are masked from 'package:plyr':
##
## desc, mutate
## The following object is masked from 'package:stats':
##
## filter
##Summary statistics
summ<-datos %>%
group_by(curva, gen, dia) %>%
get_summary_stats(cd.grano.d, type = "mean_sd")
summ %>% as_tibble() %>% print(n=Inf)
## # A tibble: 36 × 7
## curva gen dia variable n mean sd
## <fct> <fct> <fct> <chr> <dbl> <dbl> <dbl>
## 1 P3 CCN51 0 cd.grano.d 3 8.59 0.933
## 2 P3 CCN51 2 cd.grano.d 3 8.40 0.262
## 3 P3 CCN51 5 cd.grano.d 3 7.49 0.181
## 4 P3 CCN51 6 cd.grano.d 3 7.67 0.413
## 5 P3 ICS95 0 cd.grano.d 3 11.4 0.529
## 6 P3 ICS95 2 cd.grano.d 3 11.3 0.947
## 7 P3 ICS95 5 cd.grano.d 3 11.3 0.881
## 8 P3 ICS95 6 cd.grano.d 3 10.3 0.739
## 9 P3 TCS01 0 cd.grano.d 3 8.91 2.42
## 10 P3 TCS01 2 cd.grano.d 3 7.98 0.831
## 11 P3 TCS01 5 cd.grano.d 3 7.78 0.921
## 12 P3 TCS01 6 cd.grano.d 3 8.36 1.05
## 13 P1 CCN51 0 cd.grano.d 3 8.38 0.997
## 14 P1 CCN51 2 cd.grano.d 3 9.20 0.745
## 15 P1 CCN51 5 cd.grano.d 3 7.99 0.99
## 16 P1 CCN51 6 cd.grano.d 3 7.98 0.419
## 17 P1 ICS95 0 cd.grano.d 3 9.02 1.13
## 18 P1 ICS95 2 cd.grano.d 3 9.43 0.558
## 19 P1 ICS95 5 cd.grano.d 3 9.63 1.36
## 20 P1 ICS95 6 cd.grano.d 3 9.63 0.824
## 21 P1 TCS01 0 cd.grano.d 3 6.76 0.146
## 22 P1 TCS01 2 cd.grano.d 3 7.47 1.74
## 23 P1 TCS01 5 cd.grano.d 3 6.73 0.496
## 24 P1 TCS01 6 cd.grano.d 3 6.78 0.429
## 25 P2 CCN51 0 cd.grano.d 3 6.52 1.10
## 26 P2 CCN51 2 cd.grano.d 3 5.97 1.10
## 27 P2 CCN51 5 cd.grano.d 3 6.42 0.185
## 28 P2 CCN51 6 cd.grano.d 3 7.15 0.314
## 29 P2 ICS95 0 cd.grano.d 3 11.0 1.27
## 30 P2 ICS95 2 cd.grano.d 3 11.6 0.313
## 31 P2 ICS95 5 cd.grano.d 3 11.7 0.381
## 32 P2 ICS95 6 cd.grano.d 3 10.8 0.495
## 33 P2 TCS01 0 cd.grano.d 3 8.23 0.516
## 34 P2 TCS01 2 cd.grano.d 3 6.69 0.393
## 35 P2 TCS01 5 cd.grano.d 3 8.85 0.394
## 36 P2 TCS01 6 cd.grano.d 3 8.21 0.16
##Visualization
bxp <- ggboxplot(
datos, x = "curva", y = "cd.grano.d",
color = "dia", palette = "jco",
facet.by = "gen"
)
bxp

##Check assumptions
##Outliers
datos %>%
group_by(curva, gen, dia) %>%
identify_outliers(cd.grano.d)
## [1] curva gen dia muestra id cd.grano
## [7] curva.1 protocolo gen.1 muestra.1 dia.1 Testa
## [13] Grano cd.grano.c cd.grano.a cd.grano.d X is.outlier
## [19] is.extreme
## <0 rows> (or 0-length row.names)
##Normality assumption
##Compute Shapiro-Wilk test for each combinations of factor levels:
norm<-datos %>%
group_by(curva, gen, dia) %>%
shapiro_test(cd.grano.d)
norm %>% as_tibble() %>% print(n=Inf)
## # A tibble: 36 × 6
## curva gen dia variable statistic p
## <fct> <fct> <fct> <chr> <dbl> <dbl>
## 1 P3 CCN51 0 cd.grano.d 0.812 0.143
## 2 P3 CCN51 2 cd.grano.d 0.841 0.216
## 3 P3 CCN51 5 cd.grano.d 0.803 0.122
## 4 P3 CCN51 6 cd.grano.d 0.927 0.477
## 5 P3 ICS95 0 cd.grano.d 0.828 0.183
## 6 P3 ICS95 2 cd.grano.d 0.999 0.927
## 7 P3 ICS95 5 cd.grano.d 0.867 0.286
## 8 P3 ICS95 6 cd.grano.d 0.982 0.740
## 9 P3 TCS01 0 cd.grano.d 0.979 0.720
## 10 P3 TCS01 2 cd.grano.d 0.798 0.109
## 11 P3 TCS01 5 cd.grano.d 0.824 0.172
## 12 P3 TCS01 6 cd.grano.d 0.979 0.725
## 13 P1 CCN51 0 cd.grano.d 0.852 0.246
## 14 P1 CCN51 2 cd.grano.d 0.986 0.770
## 15 P1 CCN51 5 cd.grano.d 0.906 0.403
## 16 P1 CCN51 6 cd.grano.d 0.942 0.536
## 17 P1 ICS95 0 cd.grano.d 0.952 0.576
## 18 P1 ICS95 2 cd.grano.d 0.974 0.689
## 19 P1 ICS95 5 cd.grano.d 0.973 0.685
## 20 P1 ICS95 6 cd.grano.d 0.828 0.182
## 21 P1 TCS01 0 cd.grano.d 0.998 0.913
## 22 P1 TCS01 2 cd.grano.d 0.944 0.543
## 23 P1 TCS01 5 cd.grano.d 0.989 0.799
## 24 P1 TCS01 6 cd.grano.d 0.815 0.151
## 25 P2 CCN51 0 cd.grano.d 0.814 0.149
## 26 P2 CCN51 2 cd.grano.d 1.00 0.972
## 27 P2 CCN51 5 cd.grano.d 0.917 0.442
## 28 P2 CCN51 6 cd.grano.d 0.976 0.702
## 29 P2 ICS95 0 cd.grano.d 0.880 0.325
## 30 P2 ICS95 2 cd.grano.d 0.975 0.696
## 31 P2 ICS95 5 cd.grano.d 0.971 0.674
## 32 P2 ICS95 6 cd.grano.d 0.809 0.135
## 33 P2 TCS01 0 cd.grano.d 0.992 0.827
## 34 P2 TCS01 2 cd.grano.d 1.00 0.986
## 35 P2 TCS01 5 cd.grano.d 0.994 0.854
## 36 P2 TCS01 6 cd.grano.d 0.888 0.349
##Create QQ plot for each cell of design:
ggqqplot(datos, "cd.grano.d", ggtheme = theme_bw()) +
facet_grid(dia~ curva*gen, labeller = "label_both")

##Homogneity of variance assumption
##Compute the Levene’s test at each level of the within-subjects factor, here time variable:
lev<-datos %>%
group_by(dia) %>%
levene_test(cd.grano.d ~ curva*gen)
lev %>% as_tibble() %>% print(n=Inf)
## # A tibble: 4 × 5
## dia df1 df2 statistic p
## <fct> <int> <int> <dbl> <dbl>
## 1 0 8 18 0.726 0.667
## 2 2 8 18 0.769 0.634
## 3 5 8 18 0.671 0.710
## 4 6 8 18 0.509 0.834
##Computation
res.aov <- anova_test(
data = datos, dv = cd.grano.d, wid = id,
within = dia, between = c(curva, gen)
)
get_anova_table(res.aov)
## ANOVA Table (type II tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 curva 2.00 18.00 6.117 9.00e-03 * 0.202
## 2 gen 2.00 18.00 88.422 4.90e-10 * 0.785
## 3 dia 2.22 40.01 0.357 7.24e-01 0.012
## 4 curva:gen 4.00 18.00 10.113 1.80e-04 * 0.455
## 5 curva:dia 4.45 40.01 2.554 4.80e-02 * 0.151
## 6 gen:dia 4.45 40.01 1.298 2.86e-01 0.083
## 7 curva:gen:dia 8.89 40.01 1.037 4.28e-01 0.127
##Splitting dataframe by temperature ramp
## Protocol 3 (P3)
datos.curve1<-filter(datos, curva=="P3")
##Check assumptions
##Outliers
datos.curve1 %>%
group_by(gen, dia) %>%
identify_outliers(cd.grano.d)
## [1] gen dia curva muestra id cd.grano
## [7] curva.1 protocolo gen.1 muestra.1 dia.1 Testa
## [13] Grano cd.grano.c cd.grano.a cd.grano.d X is.outlier
## [19] is.extreme
## <0 rows> (or 0-length row.names)
##Normality assumption
##Compute Shapiro-Wilk test for each combinations of factor levels:
norm1<-datos.curve1 %>%
group_by(gen, dia) %>%
shapiro_test(cd.grano.d)
norm1 %>% as_tibble() %>% print(n=Inf)
## # A tibble: 12 × 5
## gen dia variable statistic p
## <fct> <fct> <chr> <dbl> <dbl>
## 1 CCN51 0 cd.grano.d 0.812 0.143
## 2 CCN51 2 cd.grano.d 0.841 0.216
## 3 CCN51 5 cd.grano.d 0.803 0.122
## 4 CCN51 6 cd.grano.d 0.927 0.477
## 5 ICS95 0 cd.grano.d 0.828 0.183
## 6 ICS95 2 cd.grano.d 0.999 0.927
## 7 ICS95 5 cd.grano.d 0.867 0.286
## 8 ICS95 6 cd.grano.d 0.982 0.740
## 9 TCS01 0 cd.grano.d 0.979 0.720
## 10 TCS01 2 cd.grano.d 0.798 0.109
## 11 TCS01 5 cd.grano.d 0.824 0.172
## 12 TCS01 6 cd.grano.d 0.979 0.725
##Create QQ plot for each cell of design:
ggqqplot(datos.curve1, "cd.grano.d", ggtheme = theme_bw()) +
facet_grid(dia~ curva*gen, labeller = "label_both")

##Homogneity of variance assumption
##Compute the Levene’s test at each level of the within-subjects factor, here time variable:
lev1<-datos.curve1 %>%
group_by(dia) %>%
levene_test(cd.grano.d ~ gen)
lev1 %>% as_tibble() %>% print(n=Inf)
## # A tibble: 4 × 5
## dia df1 df2 statistic p
## <fct> <int> <int> <dbl> <dbl>
## 1 0 2 6 1.28 0.344
## 2 2 2 6 0.553 0.602
## 3 5 2 6 0.476 0.643
## 4 6 2 6 0.568 0.595
##Computation
res.aov1 <- anova_test(
data = datos.curve1, dv = cd.grano.d, wid = id,
within = dia, between = gen
)
get_anova_table(res.aov1)
## ANOVA Table (type II tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 gen 2 6 27.237 0.000977 * 0.739
## 2 dia 3 18 1.520 0.243000 0.148
## 3 gen:dia 6 18 0.573 0.747000 0.116
#CCN51
datos.ccn<-filter(datos.curve1, gen=="CCN51")
res.aov.ccn1 <- anova_test(
data = datos.ccn, dv = cd.grano.d, wid = id,
within = dia
)
get_anova_table(res.aov.ccn1)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 dia 3 6 3.253 0.102 0.532
#ICS95
datos.ics<-filter(datos.curve1, gen=="ICS95")
res.aov.ics1 <- anova_test(
data = datos.ics, dv = cd.grano.d, wid = id,
within = dia
)
get_anova_table(res.aov.ics1)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 dia 3 6 2.245 0.184 0.341
#TCS01
datos.tcs<-filter(datos.curve1, gen=="TCS01")
res.aov.tcs1 <- anova_test(
data = datos.tcs, dv = cd.grano.d, wid = id,
within = dia
)
get_anova_table(res.aov.tcs1)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 dia 3 6 0.351 0.79 0.117
## Protocol 1 (P1)
datos.curve2<-filter(datos, curva=="P1")
##Check assumptions
##Outliers
datos.curve2 %>%
group_by(gen, dia) %>%
identify_outliers(cd.grano.d)
## [1] gen dia curva muestra id cd.grano
## [7] curva.1 protocolo gen.1 muestra.1 dia.1 Testa
## [13] Grano cd.grano.c cd.grano.a cd.grano.d X is.outlier
## [19] is.extreme
## <0 rows> (or 0-length row.names)
##Normality assumption
##Compute Shapiro-Wilk test for each combinations of factor levels:
norm2<-datos.curve2 %>%
group_by(gen, dia) %>%
shapiro_test(cd.grano.d)
norm2 %>% as_tibble() %>% print(n=Inf)
## # A tibble: 12 × 5
## gen dia variable statistic p
## <fct> <fct> <chr> <dbl> <dbl>
## 1 CCN51 0 cd.grano.d 0.852 0.246
## 2 CCN51 2 cd.grano.d 0.986 0.770
## 3 CCN51 5 cd.grano.d 0.906 0.403
## 4 CCN51 6 cd.grano.d 0.942 0.536
## 5 ICS95 0 cd.grano.d 0.952 0.576
## 6 ICS95 2 cd.grano.d 0.974 0.689
## 7 ICS95 5 cd.grano.d 0.973 0.685
## 8 ICS95 6 cd.grano.d 0.828 0.182
## 9 TCS01 0 cd.grano.d 0.998 0.913
## 10 TCS01 2 cd.grano.d 0.944 0.543
## 11 TCS01 5 cd.grano.d 0.989 0.799
## 12 TCS01 6 cd.grano.d 0.815 0.151
##Create QQ plot for each cell of design:
ggqqplot(datos.curve2, "cd.grano.d", ggtheme = theme_bw()) +
facet_grid(dia~ curva*gen, labeller = "label_both")

##Homogneity of variance assumption
##Compute the Levene’s test at each level of the within-subjects factor, here time variable:
lev2<-datos.curve2 %>%
group_by(dia) %>%
levene_test(cd.grano.d ~ gen)
lev2 %>% as_tibble() %>% print(n=Inf)
## # A tibble: 4 × 5
## dia df1 df2 statistic p
## <fct> <int> <int> <dbl> <dbl>
## 1 0 2 6 0.779 0.500
## 2 2 2 6 0.829 0.481
## 3 5 2 6 0.514 0.622
## 4 6 2 6 0.214 0.813
##Computation
res.aov2 <- anova_test(
data = datos.curve2, dv = cd.grano.d, wid = id,
within = dia, between = gen
)
get_anova_table(res.aov2)
## ANOVA Table (type II tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 gen 2.00 6.00 11.200 0.009 * 0.646
## 2 dia 1.48 8.91 1.401 0.285 0.107
## 3 gen:dia 2.97 8.91 0.675 0.587 0.103
#CCN51
datos.ccn<-filter(datos.curve2, gen=="CCN51")
res.aov.ccn2 <- anova_test(
data = datos.ccn, dv = cd.grano.d, wid = id,
within = dia
)
get_anova_table(res.aov.ccn2)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 dia 3 6 1.585 0.288 0.351
#ICS95
datos.ics<-filter(datos.curve2, gen=="ICS95")
res.aov.ics2 <- anova_test(
data = datos.ics, dv = cd.grano.d, wid = id,
within = dia
)
get_anova_table(res.aov.ics2)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 dia 3 6 0.699 0.586 0.083
#TCS01
datos.tcs<-filter(datos.curve2, gen=="TCS01")
res.aov.tcs2 <- anova_test(
data = datos.tcs, dv = cd.grano.d, wid = id,
within = dia
)
get_anova_table(res.aov.tcs2)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 dia 3 6 0.491 0.701 0.143
## Protocol 2 (P2)
datos.curve3<-filter(datos, curva=="P2")
##Check assumptions
##Outliers
datos.curve3 %>%
group_by(gen, dia) %>%
identify_outliers(cd.grano.d)
## [1] gen dia curva muestra id cd.grano
## [7] curva.1 protocolo gen.1 muestra.1 dia.1 Testa
## [13] Grano cd.grano.c cd.grano.a cd.grano.d X is.outlier
## [19] is.extreme
## <0 rows> (or 0-length row.names)
##Normality assumption
##Compute Shapiro-Wilk test for each combinations of factor levels:
norm2<-datos.curve3 %>%
group_by(gen, dia) %>%
shapiro_test(cd.grano.d)
norm2 %>% as_tibble() %>% print(n=Inf)
## # A tibble: 12 × 5
## gen dia variable statistic p
## <fct> <fct> <chr> <dbl> <dbl>
## 1 CCN51 0 cd.grano.d 0.814 0.149
## 2 CCN51 2 cd.grano.d 1.00 0.972
## 3 CCN51 5 cd.grano.d 0.917 0.442
## 4 CCN51 6 cd.grano.d 0.976 0.702
## 5 ICS95 0 cd.grano.d 0.880 0.325
## 6 ICS95 2 cd.grano.d 0.975 0.696
## 7 ICS95 5 cd.grano.d 0.971 0.674
## 8 ICS95 6 cd.grano.d 0.809 0.135
## 9 TCS01 0 cd.grano.d 0.992 0.827
## 10 TCS01 2 cd.grano.d 1.00 0.986
## 11 TCS01 5 cd.grano.d 0.994 0.854
## 12 TCS01 6 cd.grano.d 0.888 0.349
##Create QQ plot for each cell of design:
ggqqplot(datos.curve3, "cd.grano.d", ggtheme = theme_bw()) +
facet_grid(dia~ curva*gen, labeller = "label_both")

##Homogneity of variance assumption
##Compute the Levene’s test at each level of the within-subjects factor, here time variable:
lev2<-datos.curve3 %>%
group_by(dia) %>%
levene_test(cd.grano.d ~ gen)
lev2 %>% as_tibble() %>% print(n=Inf)
## # A tibble: 4 × 5
## dia df1 df2 statistic p
## <fct> <int> <int> <dbl> <dbl>
## 1 0 2 6 0.226 0.804
## 2 2 2 6 1.52 0.292
## 3 5 2 6 0.431 0.668
## 4 6 2 6 0.332 0.730
##Computation
res.aov2 <- anova_test(
data = datos.curve3, dv = cd.grano.d, wid = id,
within = dia, between = gen
)
get_anova_table(res.aov2)
## ANOVA Table (type II tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 gen 2.00 6.00 145.128 8.31e-06 * 0.931
## 2 dia 1.64 9.82 3.075 9.80e-02 0.270
## 3 gen:dia 3.27 9.82 2.966 8.20e-02 0.416
#CCN51
datos.ccn<-filter(datos.curve3, gen=="CCN51")
res.aov.ccn2 <- anova_test(
data = datos.ccn, dv = cd.grano.d, wid = id,
within = dia
)
get_anova_table(res.aov.ccn2)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 dia 3 6 1.393 0.333 0.295
#ICS95
datos.ics<-filter(datos.curve3, gen=="ICS95")
res.aov.ics2 <- anova_test(
data = datos.ics, dv = cd.grano.d, wid = id,
within = dia
)
get_anova_table(res.aov.ics2)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 dia 3 6 0.775 0.549 0.278
#TCS01
datos.tcs<-filter(datos.curve3, gen=="TCS01")
res.aov.tcs2 <- anova_test(
data = datos.tcs, dv = cd.grano.d, wid = id,
within = dia
)
get_anova_table(res.aov.tcs2)
## ANOVA Table (type III tests)
##
## Effect DFn DFd F p p<.05 ges
## 1 dia 3 6 46.383 0.000152 * 0.863
## Gráficas por réplica y genotipo
datos$dia<-as.numeric(as.character(datos$dia))
##Gráfica por réplica compuesta
pht<- ggplot(datos, aes(x = dia)) +
facet_grid(curva~gen*muestra) +
geom_line(aes(y=cd.grano.d)) +
geom_point(aes(y=cd.grano.d)) +
scale_y_continuous(name = expression("Cd (mg*Kg"^"-1)")) + # Etiqueta de la variable continua
scale_x_continuous(name = "dÃa", breaks=seq(0,7,1)) + # Etiqueta de los grupos
theme(axis.line = element_line(colour = "black", # Personalización del tema
size = 0.25)) +
theme(text = element_text(size = 12))
pht

## Gráfica por genotipo
datos2<-summarySE (datos, measurevar = "cd.grano.d", groupvars = c("curva", "gen","dia"))
write.csv(datos2, "~/Library/CloudStorage/GoogleDrive-icarounam@gmail.com/Mi unidad/Agrosavia/Env_muestra/data/datos_mean_grano.csv")
pht2<- ggplot(datos2, aes(x = dia)) +
facet_grid(curva~gen) +
geom_errorbar(aes(ymin=cd.grano.d-ci, ymax=cd.grano.d+ci), width=.1) +
geom_line(aes(y=cd.grano.d)) +
geom_point(aes(y=cd.grano.d)) +
scale_y_continuous(name = expression("Cd (mg*Kg"^"-1)")) + # Etiqueta de la variable continua
scale_x_continuous(name = "dÃa", breaks=seq(0,7,1)) + # Etiqueta de los grupos
theme(axis.line = element_line(colour = "black", # Personalización del tema
size = 0.25)) +
theme(text = element_text(size = 15))
pht2
