R Markdown

library(rpart)
library(rpart.plot)
## Warning: package 'rpart.plot' was built under R version 4.0.3
library(rattle)
## Warning: package 'rattle' was built under R version 4.0.3
## Loading required package: tibble
## Loading required package: bitops
## Rattle: A free graphical interface for data science with R.
## Version 5.4.0 Copyright (c) 2006-2020 Togaware Pty Ltd.
## Type 'rattle()' to shake, rattle, and roll your data.
library(gganimate)
## Warning: package 'gganimate' was built under R version 4.0.3
## Loading required package: ggplot2
library(av)
## Warning: package 'av' was built under R version 4.0.3
library(cluster)
library(dendextend)
## Warning: package 'dendextend' was built under R version 4.0.3
## 
## ---------------------
## Welcome to dendextend version 1.14.0
## Type citation('dendextend') for how to cite the package.
## 
## Type browseVignettes(package = 'dendextend') for the package vignette.
## The github page is: https://github.com/talgalili/dendextend/
## 
## Suggestions and bug-reports can be submitted at: https://github.com/talgalili/dendextend/issues
## Or contact: <tal.galili@gmail.com>
## 
##  To suppress this message use:  suppressPackageStartupMessages(library(dendextend))
## ---------------------
## 
## Attaching package: 'dendextend'
## The following object is masked from 'package:rpart':
## 
##     prune
## The following object is masked from 'package:stats':
## 
##     cutree
library(factoextra) 
## Warning: package 'factoextra' was built under R version 4.0.3
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
library(gridExtra)
library(sjPlot)
## Warning: package 'sjPlot' was built under R version 4.0.3
## Registered S3 method overwritten by 'parameters':
##   method         from  
##   predict.kmeans rattle
library(FactoMineR)
## Warning: package 'FactoMineR' was built under R version 4.0.3
library(tidyverse)
## -- Attaching packages --------------------------------------------------- tidyverse 1.3.0 --
## v tidyr   1.1.1     v dplyr   1.0.2
## v readr   1.3.1     v stringr 1.4.0
## v purrr   0.3.4     v forcats 0.5.0
## -- Conflicts ------------------------------------------------------ tidyverse_conflicts() --
## x dplyr::combine() masks gridExtra::combine()
## x dplyr::filter()  masks stats::filter()
## x dplyr::lag()     masks stats::lag()
library(ggrepel)
library(kableExtra)
## Warning: package 'kableExtra' was built under R version 4.0.3
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
library(knitr)
library(cluster)
library(factoextra)
library(PerformanceAnalytics)
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
## 
##     legend
library(psych)
## Warning: package 'psych' was built under R version 4.0.3
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
library(amap)
## Warning: package 'amap' was built under R version 4.0.3
## 
## Attaching package: 'amap'
## The following object is masked from 'package:psych':
## 
##     pca
library(ade4)
## Warning: package 'ade4' was built under R version 4.0.3
## 
## Attaching package: 'ade4'
## The following object is masked from 'package:FactoMineR':
## 
##     reconst
library(fastDummies)
## Warning: package 'fastDummies' was built under R version 4.0.3
library(nnet)
library(kableExtra)
library(jtools)
library(fastDummies)
library(dplyr)
library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(tidyverse)
library(ggrepel)
library(esquisse)
library(ggplot2)
library(gridExtra)
library(outliers)
## 
## Attaching package: 'outliers'
## The following object is masked from 'package:psych':
## 
##     outlier
library(readxl)
library(agricolae)
## 
## Attaching package: 'agricolae'
## The following objects are masked from 'package:PerformanceAnalytics':
## 
##     kurtosis, skewness
## The following object is masked from 'package:factoextra':
## 
##     hcut
dt <- read_excel("C:/Users/Alex/Desktop/Angelica/exp.xlsx", 
                 sheet = "sclerotinia")
attach(dt)
head(dt)
## # A tibble: 6 x 6
##   VETOR TRAT    BLOCO  numplantasmortas mortes  asen
##   <chr> <chr>   <chr>             <dbl>  <dbl> <dbl>
## 1 MT    inoc    BLOCO1                1     20 0.464
## 2 VAZIO inoc    BLOCO1                4     80 1.11 
## 3 VF    inoc    BLOCO1                1     20 0.464
## 4 VF.1  inoc    BLOCO1                5    100 1.57 
## 5 VG    inoc    BLOCO1                1     20 0.464
## 6 MT    seminoc BLOCO1                0      0 0
#2. ANOVA e normalidade Peso pupa##############
summary(aov(asen ~ VETOR*TRAT, data = dt))
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## VETOR        4  1.434   0.358   6.556 0.000647 ***
## TRAT         1  3.319   3.319  60.710 1.08e-08 ***
## VETOR:TRAT   4  1.434   0.358   6.556 0.000647 ***
## Residuals   30  1.640   0.055                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
shapt <-shapiro.test(unlist(aov(asen ~ VETOR*TRAT, data = dt)["residuals"])); print(shapt)
## 
##  Shapiro-Wilk normality test
## 
## data:  unlist(aov(asen ~ VETOR * TRAT, data = dt)["residuals"])
## W = 0.82237, p-value = 2.053e-05
my_residuals_asen<-unlist(aov(asen ~ VETOR*TRAT, data = dt)["residuals"])
hist(my_residuals_asen)

ks.test(my_residuals_asen, pnorm)$statistic
## Warning in ks.test(my_residuals_asen, pnorm): ties should not be present for the
## Kolmogorov-Smirnov test
##         D 
## 0.3538612
a<-as.factor(VETOR)
b<-as.factor(TRAT)
inter<-as.factor(a:b)
kruskal.test(asen ~ inter, data = dt)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  asen by inter
## Kruskal-Wallis chi-squared = 31.713, df = 9, p-value = 0.0002232
kruskal(asen, inter)["groups"]
## $groups
##                 asen groups
## VAZIO:inoc    37.500      a
## VF.1:inoc     33.500     ab
## MT:inoc       26.500     bc
## VG:inoc       25.375      c
## VF:inoc       17.125      d
## MT:seminoc    13.000      d
## VAZIO:seminoc 13.000      d
## VF.1:seminoc  13.000      d
## VF:seminoc    13.000      d
## VG:seminoc    13.000      d
my_mean<-LSD.test(aov(asen ~ inter, data = dt),
                      "inter", alpha = 0.05)["groups"]
datos<-as.data.frame(my_mean)
names(datos)<- c("trat", "mean")
datos2<-datos[1:5,]
datos2["vetores"]<-c("a", "b","c", "d", "e" )
attach(datos2)
vetores2<-factor(vetores, levels=c("c", "a", "e", "b", "d"))

dt <- read_excel("C:/Users/Alex/Desktop/Angelica/exp.xlsx", 
                 sheet = "mediassclero")
my_labels<- c("WT", "pCAMBIA2201", 
                              "Tc-PR1-f", "Tc-PR1-f.1","Tc-PR1-g")
attach(dt)
## The following object is masked from datos2:
## 
##     trat
ggplot(data=dt, aes(x=vetor, y=mmortes2, fill= trat )) +
  geom_bar(stat="identity", color ="black", position = "dodge")+
  geom_errorbar(data = dt, aes(ymin = mmortes2 , ymax = mmortes2 + errop),
                        width = 0.5,        position = position_dodge(width = .9))+
  labs(x = NULL, y = "Percentage of death plants (%)", fill = "Tratment",
       position = position_dodge(1), size=5)+
  scale_fill_manual(values=c("black", "white",position = "dodge"),
                    labels = c("Inoculated", "Mock") )+
  scale_x_discrete(labels=my_labels)+
  geom_text(data=dt, aes(x = vetor, y = mmortes2+errop +4, label = sigtest,
                         vjust=0, size=0), position = position_dodge(0.9), 
            size=5) +        
  theme_classic()

###########Figuras floração seca##########################

dt <- read_excel("C:/Users/Alex/Desktop/Angelica/exp.xlsx", 
                 sheet = "secaexp1")
attach(dt)
head(dt)
## # A tibble: 6 x 5
##   Vetor Planta    CC  Rept  dias
##   <chr>  <dbl> <dbl> <dbl> <dbl>
## 1 VF         1   100     3    11
## 2 MT         2    30     3    10
## 3 MT         3   100     2    13
## 4 VG         4   100     1    18
## 5 VG         5    60     2    19
## 6 VØ         6    30     4    17
summary(aov(dias~Vetor*CC, data=dt))
##             Df Sum Sq Mean Sq F value Pr(>F)  
## Vetor        3  238.9   79.62   2.691 0.0557 .
## CC           1    0.0    0.03   0.001 0.9759  
## Vetor:CC     3   93.2   31.05   1.050 0.3786  
## Residuals   52 1538.5   29.59                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
shapt <-shapiro.test(unlist(aov(dias ~ Vetor*CC, data = dt)["residuals"])); print(shapt)
## 
##  Shapiro-Wilk normality test
## 
## data:  unlist(aov(dias ~ Vetor * CC, data = dt)["residuals"])
## W = 0.97375, p-value = 0.2217
my_residuals_asen<-unlist(aov(dias ~ Vetor*CC, data = dt)["residuals"])
hist(my_residuals_asen)

ks.test(my_residuals_asen, pnorm)$statistic
## Warning in ks.test(my_residuals_asen, pnorm): ties should not be present for the
## Kolmogorov-Smirnov test
##         D 
## 0.4041489
a<-as.factor(Vetor)
b<-as.factor(CC)
inter<-as.factor(a:b)
kruskal.test(dias ~ inter, data = dt)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  dias by inter
## Kruskal-Wallis chi-squared = 11.389, df = 11, p-value = 0.4113
kruskal(dias, inter)["groups"]
## $groups
##        dias groups
## VG:100 41.2      a
## VG:60  40.7      a
## MT:30  39.0      a
## MT:60  38.6      a
## VØ:30  32.6      a
## MT:100 31.7      a
## VF:100 28.8      a
## VG:30  26.3      a
## VF:60  22.6      a
## VF:30  22.2      a
## VØ:100 22.0      a
## VØ:60  20.3      a
my_mean<-LSD.test(aov(dias ~ inter, data = dt),
                  "inter", alpha = 0.05)["groups"];print(my_mean)
## $groups
##        dias groups
## VG:100 16.6      a
## VG:60  16.6      a
## MT:30  16.0     ab
## MT:60  15.2     ab
## MT:100 13.8     ab
## VØ:30  13.4     ab
## VF:100 12.2     ab
## VG:30  12.2     ab
## VF:60  11.2     ab
## VF:30  10.8     ab
## VØ:100  9.6     ab
## VØ:60   9.4      b
###########Figuras floração Monilioptora ##########################

dt <- read_excel("C:/Users/Alex/Desktop/Angelica/exp2.xlsx", 
                 sheet = "MP")
attach(dt)
## The following object is masked from dt (pos = 3):
## 
##     dias
## The following object is masked from dt (pos = 4):
## 
##     trat
## The following object is masked from datos2:
## 
##     trat
head(dt)
## # A tibble: 6 x 24
##   Número genot Bloco trat   dias `1`   `2`   `3`   `4`   `5`   `6`   `7`   `8`  
##    <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1      1 VF.1  Bloc~ Inoc~     4 <NA>  <NA>  <NA>  x     <NA>  <NA>  <NA>  <NA> 
## 2      2 VF    Bloc~ Mock      7 <NA>  <NA>  <NA>  <NA>  <NA>  <NA>  x     <NA> 
## 3      3 VF.1  Bloc~ Mock      2 <NA>  x     <NA>  <NA>  <NA>  <NA>  <NA>  <NA> 
## 4      4 MT    Bloc~ Mock     17 <NA>  <NA>  <NA>  <NA>  <NA>  <NA>  <NA>  <NA> 
## 5      5 VG    Bloc~ Inoc~    11 <NA>  <NA>  <NA>  <NA>  <NA>  <NA>  <NA>  <NA> 
## 6      6 VF    Bloc~ Mock     12 <NA>  <NA>  <NA>  <NA>  <NA>  <NA>  <NA>  <NA> 
## # ... with 11 more variables: `9` <chr>, `10` <chr>, `11` <chr>, `12` <chr>,
## #   `13` <chr>, `14` <chr>, `15` <chr>, `16` <chr>, `17` <chr>, `18` <chr>,
## #   `19` <chr>
summary(aov(dias~genot*trat, data=dt))
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## genot         4  543.7  135.91   5.782 0.000254 ***
## trat          1    0.0    0.00   0.000 0.991187    
## genot:trat    4  161.2   40.31   1.715 0.150436    
## Residuals   133 3126.5   23.51                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 8 observations deleted due to missingness
shapt <-shapiro.test(unlist(aov(dias ~ genot*trat, data = dt)["residuals"])); print(shapt)
## 
##  Shapiro-Wilk normality test
## 
## data:  unlist(aov(dias ~ genot * trat, data = dt)["residuals"])
## W = 0.97293, p-value = 0.006175
my_residuals_asen<-unlist(aov(dias ~ genot*trat, data = dt)["residuals"])
hist(my_residuals_asen)

ks.test(my_residuals_asen, pnorm)$statistic
## Warning in ks.test(my_residuals_asen, pnorm): ties should not be present for the
## Kolmogorov-Smirnov test
##         D 
## 0.3626711
a<-as.factor(genot)
b<-as.factor(trat)
inter<-as.factor(a:b)
kruskal.test(dias ~ inter, data = dt)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  dias by inter
## Kruskal-Wallis chi-squared = 25.853, df = 9, p-value = 0.002159
kruskal(dias, inter)["groups"]
## $groups
##                       dias groups
## MT:Inoculated    104.50000      a
## MT:Mock           86.26471     ab
## VF.1:Inoculated   82.75000    abc
## VF.1:Mock         82.17857   abcd
## VAZIO:Mock        81.80556   abcd
## VG:Mock           71.00000    bcd
## VAZIO:Inoculated  62.50000   bcde
## VF:Inoculated     57.13333    cde
## VG:Inoculated     53.42857     de
## VF:Mock           39.25000      e
my_mean<-LSD.test(aov(dias ~ inter, data = dt),
                  "inter", alpha = 0.05)["groups"];print(my_mean)
## $groups
##                       dias groups
## MT:Inoculated    14.090909      a
## MT:Mock          11.294118     ab
## VF.1:Mock        11.142857    abc
## VAZIO:Mock       11.111111    abc
## VF.1:Inoculated  11.000000   abcd
## VG:Mock           9.642857    bcd
## VAZIO:Inoculated  8.666667   bcde
## VF:Inoculated     7.800000    cde
## VG:Inoculated     7.428571     de
## VF:Mock           5.714286      e
my_mean<-LSD.test(aov(dias ~ genot, data = dt),
                  "genot", alpha = 0.05)["groups"];print(my_mean)
## $groups
##            dias groups
## MT    12.392857      a
## VF.1  11.071429     ab
## VAZIO 10.133333     ab
## VG     8.535714     bc
## VF     6.793103      c
dt <- read_excel("C:/Users/Alex/Desktop/Angelica/exp2.xlsx", 
                 sheet = "MP3")
my_labels<- c("WT", "pCAMBIA2201", 
              "Tc-PR1-f", "Tc-PR1-f.1","Tc-PR1-g")
attach(dt)
## The following object is masked from dt (pos = 3):
## 
##     genot
## The following objects are masked from dt (pos = 5):
## 
##     desv, errop, sigtest
head(dt)
## # A tibble: 5 x 5
##   genot   med  desv errop sigtest
##   <chr> <dbl> <dbl> <dbl> <chr>  
## 1 MT    12.4   4.76 0.674 a      
## 2 VAZIO 10.1   5.41 0.765 ab     
## 3 VF     6.79  4.20 0.594 ab     
## 4 VF.1  11.1   5.35 0.757 bc     
## 5 VG     8.54  4.61 0.653 c
ggplot(data=dt, aes(x=genot, y=med )) +
  geom_bar(stat="identity",  position = "dodge")+
  geom_errorbar(data = dt, aes(ymin = med - errop, ymax = med + errop), width=0.5)+
  labs(x = NULL, y = "Days to flowering", 
        size=5)+
  scale_x_discrete(labels=my_labels)+
  geom_text(data=dt, aes(x = genot, y = med+errop +0.5, label = sigtest,
                         vjust=0, size=0), size=5) +        
  theme_classic()