source("https://raw.githubusercontent.com/Flavjack/inti/master/pkgdown/favicon/docs.r") knitr::opts_chunk$set(echo = TRUE)
library(inti) library(gsheet) library(FactoMineR) library(cowplot) library(png)
url <- paste0("https://docs.google.com/spreadsheets/d/" , "15r7ZwcZZHbEgltlF6gSFvCTFA-CFzVBWwg3mFlRyKPs/edit#gid=172957346") # browseURL(url) fb <- url %>% gsheet2tbl() %>% rename_with(tolower) %>% mutate(across(c(riego, geno, bloque), ~ as.factor(.))) %>% mutate(across(where(is.factor), ~ gsub("[[:space:]]", "", .)) ) %>% as.data.frame() # str(fb)
wue <- fb %>% plot_raw(type = "boxplot" , x = "geno" , y = "wue" , group = "riego" , xlab = "Genotipos" , ylab = "Water use efficiency (g/l)" , ylimits = c(5, 30, 5) , glab = "Tratamientos" )
hi <- fb %>% plot_raw(type = "scatterplot" , x = "hi" , y = "twue" , group = "riego" , xlab = "Harvest Index" , ylab = "Tuber water use efficiency (g/l)" , glab = "Tratamientos" )
grid <- plot_grid(wue, hi , nrow = 2 , labels = "AUTO") save_plot("files/fig-01.png" , plot = grid , dpi= 300 , base_width = 10 , base_height = 10 , scale = 1.4 , units = "cm" ) knitr::include_graphics("files/fig-01.png")
#> Plot summary data model <- fb %>% yupana_analysis(response = "lfa" , model_factors = "geno*riego" , comparison = c("geno", "riego") ) lfa <- model$meancomp %>% plot_smr(type = "bar" , x = "geno" , y = "lfa" , group = "riego" , ylimits = c(0, 12000, 2000) , sig = "sig" , error = "ste" , xlab = "Genotipos" , ylab = "Area foliar (cm^2)" , color = F ) model$anova %>% anova() model$meancomp %>% web_table()
model <- fb %>% yupana_analysis(response = "twue" , model_factors = "block + geno*riego" , comparison = c("geno", "riego") ) twue <- model$meancomp %>% plot_smr(type = "line" , x = "geno" , y = "twue" , group = "riego" , ylimits = c(0, 10, 2) , error = "ste" , color = c("blue", "red") , ) + labs(x = "Genotipos" , y = "Tuber water use effiency (g/l)" ) model$anova %>% anova() model$meancomp %>% web_table()
grid <- plot_grid(lfa, twue , nrow = 2 , labels = "AUTO") ggsave2("files/fig-02.png" , plot = grid , dpi= 300 , width = 10 , height = 10 , scale = 1.5 , units = "cm") knitr::include_graphics("files/fig-02.png")
#> Principal component Analysis mv <- fb %>% yupana_mvr(last_factor = "bloque" , summary_by = c("geno", "riego") , groups = "riego" ) # sink("files/pca.txt") # # Results # summary(pca, nbelements = Inf, nb.dec = 2) # # Correlation de dimensions # dimdesc(pca) # sink() ppi <- 300 png("files/plot_pca_var.png", width=7*ppi, height=7*ppi, res=ppi) plot.PCA(mv$pca, choix="var", title="", autoLab = "y", cex = 0.8, shadowtext = T) graphics.off() ppi <- 300 png("files/plot_pca_ind.png", width=7*ppi, height=7*ppi, res=ppi) plot.PCA(mv$pca, choix="ind", habillage = 2, title="", autoLab = "y", cex = 0.8, shadowtext = T, label = "ind", legend = list(bty = "y", x = "topright")) graphics.off() # Hierarchical Clustering Analysis clt <- mv$pca %>% HCPC(., nb.clust=-1, graph = F) # sink("files/clu.txt") # clus$call$t$tree # clus$desc.ind # clus$desc.var # sink() ppi <- 300 png("files/plot_cluster_tree.png", width=7*ppi, height=7*ppi, res=ppi) plot.HCPC(x = clt, choice = "tree") graphics.off() ppi <- 300 png("files/plot_cluster_map.png", width=7*ppi, height=7*ppi, res=ppi) plot.HCPC(x = clt, choice = "map") graphics.off() plot.01 <- readPNG("files/plot_pca_var.png") %>% grid::rasterGrob() plot.02 <- readPNG("files/plot_pca_ind.png") %>% grid::rasterGrob() plot.03 <- readPNG("files/plot_cluster_map.png") %>% grid::rasterGrob() plot.04 <- readPNG("files/plot_cluster_tree.png") %>% grid::rasterGrob() plot <- plot_grid(plot.01, plot.02, plot.03, plot.04 , nrow = 2 , labels = "AUTO") ggsave2("files/fig-03.png" , plot = plot , dpi = 300 , width = 12 , height = 10 , scale = 1.5 , units = "cm") knitr::include_graphics("files/fig-03.png")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.