videoImageGreenhouse.Rmd
Create a video of a given trait recorded in the phenoArch platform. This tutorial will use the imageGreenhouse() function and the animation R package.
https://cran.r-project.org/package=animation
SystemRequirements: ImageMagick (http://imagemagick.org) or GraphicsMagick (http://www.graphicsmagick.org) or LyX (http://www.lyx.org) for saveGIF(); (PDF)LaTeX for saveLatex(); SWF Tools (http://swftools.org) for saveSWF(); FFmpeg (http://ffmpeg.org) or avconv (https://libav.org/avconv.html) for saveVideo()
## 'data.frame': 47022 obs. of 14 variables:
## $ Ref : Factor w/ 1680 levels "manip1_10_10_WW",..: 131 131 131 131 131 131 131 131 131 131 ...
## $ experimentAlias: Factor w/ 1 level "manip1": 1 1 1 1 1 1 1 1 1 1 ...
## $ Day : Factor w/ 42 levels "2013-02-01","2013-02-02",..: 3 4 5 6 7 9 9 10 11 12 ...
## $ potAlias : int 1 1 1 1 1 1 1 1 1 1 ...
## $ scenario : Factor w/ 2 levels "WD","WW": 2 2 2 2 2 2 2 2 2 2 ...
## $ genotypeAlias : Factor w/ 274 levels "11430_H","A310_H",..: 165 165 165 165 165 165 165 165 165 165 ...
## $ repetition : int 1 1 1 1 1 1 1 1 1 1 ...
## $ Line : int 1 1 1 1 1 1 1 1 1 1 ...
## $ Position : int 1 1 1 1 1 1 1 1 1 1 ...
## $ thermalTime : num 1.29 2.65 3.98 5.32 6.66 ...
## $ plantHeight : num 140 151 213 239 271 ...
## $ leafArea : num 0.018 0.019 0.0208 0.0222 0.0235 ...
## $ biovolume : num 0.253 0.62 1.201 1.68 3.396 ...
## $ Repsce : Factor w/ 15 levels "1_WD","1_WW",..: 2 2 2 2 2 2 2 2 2 2 ...
head(plant1)
## Ref experimentAlias Day potAlias scenario genotypeAlias
## 1 manip1_1_1_WW manip1 2013-02-04 1 WW Lo1199_H
## 2 manip1_1_1_WW manip1 2013-02-05 1 WW Lo1199_H
## 3 manip1_1_1_WW manip1 2013-02-06 1 WW Lo1199_H
## 4 manip1_1_1_WW manip1 2013-02-07 1 WW Lo1199_H
## 5 manip1_1_1_WW manip1 2013-02-08 1 WW Lo1199_H
## 6 manip1_1_1_WW manip1 2013-02-10 1 WW Lo1199_H
## repetition Line Position thermalTime plantHeight leafArea biovolume Repsce
## 1 1 1 1 1.290456 140.300 0.01799736 0.2530896 1_WW
## 2 1 1 1 2.645803 151.225 0.01901210 0.6198236 1_WW
## 3 1 1 1 3.980055 213.325 0.02081664 1.2013394 1_WW
## 4 1 1 1 5.319284 239.200 0.02215532 1.6800266 1_WW
## 5 1 1 1 6.656157 270.825 0.02351661 3.3961557 1_WW
## 6 1 1 1 9.258258 358.225 0.02595851 5.9954879 1_WW
# Number of Days in the dataframe (in the experiment) table(plant1[,"Day"])
##
## 2013-02-01 2013-02-02 2013-02-04 2013-02-05 2013-02-06 2013-02-07 2013-02-08
## 719 961 617 1843 1547 1573 1382
## 2013-02-09 2013-02-10 2013-02-11 2013-02-12 2013-02-13 2013-02-14 2013-02-15
## 1088 2425 2008 1590 1599 1812 1671
## 2013-02-16 2013-02-17 2013-02-18 2013-02-19 2013-02-20 2013-02-21 2013-02-22
## 1618 1681 1467 1529 866 744 824
## 2013-02-23 2013-02-24 2013-02-25 2013-02-26 2013-02-27 2013-02-28 2013-03-01
## 928 871 827 841 786 800 914
## 2013-03-02 2013-03-03 2013-03-04 2013-03-05 2013-03-06 2013-03-07 2013-03-08
## 819 873 800 987 843 871 531
## 2013-03-09 2013-03-10 2013-03-11 2013-03-12 2013-03-13 2013-03-14 2013-03-15
## 1154 1243 1568 979 583 120 120
plant1<-arrange(plant1,Day)
The code below is not evaluated but just presented. Indeed, to create a video, R must save each temporal graphic in a repertory and then create the video using all the files. We just here show how to do this. Please try it with your own path and folder hierarchy.
#---------------------------------------------------- #heat map biovolume per Day and creation of a gif video #---------------------------------------------------- vecDay<-na.omit(unique(plant1[,"Day"])) videoFileName<-"biovolume" saveVideo({ for (tmpday in 1:length(vecDay)){ imageGreenhouse(datain=filter(plant1,Day==vecDay[tmpday]),trait="biovolume",typeD=1,typeT=1,ylim=NULL, xcol="Line",ycol="Position",numrow=28,numcol=60, typeI="video") } ani.options(interval = 1,ani.dev="png",ani.height=480) }, video.name = paste0(thepath,"/output/",videoFileName,".gif"), other.opts = paste0("-y -r ",length(vecDay)+2," -i Rplot%d.png -dframes ", length(vecDay)+2," -r ",length(vecDay)+2) ) # Call the video in a Rmarkdown file #![](/my-path-to-project/output/humidity.gif)
## R version 4.0.2 (2020-06-22)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 18363)
##
## Matrix products: default
##
## locale:
## [1] LC_COLLATE=French_France.1252 LC_CTYPE=French_France.1252
## [3] LC_MONETARY=French_France.1252 LC_NUMERIC=C
## [5] LC_TIME=French_France.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] animation_2.6 openSilexStatR_1.1.0 dplyr_1.0.2
## [4] tidyr_1.1.2
##
## loaded via a namespace (and not attached):
## [1] splines_4.0.2 dotCall64_1.0-0 gtools_3.8.2 assertthat_0.2.1
## [5] expm_0.999-5 CARBayesdata_2.2 sp_1.4-2 stats4_4.0.2
## [9] yaml_2.2.1 LearnBayes_2.15.1 truncdist_1.0-2 pillar_1.4.6
## [13] backports_1.1.9 lattice_0.20-41 glue_1.4.2 digest_0.6.25
## [17] RColorBrewer_1.1-2 colorspace_1.4-1 plyr_1.8.6 htmltools_0.5.0
## [21] Matrix_1.2-18 pkgconfig_2.0.3 raster_3.3-13 CARBayesST_3.1
## [25] gmodels_2.18.1 purrr_0.3.4 scales_1.1.1 gdata_2.18.0
## [29] tibble_3.0.3 generics_0.0.2 ggplot2_3.3.2 ellipsis_0.3.1
## [33] magrittr_1.5 crayon_1.3.4 deldir_0.1-28 memoise_1.1.0
## [37] evaluate_0.14 GGally_2.0.0 fs_1.4.2 nlme_3.1-148
## [41] MASS_7.3-51.6 foreign_0.8-80 truncnorm_1.0-8 class_7.3-17
## [45] data.table_1.13.0 tools_4.0.2 shapefiles_0.7 lifecycle_0.2.0
## [49] matrixStats_0.56.0 stringr_1.4.0 munsell_0.5.0 compiler_4.0.2
## [53] pkgdown_1.5.1 e1071_1.7-3 evd_2.3-3 rlang_0.4.7
## [57] classInt_0.4-3 units_0.6-7 grid_4.0.2 rstudioapi_0.11
## [61] htmlwidgets_1.5.1 spam_2.5-1 crosstalk_1.1.0.1 rmarkdown_2.3
## [65] SpATS_1.0-11 boot_1.3-25 testthat_2.3.2 gtable_0.3.0
## [69] codetools_0.2-16 reshape_0.8.8 DBI_1.1.0 R6_2.4.1
## [73] lubridate_1.7.9 gridExtra_2.3 knitr_1.29 rgdal_1.5-16
## [77] rprojroot_1.3-2 spdep_1.1-5 KernSmooth_2.23-17 desc_1.2.0
## [81] matrixcalc_1.0-3 stringi_1.4.6 Rcpp_1.0.5 vctrs_0.3.4
## [85] sf_0.9-5 leaflet_2.0.3 spData_0.3.8 tidyselect_1.1.0
## [89] xfun_0.16 coda_0.19-3