Repository 'stoc_trend_indic'
hg clone https://toolshed.g2.bx.psu.edu/repos/ecology/stoc_trend_indic

Changeset 1:5c244408661f (2020-05-11)
Previous changeset 0:916b49d725ba (2020-04-02)
Commit message:
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit d49a4da1ffac1f33a15fdb7ae98827d0034a7879"
modified:
FunctExeTemporalAnalysisofIndicatorTrait.r
FunctTrendSTOCGalaxy.r
stoceps_macros.xml
temp_analysis_indic.xml
b
diff -r 916b49d725ba -r 5c244408661f FunctExeTemporalAnalysisofIndicatorTrait.r
--- a/FunctExeTemporalAnalysisofIndicatorTrait.r Thu Apr 02 03:35:29 2020 -0400
+++ b/FunctExeTemporalAnalysisofIndicatorTrait.r Mon May 11 17:54:02 2020 -0400
[
@@ -38,12 +38,12 @@
     Datafiltered<-args[1] ###### Nom du fichier avec extension ".typedefichier", peut provenir de la fonction "FiltreEspeceRare" / file name without the file type ".filetype", may result from the function "FiltreEspeceRare"    
     tabSpecies<-args[2] ###### Nom du fichier avec extension ".typedefichier", fichier mis à disposition dans Galaxy-E avec specialisation à l'habitat des especes et si espece considérée comme indicatrice / file name without the file type ".filetype", file available in Galaxy-E containing habitat specialization for each species and whether or not they are considered as indicator  
     tabtrait<-args[3] ##### Nom du fichier avec extension ".typedefichier", fichier mis à disposition dans Galaxy-E avec degre de specialisation de l espece et affinite thermique /file name without the file type ".filetype", file available in Galaxy-E containing specilalization degree as well as thermic preferences
-    coordCarre<-args[4] #### Nom du fichier avec extension ".typedefichier", fichier mis à disposition dans Galaxy-E avec les coordonnees gps des carres /file name without the file type ".filetype", file available in Galaxy-E containing gps coordinates of the plots
-    Var <- args[5] #### Nom du trait dans fichier de traits "nomdutrait" exemple: "ssi" pour l'indice de specialisation par sps / Name of the trait in the file containing trait data   
-    indicator <- args[6] #### Nom de l'indicateur ou du trait par communauté ex pour ssi c'est csi calculé au niveau communauté / Name of the indicator or the trait per community ex: for the ssi, it is the csi measured at the community level  
-    methode <- args[7] #### Methode d'analyse de l'evolution du trait ou de l'indicateur, lmer pour modèloe mixte seul ou gam pour generalized additive model / name of the models used to analyze evolution of mean trait or indicator
-    dd <- args[8] ##### Nom du fichier si déjà un fichier avec trait moyen par communauté, avec une colonne annee appelé "year" et une colonne plot appelé "carre" correspondant à l'echelle des communautés etudiées / name of the file if a file with the mean trait value per community is already prepared with one column named "year" for the year, one column named "carre" for the plots (the scale of the community measurment)
-    id<-args[9]#Id name for output res repo 
+    coordCarre<-args[9] #### Nom du fichier avec extension ".typedefichier", fichier mis à disposition dans Galaxy-E avec les coordonnees gps des carres /file name without the file type ".filetype", file available in Galaxy-E containing gps coordinates of the plots
+    Var <- args[4] #### Nom du trait dans fichier de traits "nomdutrait" exemple: "ssi" pour l'indice de specialisation par sps / Name of the trait in the file containing trait data   
+    indicator <- args[5] #### Nom de l'indicateur ou du trait par communauté ex pour ssi c'est csi calculé au niveau communauté / Name of the indicator or the trait per community ex: for the ssi, it is the csi measured at the community level  
+    methode <- args[6] #### Methode d'analyse de l'evolution du trait ou de l'indicateur, lmer pour modèloe mixte seul ou gam pour generalized additive model / name of the models used to analyze evolution of mean trait or indicator
+    dd <- args[7] ##### Nom du fichier si déjà un fichier avec trait moyen par communauté, avec une colonne annee appelé "year" et une colonne plot appelé "carre" correspondant à l'echelle des communautés etudiées / name of the file if a file with the mean trait value per community is already prepared with one column named "year" for the year, one column named "carre" for the plots (the scale of the community measurment)
+    id<-args[8]#Id name for output res repo 
     plot_smooth<-args[10]#TRUE or FALSE
     ic<-args[11]#TRUE or FALSE
     source(args[12])
@@ -73,7 +73,6 @@
 }
 
 spTrait=read.table(tabtrait,sep="\t",dec=".",header=TRUE) ############# species_indicateur_fonctionnel.csv pour le STOC sinon fichier avec traits pour calcul du trait moyen par communauté / file with the trait for the community weighted mean calculation 
-coordCarre=read.table(coordCarre,sep="\t",dec=".",header=TRUE) ######## carre.csv  charge les coordonnées des carrés qui sont utilisés comme covariable  / load the gps coordinates of the plots, is used as covariable in the models
 
 dir.create(paste("Output/",sep=""),recursive=TRUE,showWarnings=FALSE)##### Creation du dossier de sortie
 #cat(paste("Create Output/","\n",sep=""))
@@ -113,8 +112,6 @@
         dd <- data.frame(indic,traitcarre$carre,traitcarre$annee) 
         names(dd)[2] <- "carre"
         names(dd)[3] <- "year"
-        dd$longitude_grid_wgs84 <- coordCarre$longitude_grid_wgs84[match(dd$carre,coordCarre$pk_carre)] #### recupere coordonnées gps / retrieve gps coordinates
-        dd$latitude_grid_wgs84 <- coordCarre$latitude_grid_wgs84[match(dd$carre,coordCarre$pk_carre)]  #### recupere coordonnées gps / retrieve gps coordinates
         dd$id_plot <- dd$carre  ### id_plot nom données aux carrés dans le script /id_plot is use as the name of the plot in the following script
     }else{
         colnames(dd)[colnames == "indicator"] <- "indic"
@@ -126,6 +123,10 @@
     pasdetemps <-nban-1
 
     if(methode == "gam") {
+        coordCarre=read.table(coordCarre,sep="\t",dec=".",header=TRUE) ######## carre.csv  charge les coordonnées des carrés qui sont utilisés comme covariable  / load the gps coordinates of the plots, is used as covariable in the models
+        dd$longitude_grid_wgs84 <- coordCarre$longitude_grid_wgs84[match(dd$carre,coordCarre$pk_carre)] #### recupere coordonnées gps / retrieve gps coordinates
+        dd$latitude_grid_wgs84 <- coordCarre$latitude_grid_wgs84[match(dd$carre,coordCarre$pk_carre)]  #### recupere coordonnées gps / retrieve gps coordinates
+
         cat("Methode: gam\n")
         ## Utilisation des modèles GAMM pour obtenir les tendances d evolution par an du csi cti ou ctri !!!! Marche pas si peu de données !!!!  / Use of GAMM model for the estimation of the annual variations of the csi cti or ctri  !!! does not work with few data !!! 
         cat("\nEstimation de la variation annuelle ",indicator,"~ factor(year)+s(longitude_grid_wgs84,latitude_grid_wgs84,bs='sos'),random=reStruct(object = ~ 1| id_plot,correlation=corAR1(form=~year)\n",sep="")
b
diff -r 916b49d725ba -r 5c244408661f FunctTrendSTOCGalaxy.r
--- a/FunctTrendSTOCGalaxy.r Thu Apr 02 03:35:29 2020 -0400
+++ b/FunctTrendSTOCGalaxy.r Mon May 11 17:54:02 2020 -0400
[
@@ -62,7 +62,7 @@
     if(length(colNull)>0){
         cat("\n",length(colNull)," Species removed from the analysis, abundance is always 0.\n\n",sep="")  #Espèces enlevées de l'analyse car abondance toujours égale a 0\n\n",sep="")
         #tabNull <- data.frame(Code_espece = colNull, nom_espece = tabsp[colNull,"nom"])
-        #cat("\n\n",sep="")
+        cat("Removed absent species : \n-",paste(colNull,collapse="\n-"),sep="")
         tab <- tab[,c("carre","annee",colConserve)]
     }
 ################################################################################ FIN DE LA PARTIE ISOLABLE
@@ -119,7 +119,7 @@
         cat("\n",length(colSupr)," Rare species removed from the analysis.\n\n",sep="")
         #tabSupr <- subset(tabsp,espece %in% colSupr ,select=c("espece","nom"))
         #tabSupr <- tabSupr[order(tabSupr$espece),]
-        #cat("\n\n",sep="")
+        cat("Removed rare species : \n-",paste(colSupr,collapse="\n-"),sep="")
         
     }
     if(length(colConserve)==0) {
b
diff -r 916b49d725ba -r 5c244408661f stoceps_macros.xml
--- a/stoceps_macros.xml Thu Apr 02 03:35:29 2020 -0400
+++ b/stoceps_macros.xml Mon May 11 17:54:02 2020 -0400
[
@@ -1,5 +1,5 @@
 <macros>
-    <token name="@VERSION@">0.0.1</token>
+    <token name="@VERSION@">0.0.2</token>
     <xml name="reshape_requirements">
         <requirements>
             <requirement type="package" version="0.8.8">r-reshape</requirement>
@@ -53,11 +53,10 @@
         <param name="compute_ic" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="yes" label="Compute confidence intervals"/>
     </xml>
     <xml name="stoceps_filter_glmmtmb">
-        <filter> settings['advanced'] == 'advanced'</filter>
-        <filter> settings['method'] == 'glmmtmb'</filter>
+        <filter> method['model'] == 'glmmtmb'</filter>
     </xml>
     <xml name="stoceps_filter_gam">
-        <filter> settings['method'] == 'gam'</filter>
+        <filter> method['model'] == 'gam'</filter>
     </xml>
     <xml name="stoceps_bibref">
         <citations>
b
diff -r 916b49d725ba -r 5c244408661f temp_analysis_indic.xml
--- a/temp_analysis_indic.xml Thu Apr 02 03:35:29 2020 -0400
+++ b/temp_analysis_indic.xml Mon May 11 17:54:02 2020 -0400
b
@@ -10,7 +10,6 @@
          '$input'
          '$inputtabSpecies'
          '$inputspeciesindic'
-         '$inputcoord'
          #if $index=='csi' 
              'ssi'
              'csi'
@@ -21,12 +20,17 @@
              'stri'
              'ctri'
          #end if
+         #if $method.model=='gam'
+             'gam' '' 'idindicatortrait'
+             '$inputcoord'
+         #else
+             'glmmtmb' '' 'idindicatortrait'
+             ''
+         #end if
          #if $settings.advanced=='advanced' 
-             $settings.method '' 'idindicatortrait'
              $settings.smooth_plot
              $settings.compute_ic
          #else
-             'gam' '' 'idindicatortrait'
              'TRUE'
              'TRUE'
          #end if
@@ -35,7 +39,7 @@
     </command>
     <inputs>
         <expand macro="stoceps_input_filtered"/>
-        <param name="inputcoord" type="data" format="tabular" label="Coordinates of sites" help="Input localization tabular file, with 3 columns (site ID, latitude, longitude)." />
+
         <param name="inputtabSpecies" type="data" format="tabular" label="Species file" help="Input species tabular file, with 5 columns (species ID, species name, species scientific name, specialization status)." />
         <param name="inputspeciesindic" type="data" format="tabular" label="indicators info file" help="Input indicator info tabular file, with a `species ID` column and at least one index column (named `ssi` or `sti` or `stri`)." />
         <param name="index" type="select" help="Available index" label="Chose the index you want to compute">
@@ -43,14 +47,21 @@
             <option value="cti">CTI</option>
             <option value="ctri">CTRI</option>
         </param>
+        <conditional name="method">
+            <param name="model" type="select" help="Available methods are GlmmTMB and Gam" label="Choose the model method">
+                <option value="glmmtmb">GlmmTMB</option>
+                <option selected="true" value="gam">Gam</option>
+            </param>
+            <when value="gam">
+                 <param name="inputcoord" type="data" format="tabular" label="Coordinates of sites" help="Input localization tabular file, with 3 columns (site ID, latitude, longitude)." />
+            </when>
+            <when value="glmmtmb">
+            </when>
+        </conditional>
         <conditional name="settings">
             <expand macro="stoceps_advanced_params_select"/>
             <when value="advanced">
                 <param name="smooth_plot" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="yes" label="Smooth visualization."/>
-                <param name="method" type="select" help="Available methods are GlmmTMB and Gam" label="Chose the model method">
-                    <option selected="true" value="glmmtmb">GlmmTMB</option>
-                    <option value="gam">Gam</option>
-                </param>
                 <expand macro="stoceps_compute_ic"/>
             </when>
         </conditional>
@@ -90,7 +101,7 @@
             <param name="inputtabSpecies" value="tabSpecies.csv"/>
             <param name="advanced" value="advanced"/>
             <param name="smooth_plot" value="TRUE"/>
-            <param name="method" value="gam"/>
+            <param name="model" value="gam"/>
             <param name="compute_ic" value="FALSE"/>
             <output name="output_tab_gammcomplet">
                 <assert_contents>
@@ -123,12 +134,11 @@
         </test>
         <test>
             <param name="input" value="Datafilteredfortrendanalysis.tabular"/>
-            <param name="inputcoord" value="coordCarreSTOCfaux.tabular"/>
             <param name="inputspeciesindic" value="species_indicateur_fonctionnel.tabular"/>
             <param name="inputtabSpecies" value="tabSpecies.csv"/>
             <param name="advanced" value="advanced"/>
             <param name="smooth_plot" value="FALSE"/>
-            <param name="method" value="glmmtmb"/>
+            <param name="model" value="glmmtmb"/>
             <param name="compute_ic" value="TRUE"/>
             <output name="output_plot_glmmtb_csiplot">
                 <assert_contents>
@@ -158,8 +168,11 @@
 
 Compute and plot time variation of indicator or mean trait values of communities.
 
+The default GAM model tests fixed effects of year, smoothed longitude and latitude and random effect of site on the selected indicator : indicator ~ year + s(longitude,latitude) + 1|site
+The GlmmTMB model tests fixed effects of year and random effect of site on the selected indicator : indicator ~ year + 1|site 
+
 CSI Temporal analysis indicator
-This script computes the indicator csi, cti and ctri per year and site, wich also correspond to a community weighted mean (CWM), and analyse its temporal evolution trend and create graphical vizualisation.
+This script computes the indicator csi, cti and ctri per year and site, wich also correspond to a community weighted mean (CWM), analyse its temporal evolution trend with gam or glmmtmb model and create graphical vizualisation.
 As indicator you can thus use also a trait.
 
 |
@@ -176,7 +189,7 @@
 
 One tabular file with trait data including at least one column with the species name or ID (the one used in the count data file) and one column with the trait value for each species (named `ssi` or `sti` or `stri`). For the CSI indicator notably (community specialization index), this should be the ssi (species specialization index).   
 
-One tabular file with coordinates in latitude and longitude (one column for each) including also the site ID (the one used in the count data file) 
+One additional tabular for Gam method only file with coordinates in latitude and longitude (one column for each) including also the site ID (the one used in the count data file) 
 
 |