Mercurial > repos > ecology > stoc_maketable
comparison ExemakeTableAnalyseGalaxy.r @ 0:22a784d2b0e0 draft
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
| author | ecology |
|---|---|
| date | Thu, 02 Apr 2020 03:33:29 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:22a784d2b0e0 |
|---|---|
| 1 #!/usr/bin/env Rscript | |
| 2 | |
| 3 ################################################################################################################## | |
| 4 ################ Data transformation for population evolution trend analyses function:makeTableAnalyse ######### | |
| 5 ################################################################################################################## | |
| 6 ########### | |
| 7 | |
| 8 library(data.table) | |
| 9 #delcaration des arguments et variables/ declaring some variables and load arguments | |
| 10 | |
| 11 args = commandArgs(trailingOnly=TRUE) ##### par defaut prends les arguments comme du texte !!!! / default behaviour is to take the arguments as text !!! | |
| 12 | |
| 13 if (length(args)==0) { | |
| 14 stop("At least one argument must be supplied, an input dataset file (.tabular).", call.=FALSE) #si pas d'arguments -> affiche erreur et quitte / if no args -> error and exit1 | |
| 15 | |
| 16 } else { | |
| 17 ImportduSTOC<-args[1] ###### Nom du fichier importé depuis la base de données STOCeps avec son extension / file name imported from the STOCeps database with the file type ".filetype" | |
| 18 source(args[2])### chargement des fonctions / load the functions | |
| 19 | |
| 20 } | |
| 21 | |
| 22 ##### Le tableau de données doit posséder 4 variables en colonne: abondance ("abond"), les carrés ou sont réalisés les observatiosn ("carre"), la ou les années des observations ("annee"), et le code de ou des espèces ("espece") | |
| 23 ##### Data must be a dataframe with 4 variables in column: abundance ("abond"), plots where observation where made ("carre"), year(s) of the different sampling ("annee"), and the species code ("espece") | |
| 24 | |
| 25 | |
| 26 #Import des données / Import data | |
| 27 data<- fread(ImportduSTOC,sep="\t",dec=".",header=TRUE,encoding="UTF-8") # | |
| 28 vars_data<-c("carre","annee","espece","abond") | |
| 29 err_msg_data<-"The input dataset filtered doesn't have the right format. It need to have the following 4 variables :\n- carre\n- annee\n- espece\n- abond\n" | |
| 30 check_file(data,err_msg_data,vars_data,4) | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 ######### | |
| 36 #Do your analysis | |
| 37 tableAnalyse<-makeTableAnalyse(data) #la fonction a un 'return' il faut donc stocker le resultat dans une nouvelle variable | |
| 38 #save the data in a output file in a tabular format | |
| 39 filename <- "Datatransformedforfiltering_trendanalysis.tabular" | |
| 40 write.table(tableAnalyse, filename,row.names=FALSE,sep="\t",dec=".",fileEncoding="UTF-8") | |
| 41 | |
| 42 cat(paste("\nWrite table with data transformed for filtering. \n--> \"",filename,"\"\n",sep="")) |
