Last updated: 2022-03-29

Checks: 6 1

Knit directory: HenriqueDGen/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20211012) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 92024b5. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/figure/
    Ignored:    data/.DS_Store

Untracked files:
    Untracked:  output/BLUPsDiseaseAgro.rds

Unstaged changes:
    Modified:   analysis/AnalisesModelosMistos.Rmd
    Modified:   analysis/PCA_DAPC.Rmd
    Modified:   analysis/index.Rmd
    Modified:   data/DadosFenotipicos.RDS
    Deleted:    output/BLUPsDisease.RDS
    Modified:   output/DAPCAn.RDS
    Modified:   output/DadosFenotipicosv2.RDS

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/PCA_DAPC.Rmd) and HTML (docs/PCA_DAPC.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 89ac868 HenriqueBernardino 2022-01-29 Análise de Correlações
html 89ac868 HenriqueBernardino 2022-01-29 Análise de Correlações
Rmd d124c30 LucianoRogerio 2021-12-07 Update of the webpage to english writting
html d124c30 LucianoRogerio 2021-12-07 Update of the webpage to english writting
Rmd 73653b1 LucianoRogerio 2021-12-07 fix the buttons at the final of each of the webpages
html 73653b1 LucianoRogerio 2021-12-07 fix the buttons at the final of each of the webpages
Rmd f272038 LucianoRogerio 2021-12-07 Update of the analysis and website layout
html f51cdc6 LucianoRogerio 2021-11-18 Add the Dendrogram analysis
Rmd b30f532 LucianoRogerio 2021-11-16 Add a header Introduction to PCA DAPC Analysis
html b30f532 LucianoRogerio 2021-11-16 Add a header Introduction to PCA DAPC Analysis
Rmd cbf63bd LucianoRogerio 2021-11-16 Add Dendrogram
html cbf63bd LucianoRogerio 2021-11-16 Add Dendrogram
html 1faf8c1 LucianoRogerio 2021-11-09 DAPC Analysis finished
Rmd efcce5f LucianoRogerio 2021-11-09 Merge branch ‘main’ of https://github.com/LucianoRogerio/HenriqueDGen
Rmd e89306d LucianoRogerio 2021-11-09 DAPC Analysis finished
html e89306d LucianoRogerio 2021-11-09 DAPC Analysis finished
Rmd 33422ee LucianoRogerio 2021-11-09 DAPC Analysis finished
html 33422ee LucianoRogerio 2021-11-09 DAPC Analysis finished
Rmd 97d638d LucianoRogerio 2021-11-02 Update of html links
html 97d638d LucianoRogerio 2021-11-02 Update of html links

Wrong Page?

Analysis of Principal Components

This previoulsy analysis were performed aiming to select the best number of principal components. The phenotypic data were centered using the function scale to remove the effect of trait variance at the principal components analysis. The selection criteria for the number of principal components were variance bigger than one.

suppressMessages(library(tidyverse))
suppressMessages(library(adegenet))
library(reactable)
library(here)
here() starts at /Users/lbd54/Documents/GitHub/HenriqueDGen
BLUPS <- readRDS(here::here("output", "BLUPsDiseaseAgro.rds"))

BLUPS[, -1] <- scale(BLUPS[ , -1], center = T, scale = T)
BLUPS[is.na(BLUPS)] <- 0

Estimation of the Variance acumulated and selection of the number of Principal Components

PCA <- prcomp(BLUPS[,-1])

Perc <- 100*PCA$sdev^2/sum(PCA$sdev^2)

PercAc <- as.vector(rep(NA, times = length(Perc)))
for(i in 1:length(Perc)) {
  PercAc[i] <- sum(Perc[1:i])
  names(PercAc)[i] <- i
}

Table 1. Variance explained by each principal component

Fig 1. Barplot of the Accumulated variances of the principal components for foliar diseases.

This part we prepare the print location for the labels of foliar disease traits

PointPCA1 <- as.data.frame(PCA$x)
ArrowPCA1 <- as.data.frame(PCA$rotation)
LabelsPCA1 <- 5*ArrowPCA1
LabelsPCA1[2, 1] <- c(-1)
LabelsPCA1[3, 1] <- c(0)
LabelsPCA1[5, 1:2] <- c(1.25, -0.45)
LabelsPCA1[6, 1:2] <- c(1.9, -0.9)
LabelsPCA1[7, 1:2] <- c(2.8, -0.1)
LabelsPCA1[9, 1:2] <- c(2.7, -0.55)
LabelsPCA1[10, 1:2] <- c(1.9, -0.1)

Fig 2. Scatterplot of the Principal components 1 and 2 with the correlation arrows of the foliar disease resistance with the principal components.

Table 2. Analise de correlação dos Caracteristicas

Discriminant Analysis of Principal Components

library(adegenet); library(ggplot2)

BLUPS <- readRDS(here::here("output", "BLUPsDiseaseAgro.rds"))
BLUPS[, -1] <- scale(BLUPS[, -1], center = T, scale = T)
BLUPS[is.na(BLUPS)] <- 0
rownames(BLUPS) <- BLUPS$CLONE
BLUPS$CLONE <- NULL

set.seed(1)
DAPCHen <- find.clusters(BLUPS, n.pca = 5, max.n.clust = 20, choose.n.clust = FALSE, criterion = "diffNgroup")
ClassDAPCHen <- DAPCHen$grp

DAPCHenGraph <- dapc(BLUPS, grp = ClassDAPCHen, n.pca = 5, n.da = 2)
saveRDS(DAPCHenGraph, here::here("output", "DAPCAn.rds"))

VarDAPC <- 10*sum(DAPCHenGraph$pca.eig[1:5])*DAPCHenGraph$var*DAPCHenGraph$eig/sum(DAPCHenGraph$eig)

DAPCIndPoint <- data.frame(DAPCHenGraph$ind.coord, grp = DAPCHenGraph$grp)
DAPCGrpEllip <- data.frame(DAPCHenGraph$grp.coord, grp = as.character(1:3))
ArrowDAPC <- as.data.frame(DAPCHenGraph$var.contr)
LabelsDAPC <- data.frame(ArrowDAPC*7)
LabelsDAPC[1, 2] <- c(1.45)
LabelsDAPC[2, 1:2] <- c(0.1, 1.69)
LabelsDAPC[3, 1:2] <- c(0.7, 1.69)
LabelsDAPC[5, 2] <- c(0)
LabelsDAPC[6, 2] <- c(0.4)
LabelsDAPC[9, 2] <- c(0.35)
LabelsDAPC[10, 2] <- c(0.05)

Fig 3. Scatterplot of the first and second linear discriminant function of the discriminant analysis of principal components for cassava foliar diseases, with four clusters

suppressMessages(library(reshape2))
BLUPS$CLONE <- rownames(BLUPS)
BLUPS$Grp <- DAPCHenGraph$grp

BLUPSBoxplot <- melt(BLUPS, variable.name = "Trait", value.name = "Y", id.vars = c("CLONE", "Grp"))

Fig 4. Boxplots of the BLUPS of the accessions grouped by the discriminant analysis of principal components for cassava foliar diseases traits

Next page

Last page

Back to home


sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Big Sur 11.6.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] reshape2_1.4.4  here_1.0.1      reactable_0.2.3 adegenet_2.1.5 
 [5] ade4_1.7-18     forcats_0.5.1   stringr_1.4.0   dplyr_1.0.8    
 [9] purrr_0.3.4     readr_2.1.2     tidyr_1.2.0     tibble_3.1.6   
[13] ggplot2_3.3.5   tidyverse_1.3.1

loaded via a namespace (and not attached):
 [1] nlme_3.1-155      fs_1.5.2          lubridate_1.8.0   httr_1.4.2       
 [5] rprojroot_2.0.2   tools_4.1.2       backports_1.4.1   bslib_0.3.1      
 [9] utf8_1.2.2        R6_2.5.1          vegan_2.5-7       DBI_1.1.2        
[13] mgcv_1.8-38       colorspace_2.0-2  permute_0.9-7     withr_2.5.0      
[17] tidyselect_1.1.2  compiler_4.1.2    git2r_0.29.0      cli_3.2.0        
[21] rvest_1.0.2       xml2_1.3.3        labeling_0.4.2    sass_0.4.1       
[25] scales_1.1.1      digest_0.6.29     rmarkdown_2.13    pkgconfig_2.0.3  
[29] htmltools_0.5.2   highr_0.9         dbplyr_2.1.1      fastmap_1.1.0    
[33] htmlwidgets_1.5.4 rlang_1.0.2       readxl_1.3.1      rstudioapi_0.13  
[37] shiny_1.7.1       farver_2.1.0      jquerylib_0.1.4   generics_0.1.2   
[41] jsonlite_1.8.0    crosstalk_1.2.0   magrittr_2.0.2    Matrix_1.4-0     
[45] Rcpp_1.0.8.3      munsell_0.5.0     fansi_1.0.3       ape_5.6-1        
[49] lifecycle_1.0.1   stringi_1.7.6     whisker_0.4       yaml_2.3.5       
[53] MASS_7.3-55       plyr_1.8.6        grid_4.1.2        parallel_4.1.2   
[57] promises_1.2.0.1  crayon_1.5.1      lattice_0.20-45   haven_2.4.3      
[61] splines_4.1.2     hms_1.1.1         knitr_1.38        pillar_1.7.0     
[65] igraph_1.2.11     seqinr_4.2-8      reprex_2.0.1      glue_1.6.2       
[69] evaluate_0.15     modelr_0.1.8      vctrs_0.3.8       tzdb_0.2.0       
[73] httpuv_1.6.5      cellranger_1.1.0  gtable_0.3.0      reactR_0.4.4     
[77] assertthat_0.2.1  xfun_0.30         mime_0.12         xtable_1.8-4     
[81] broom_0.7.12      later_1.3.0       viridisLite_0.4.0 workflowr_1.7.0  
[85] cluster_2.1.2     ellipsis_0.3.2