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.a, 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.a 3 8.68 0.855
## 2 P3 CCN51 2 cd.grano.a 3 8.40 0.262
## 3 P3 CCN51 5 cd.grano.a 3 7.49 0.181
## 4 P3 CCN51 6 cd.grano.a 3 7.60 0.286
## 5 P3 ICS95 0 cd.grano.a 3 11.8 0.556
## 6 P3 ICS95 2 cd.grano.a 3 11.4 0.767
## 7 P3 ICS95 5 cd.grano.a 3 10.9 0.435
## 8 P3 ICS95 6 cd.grano.a 3 10.2 0.703
## 9 P3 TCS01 0 cd.grano.a 3 9.03 2.35
## 10 P3 TCS01 2 cd.grano.a 3 7.85 0.757
## 11 P3 TCS01 5 cd.grano.a 3 7.75 0.903
## 12 P3 TCS01 6 cd.grano.a 3 8.18 0.961
## 13 P1 CCN51 0 cd.grano.a 3 8.50 0.901
## 14 P1 CCN51 2 cd.grano.a 3 9.09 0.593
## 15 P1 CCN51 5 cd.grano.a 3 7.98 0.967
## 16 P1 CCN51 6 cd.grano.a 3 7.89 0.378
## 17 P1 ICS95 0 cd.grano.a 3 9.17 1.05
## 18 P1 ICS95 2 cd.grano.a 3 9.36 0.616
## 19 P1 ICS95 5 cd.grano.a 3 9.46 1.27
## 20 P1 ICS95 6 cd.grano.a 3 9.49 0.801
## 21 P1 TCS01 0 cd.grano.a 3 6.88 0.291
## 22 P1 TCS01 2 cd.grano.a 3 7.36 1.65
## 23 P1 TCS01 5 cd.grano.a 3 6.59 0.595
## 24 P1 TCS01 6 cd.grano.a 3 6.67 0.432
## 25 P2 CCN51 0 cd.grano.a 3 6.88 0.779
## 26 P2 CCN51 2 cd.grano.a 3 5.71 0.742
## 27 P2 CCN51 5 cd.grano.a 3 5.75 0.184
## 28 P2 CCN51 6 cd.grano.a 3 6.26 0.109
## 29 P2 ICS95 0 cd.grano.a 3 11.9 0.555
## 30 P2 ICS95 2 cd.grano.a 3 11.2 0.519
## 31 P2 ICS95 5 cd.grano.a 3 11.1 0.529
## 32 P2 ICS95 6 cd.grano.a 3 10.4 0.156
## 33 P2 TCS01 0 cd.grano.a 3 8.88 0.554
## 34 P2 TCS01 2 cd.grano.a 3 6.69 0.393
## 35 P2 TCS01 5 cd.grano.a 3 8.11 0.368
## 36 P2 TCS01 6 cd.grano.a 3 7.28 0.297
##Visualization
bxp <- ggboxplot(
datos, x = "curva", y = "cd.grano.a",
color = "dia", palette = "jco",
facet.by = "gen"
)
bxp

##Check assumptions
##Outliers
datos %>%
group_by(curva, gen, dia) %>%
identify_outliers(cd.grano.a)
## [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.a)
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.a 0.849 0.237
## 2 P3 CCN51 2 cd.grano.a 0.841 0.216
## 3 P3 CCN51 5 cd.grano.a 0.803 0.122
## 4 P3 CCN51 6 cd.grano.a 0.975 0.698
## 5 P3 ICS95 0 cd.grano.a 1.00 0.972
## 6 P3 ICS95 2 cd.grano.a 0.992 0.827
## 7 P3 ICS95 5 cd.grano.a 0.755 0.0110
## 8 P3 ICS95 6 cd.grano.a 0.969 0.663
## 9 P3 TCS01 0 cd.grano.a 0.988 0.787
## 10 P3 TCS01 2 cd.grano.a 0.960 0.617
## 11 P3 TCS01 5 cd.grano.a 0.856 0.256
## 12 P3 TCS01 6 cd.grano.a 0.930 0.487
## 13 P1 CCN51 0 cd.grano.a 0.899 0.382
## 14 P1 CCN51 2 cd.grano.a 0.999 0.940
## 15 P1 CCN51 5 cd.grano.a 0.908 0.413
## 16 P1 CCN51 6 cd.grano.a 0.940 0.529
## 17 P1 ICS95 0 cd.grano.a 0.994 0.852
## 18 P1 ICS95 2 cd.grano.a 0.962 0.625
## 19 P1 ICS95 5 cd.grano.a 0.999 0.928
## 20 P1 ICS95 6 cd.grano.a 0.838 0.209
## 21 P1 TCS01 0 cd.grano.a 0.964 0.634
## 22 P1 TCS01 2 cd.grano.a 0.928 0.482
## 23 P1 TCS01 5 cd.grano.a 0.932 0.495
## 24 P1 TCS01 6 cd.grano.a 0.880 0.324
## 25 P2 CCN51 0 cd.grano.a 0.757 0.0159
## 26 P2 CCN51 2 cd.grano.a 0.922 0.460
## 27 P2 CCN51 5 cd.grano.a 0.975 0.700
## 28 P2 CCN51 6 cd.grano.a 0.989 0.803
## 29 P2 ICS95 0 cd.grano.a 0.972 0.682
## 30 P2 ICS95 2 cd.grano.a 0.971 0.671
## 31 P2 ICS95 5 cd.grano.a 0.860 0.268
## 32 P2 ICS95 6 cd.grano.a 0.974 0.690
## 33 P2 TCS01 0 cd.grano.a 0.880 0.324
## 34 P2 TCS01 2 cd.grano.a 1.00 0.986
## 35 P2 TCS01 5 cd.grano.a 0.997 0.892
## 36 P2 TCS01 6 cd.grano.a 0.988 0.794
##Create QQ plot for each cell of design:
ggqqplot(datos, "cd.grano.a", 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.a ~ 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.960 0.496
## 2 2 8 18 0.649 0.728
## 3 5 8 18 0.702 0.686
## 4 6 8 18 0.653 0.724
##Computation
res.aov <- anova_test(
data = datos, dv = cd.grano.a, 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 8.793 2.00e-03 * 0.281
## 2 gen 2.00 18.00 106.935 1.02e-10 * 0.826
## 3 dia 2.27 40.85 7.757 9.18e-04 * 0.206
## 4 curva:gen 4.00 18.00 13.203 3.42e-05 * 0.539
## 5 curva:dia 4.54 40.85 2.914 2.80e-02 * 0.163
## 6 gen:dia 4.54 40.85 0.955 4.50e-01 0.060
## 7 curva:gen:dia 9.08 40.85 0.932 5.09e-01 0.111
##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.a)
## [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.a)
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.a 0.849 0.237
## 2 CCN51 2 cd.grano.a 0.841 0.216
## 3 CCN51 5 cd.grano.a 0.803 0.122
## 4 CCN51 6 cd.grano.a 0.975 0.698
## 5 ICS95 0 cd.grano.a 1.00 0.972
## 6 ICS95 2 cd.grano.a 0.992 0.827
## 7 ICS95 5 cd.grano.a 0.755 0.0110
## 8 ICS95 6 cd.grano.a 0.969 0.663
## 9 TCS01 0 cd.grano.a 0.988 0.787
## 10 TCS01 2 cd.grano.a 0.960 0.617
## 11 TCS01 5 cd.grano.a 0.856 0.256
## 12 TCS01 6 cd.grano.a 0.930 0.487
##Create QQ plot for each cell of design:
ggqqplot(datos.curve1, "cd.grano.a", 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.a ~ 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.40 0.317
## 2 2 2 6 0.686 0.539
## 3 5 2 6 0.591 0.583
## 4 6 2 6 0.592 0.583
##Computation
res.aov1 <- anova_test(
data = datos.curve1, dv = cd.grano.a, 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 29.648 0.000776 * 0.775
## 2 dia 3 18 3.583 0.034000 * 0.280
## 3 gen:dia 6 18 0.516 0.789000 0.101
#CCN51
datos.ccn<-filter(datos.curve1, gen=="CCN51")
res.aov.ccn1 <- anova_test(
data = datos.ccn, dv = cd.grano.a, 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 5.222 0.041 * 0.63
#ICS95
datos.ics<-filter(datos.curve1, gen=="ICS95")
res.aov.ics1 <- anova_test(
data = datos.ics, dv = cd.grano.a, 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 5.046 0.044 * 0.567
#TCS01
datos.tcs<-filter(datos.curve1, gen=="TCS01")
res.aov.tcs1 <- anova_test(
data = datos.tcs, dv = cd.grano.a, 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.579 0.65 0.164
## Protocol 1 (P1)
datos.curve2<-filter(datos, curva=="P1")
##Check assumptions
##Outliers
datos.curve2 %>%
group_by(gen, dia) %>%
identify_outliers(cd.grano.a)
## [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.a)
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.a 0.899 0.382
## 2 CCN51 2 cd.grano.a 0.999 0.940
## 3 CCN51 5 cd.grano.a 0.908 0.413
## 4 CCN51 6 cd.grano.a 0.940 0.529
## 5 ICS95 0 cd.grano.a 0.994 0.852
## 6 ICS95 2 cd.grano.a 0.962 0.625
## 7 ICS95 5 cd.grano.a 0.999 0.928
## 8 ICS95 6 cd.grano.a 0.838 0.209
## 9 TCS01 0 cd.grano.a 0.964 0.634
## 10 TCS01 2 cd.grano.a 0.928 0.482
## 11 TCS01 5 cd.grano.a 0.932 0.495
## 12 TCS01 6 cd.grano.a 0.880 0.324
##Create QQ plot for each cell of design:
ggqqplot(datos.curve2, "cd.grano.a", 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.a ~ 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.686 0.539
## 2 2 2 6 0.768 0.505
## 3 5 2 6 0.385 0.696
## 4 6 2 6 0.237 0.796
##Computation
res.aov2 <- anova_test(
data = datos.curve2, dv = cd.grano.a, 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 12.581 0.007 * 0.669
## 2 dia 1.54 9.26 1.292 0.308 0.100
## 3 gen:dia 3.09 9.26 0.602 0.634 0.094
#CCN51
datos.ccn<-filter(datos.curve2, gen=="CCN51")
res.aov.ccn2 <- anova_test(
data = datos.ccn, dv = cd.grano.a, 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.822 0.243 0.381
#ICS95
datos.ics<-filter(datos.curve2, gen=="ICS95")
res.aov.ics2 <- anova_test(
data = datos.ics, dv = cd.grano.a, 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.23 0.872 0.025
#TCS01
datos.tcs<-filter(datos.curve2, gen=="TCS01")
res.aov.tcs2 <- anova_test(
data = datos.tcs, dv = cd.grano.a, 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.432 0.738 0.137
## Protocol 2 (P2)
datos.curve3<-filter(datos, curva=="P2")
##Check assumptions
##Outliers
datos.curve3 %>%
group_by(gen, dia) %>%
identify_outliers(cd.grano.a)
## [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.a)
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.a 0.757 0.0159
## 2 CCN51 2 cd.grano.a 0.922 0.460
## 3 CCN51 5 cd.grano.a 0.975 0.700
## 4 CCN51 6 cd.grano.a 0.989 0.803
## 5 ICS95 0 cd.grano.a 0.972 0.682
## 6 ICS95 2 cd.grano.a 0.971 0.671
## 7 ICS95 5 cd.grano.a 0.860 0.268
## 8 ICS95 6 cd.grano.a 0.974 0.690
## 9 TCS01 0 cd.grano.a 0.880 0.324
## 10 TCS01 2 cd.grano.a 1.00 0.986
## 11 TCS01 5 cd.grano.a 0.997 0.892
## 12 TCS01 6 cd.grano.a 0.988 0.794
##Create QQ plot for each cell of design:
ggqqplot(datos.curve3, "cd.grano.a", 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.a ~ 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.0309 0.970
## 2 2 2 6 0.227 0.803
## 3 5 2 6 0.375 0.702
## 4 6 2 6 0.824 0.483
##Computation
res.aov2 <- anova_test(
data = datos.curve3, dv = cd.grano.a, 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 6 279.943 1.19e-06 * 0.966
## 2 dia 3 18 15.900 2.66e-05 * 0.649
## 3 gen:dia 6 18 3.259 2.40e-02 * 0.431
#CCN51
datos.ccn<-filter(datos.curve3, gen=="CCN51")
res.aov.ccn2 <- anova_test(
data = datos.ccn, dv = cd.grano.a, 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 3.73 0.08 0.528
#ICS95
datos.ics<-filter(datos.curve3, gen=="ICS95")
res.aov.ics2 <- anova_test(
data = datos.ics, dv = cd.grano.a, 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 4.504 0.056 0.662
#TCS01
datos.tcs<-filter(datos.curve3, gen=="TCS01")
res.aov.tcs2 <- anova_test(
data = datos.tcs, dv = cd.grano.a, 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 18.621 0.002 * 0.858
## 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.a)) +
geom_point(aes(y=cd.grano.a)) +
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.a", 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.a-ci, ymax=cd.grano.a+ci), width=.1) +
geom_line(aes(y=cd.grano.a)) +
geom_point(aes(y=cd.grano.a)) +
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
