Mercurial > repos > ecology > stoc_mainglm
annotate FunctTrendSTOCGalaxy.r @ 0:df3ce23d0d23 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:32:56 -0400 |
parents | |
children | a961be0a964f |
rev | line source |
---|---|
0
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
1 #!/usr/bin/env Rscript |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
2 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
3 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
4 ################################################################################################################################## |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
5 ############## FUNCTION TO CALCULATE AND PLOT EVOLUTION OF SPECIES POPULATION function:main.glm ############################## |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
6 ################################################################################################################################## |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
7 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
8 #### Based on Romain Lorrillière R script |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
9 #### Modified by Alan Amosse and Benjamin Yguel for integrating within Galaxy-E |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
10 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
11 ##### workes with the R version 3.5.1 (2018-07-02) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
12 ##### Package used with the version: |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
13 #suppressMessages(library(lme4)) version 1.1.18.1 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
14 #suppressMessages(library(ggplot2)) version 3.0.0 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
15 #suppressMessages(library(speedglm)) version 0.3.2 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
16 #suppressMessages(library(arm)) version 1.10.1 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
17 #suppressMessages(library(reshape)) version 0.8.8 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
18 #suppressMessages(library(data.table)) version 1.12.0 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
19 #suppressMessages(library(reshape2)) version 1.4.3 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
20 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
21 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
22 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
23 ######################################### debut de la fonction makeTableAnalyse / stard of the function makeTableAnalyse |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
24 ## mise en colonne des especes et rajout de zero mais sur la base des carrés selectionné sans l'import / Species are placed in separated columns and addition of zero on plots where at least one selected species is present |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
25 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
26 makeTableAnalyse <- function(data) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
27 tab <- reshape(data |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
28 ,v.names="abond" |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
29 ,idvar=c("carre","annee") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
30 ,timevar="espece" |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
31 ,direction="wide") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
32 tab[is.na(tab)] <- 0 ###### remplace les na par des 0 / replace NAs by 0 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
33 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
34 colnames(tab) <- sub("abond.","",colnames(tab))### remplace le premier pattern "abond." par le second "" / replace the column names "abond." by "" |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
35 return(tab) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
36 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
37 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
38 ######################################### fin de la fonction makeTableAnalyse / end of the function makeTableAnalyse |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
39 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
40 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
41 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
42 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
43 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
44 ############################################# les fonctions qui filtrent les données pas suffisantes pour analyses fiables / The filtering functions removing species with not enough data to perform accurate analyses |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
45 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
46 filter_absent_species<-function(tab){ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
47 ##################### Filtre les espèces jamais présentes (abondance=0) / Filter of species with 0 abundance |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
48 ################################################################################# PARTIE POTENTIELLEMENT ISOLABLE ET INSERABLE AVANT LA BOUCLE = permet de gagner du temps sur la boucle car supprime sps pas vu, donc pas repris par la boucle |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
49 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
50 ## Fait la somme des abondances totales par espèce / calculate the sum of all abundance per species |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
51 if(ncol(tab)==3) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
52 tabSum <- sum(tab[,3])## cas d'une seule especes (problème de format et manip un peu differente) / when selecting only one species, use a different method |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
53 names(tabSum) <- colnames(tab)[3] |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
54 } else { ## cas de plusieurs espèce/ when selecting more than one species |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
55 tabSum <- colSums(tab[,-(1:2)]) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
56 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
57 ## colNull= espece(s) toujours absente /species with 0 total abundance |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
58 colNull <- names(which(tabSum==0)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
59 ## colconserve= espece(s) au moins presente 1 fois/ species at least with 1 presence |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
60 colConserve <- names(which(tabSum>0)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
61 ## Affichage des espèces rejetees / show species eliminated for the analyses |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
62 if(length(colNull)>0){ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
63 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="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
64 #tabNull <- data.frame(Code_espece = colNull, nom_espece = tabsp[colNull,"nom"]) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
65 #cat("\n\n",sep="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
66 tab <- tab[,c("carre","annee",colConserve)] |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
67 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
68 ################################################################################ FIN DE LA PARTIE ISOLABLE |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
69 return(tab) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
70 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
71 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
72 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
73 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
74 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
75 ###################### Filtre les especes trop rare pour avoir des analyses robustes i.e. espèce non presente la 1ère année, avec plus de 3 ans consecutif sans données et moins de 3 ans consécutif avec données |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
76 ###################### Filter too rare species for accurate analysis i.e. species absent the first year, with more than 3 consecutive years with 0 abundance, or with less than 3 consecutive years with presence |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
77 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
78 ### |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
79 filter_rare_species<-function(tab){ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
80 exclude_threshold <- NULL |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
81 ## calcul et filtre pour chaque (colonne) espece / measure and filter for each species |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
82 for(i in 3:ncol(tab)) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
83 ## v =abondance par annee / v= abundance per year |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
84 v <- tapply(tab[,i],tab$annee,sum) #################### |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
85 ## v0 =presence(1) abscence(0) per year |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
86 v0 <- ifelse(v>0,1,0) ##### |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
87 tx <- paste(v0,collapse="") #### colle les 0 et 1 / stick the 0 and 1 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
88 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
89 p <- unlist(strsplit(tx,"0"))#### Enleve les 0, ce qui séparent les sequences de "1", les sequences de "1" = nbre d'années consécutives avec data / remove 0, splitting sequences of "1" which correspond to consecutve year with data (e.g. 111 = 3 years consecutive years with data) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
90 p <- p[p!=""] #### ne garde pas les partie sans 1 ou 0 dans les sequences |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
91 ## gsSup0 = plus grande serie temporelle de presence =calcul du nbre de 1 consécutif max / calcul of the biggest temporal series which corresponds to the maximum number of consecutive "1" |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
92 gsSup0 <- max(nchar(p))#### |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
93 ## gsInf0 plus grande serie temporelle d'absccence ou sans données = enlève les 1 séparant sequence de 0 qui correspondent au nbre d'année consecutive sans données / calcul of the biggest temporal series without data which corresponds to max numbzer fo consecutive "0" |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
94 gsInf0 <- max(nchar(unlist(strsplit(tx,"1")))) #### |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
95 ## y0is0 absence la premiere annee |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
96 y0is0 <- v0[1]==0 #### True ou false pour presence de "0"(=pas de données) dans la 1ère année / look if the first year of the time sequence analyzed has no data |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
97 ## seuil d'exclusion / exclusion threshold |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
98 exclude_threshold <- c(exclude_threshold,as.vector(ifelse( y0is0 | gsInf0 > 3 | gsSup0 < 3 ,"exclu","bon"))) ############## exclu sps absente la 1ère année, avec plus de 3 ans consécutifs sans données, et avec moins de 3 années consécutives sans données / indicate if the max consecutive year with data and without data, as well as whether the first year of the time sequence analyzed has data |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
99 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
100 names(exclude_threshold) <- colnames(tab)[3:ncol(tab)] |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
101 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
102 ## colonnes conservees avec assez de données / Column with enough data |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
103 colConserve <- names(exclude_threshold)[exclude_threshold=="bon"] |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
104 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
105 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
106 ## colonnes supprimees / Column that will conserved |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
107 colSupr <- names(exclude_threshold)[exclude_threshold=="exclu"] |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
108 tabCLEAN <- tab[,c("carre","annee",colConserve)] #### Garde les sps à conserver / select only species with enough data |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
109 lfiltre <- list(tabCLEAN=tabCLEAN,colConserve=colConserve,colSupr=colSupr) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
110 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
111 ################################################################################# |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
112 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
113 ## colConserve espece conservees / extract species that will be kept to print them |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
114 colConserve <- lfiltre$colConserve |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
115 ## colsupr espece trop rare et donc supprimée de l'analyse / extract species that will be deleted to print them |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
116 colSupr <- lfiltre$colSupr |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
117 ## affichage des especes retirer de l'analyse / print species that will be deleted |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
118 if(length(colSupr)>0){ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
119 cat("\n",length(colSupr)," Rare species removed from the analysis.\n\n",sep="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
120 #tabSupr <- subset(tabsp,espece %in% colSupr ,select=c("espece","nom")) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
121 #tabSupr <- tabSupr[order(tabSupr$espece),] |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
122 #cat("\n\n",sep="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
123 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
124 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
125 if(length(colConserve)==0) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
126 mess <- "No species available to calculate abundance variation in this dataset." |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
127 stop(mess) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
128 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
129 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
130 tabCLEAN <- lfiltre$tabCLEAN |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
131 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
132 #### MARCHE PAS NE SAIT PAS PQUOI |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
133 tabCLEAN <- melt(tabCLEAN, id.vars=c("carre", "annee")) #### remet le format de base :le nom d'espèce et abondance dans des colonnes séparées / back to the first format of the file: species name and abundance in separated column |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
134 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
135 colnames(tabCLEAN)[3:4] <- c("espece","abond") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
136 tabCLEAN$annee <- as.numeric(as.character(tabCLEAN$annee)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
137 ################################################################################ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
138 return(tabCLEAN) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
139 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
140 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
141 ####################################################################################################################### fin des 2 fonctions de filtre des données / end of the two function to filter the data |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
142 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
143 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
144 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
145 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
146 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
147 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
148 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
149 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
150 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
151 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
152 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
153 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
154 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
155 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
156 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
157 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
158 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
159 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
160 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
161 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
162 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
163 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
164 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
165 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
166 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
167 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
168 ############################################################################################ debut de la Function main.glm / start of the function main.glm |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
169 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
170 main.glm <- function(id="france",donneesAll=dataCLEAN,assessIC= TRUE,tabsp=tabsp,annees=annees,figure=TRUE,description=TRUE,tendanceSurFigure=TRUE, ###### declaration des arguments listSp=sp était avant declaré avant la fonction mais il me semble que ca marche aussi comme cela |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
171 seuilOccu=14,seuilAbond=NA) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
172 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
173 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
174 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
175 filesaveAn <- paste("Output/",id,"/variationsAnnuellesEspece_",id,".tabular", ##### Nom du dossier ET fichier de sortie des resultats par année / name of the output file with results for each years |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
176 sep = "") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
177 filesaveTrend <- paste("Output/",id,"/tendanceGlobalEspece_",id,".tabular", ##### Nom du dossier ET fichier de sortie des resultats pour la période "annee" complete / name of the output file with the results for the period |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
178 sep = "") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
179 fileSaveGLMs <- paste("Output/",id,"/listGLM_",id,sep = "") ##### Nom du dossier ET fichier de sortie des modèles lineaire generalisés / name of the output file of the generlized linear models |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
180 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
181 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
182 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
183 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
184 seuilSignif <- 0.05 ## seuil de significativite / significancy threshold |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
185 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
186 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
187 rownames(tabsp) <- tabsp$espece ## change nom des lignes de tabsp (table de reference des especes) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
188 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
189 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
190 ##vpan vecteur des panels de la figure ###### POUR FAIRE LES GRAPHIQUES |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
191 vpan <- c("Variation abondance") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
192 if(description) vpan <- c(vpan,"Occurrences","Abondances brutes") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
193 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
194 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
195 ## specifications des variables temporelles necesaires pour les analyses / specification of temporal variable necessary for the analyses |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
196 annee <- sort(unique(donneesAll$annee)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
197 nbans <- length(annee) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
198 pasdetemps <- nbans-1 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
199 firstY <- min(annee) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
200 lastY <- max(annee) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
201 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
202 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
203 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
204 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
205 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
206 ## Ordre de traitement des especes ### order of species to be analyzed |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
207 spOrdre <- aggregate(abond~espece,data=donneesAll,sum) #### calcul les sommes des abondances pour ordonner / calculate the sum for the ordination |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
208 spOrdre <- merge(spOrdre,tabsp,by="espece") #### rajoute la colonne avec les abondances totales par espece / add a new column with the sum |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
209 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
210 spOrdre <- spOrdre[order(as.numeric(spOrdre$indicateur),spOrdre$abond,decreasing = TRUE),] #### mets les especes plus abondantes en premiers (plus long pour faire tourner le modèle) / order the species by abundance, the most abundant species being the less fast analysis |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
211 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
212 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
213 listSp <- spOrdre$espece |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
214 i <- 0 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
215 nbSp <- length(listSp) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
216 # browser() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
217 ## analyse par espece |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
218 ### browser() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
219 ## affichage des especes conservees pour l'analyse ### PAS SUR QUE CE SOIT ENCORE UTILE |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
220 cat("\n",nbSp," Espèces conservées pour l'analyse\n\n",sep="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
221 rownames(tabsp) <- tabsp$espece |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
222 print(tabsp[,1:2]) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
223 #tabCons <- data.frame(Code_espece = listSp, nom_espece = tabsp[as.character(listSp),"nom"]) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
224 #print(tabCons) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
225 cat("\n\n",sep="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
226 flush.console() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
227 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
228 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
229 ## initialisation de la liste de sauvegarde |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
230 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
231 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
232 ##browser() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
233 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
234 for (sp in listSp) { ######## Boucle pour analyse par espèce / loop for the analysis by species |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
235 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
236 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
237 i <- i + 1 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
238 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
239 d <- subset(donneesAll,espece==sp) ## d data pour l'espece en court / cut the data keeping only the i species |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
240 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
241 #nomSp <- as.character(tabsp[sp,"nom"]) ## info sp |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
242 nomSp <- tabsp$nom[which(tabsp$espece==sp)] ## info sp |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
243 cat("\n(",i,"/",nbSp,") ",sp," | ", nomSp,"\n",sep="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
244 flush.console() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
245 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
246 #indic <- tabsp[sp,"indicateur"] ## indic :espece utilisee pour le calcul des indicateurs par groupe de specialisation / list the species used as species indicators by trophic specialization |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
247 indic <- tabsp$indicateur[which(tabsp$espece==sp)] ## indic :espece utilisee pour le calcul des indicateurs par groupe de specialisation / list the species used as species indicators by trophic specialization |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
248 nb_carre = tapply(rep(1,nrow(d)),d$annee,sum) ## nb_carre nombre de carre suivie par annee / number of plots per year |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
249 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
250 nb_carre_presence = tapply(ifelse(d$abond>0,1,0),d$annee,sum) ## nb_carre_presence nombre de carre de presence par annee / number the plots where the species were observed |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
251 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
252 tab2 <- data.frame(annee=rep(annee,2),val=c(nb_carre,nb_carre_presence),LL = NA,UL=NA, ## tab2 table de resultat d'analyse / data.frame of the analyses results |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
253 catPoint=NA,pval=NA, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
254 courbe=rep(c("carre","presence"),each=length(annee)),panel=vpan[2]) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
255 tab2$catPoint <- ifelse(tab2$val == 0,"0",ifelse(tab2$val < seuilOccu,"infSeuil",NA)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
256 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
257 abond <- tapply(d$abond,d$annee,sum) ## abond abondance par annee / abundance per year |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
258 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
259 tab3 <- data.frame(annee=annee,val=abond,LL = NA,UL=NA,catPoint=NA,pval=NA,courbe=vpan[3],panel=vpan[3]) ## table pour la figure / data.frame made to realize the graphical outputs |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
260 tab3$catPoint <- ifelse(tab3$val == 0,"0",ifelse(tab3$val < seuilAbond,"infSeuil",NA)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
261 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
262 ## GLM pour calcul des tendances annuelles de l'evolution des populations / GLM to measure annual tendency of population evolution |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
263 formule <- as.formula("abond~as.factor(carre)+as.factor(annee)") #### specification du modèle = log lineaire / specifying the model = log linear |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
264 if(assessIC) {##### OPTION A RENTRER AU DEBUT PEUT ËTRE A METTRE DANS LES ARGUMENTS SI LAISSE LE CHOIX SINON L ARG PAR DEFAUT LORS DE LA DECLARATION DE LA FONCTION |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
265 glm1 <- glm(formule,data=d,family=quasipoisson) ##### fit model lineaire general avec intervalle de confiance disponible / fit linear and generalized model with confidence intervalle available |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
266 } else { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
267 glm1 <- try(speedglm(formule,data=d,family=quasipoisson())) ##### fit modele lineaire et generaux pour les gros jeux de données / fit of linear and generalized model for large-medium dataset |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
268 if(class(glm1)[1]=="try-error") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
269 glm1 <- glm(formule,data=d,family=quasipoisson) ##### comprends pas mais je pense que c'est speedglm qui marche pas avec toutes les données |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
270 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
271 sglm1 <- summary(glm1) #### sortie du modele / output of the model |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
272 sglm1 <- coefficients(sglm1) ### coefficient regression de chaque variable avec les résultats des tests statistiques / regression coefficient of each predictive variables with results of the statistical tests |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
273 sglm1 <- tail(sglm1,pasdetemps) #### recupére les derniers elements du modèle avec la taille de l'objet "pasdetemps" car le nombre de coef = nbre d'année et pas les coefficient de regression de la variable carre / retrieve only the coefficient regression of the variable year |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
274 coefan <- as.numeric(as.character(sglm1[,1]))#### coefficient de regression de la variable année (1 pour chaque année) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
275 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
276 coefannee <- c(1,exp(coefan))## coefannee vecteur des variation d'abondance par annee avec transformation inverse du log :exp() / regression coefficient of the year back transformed from log(abundance) : exp() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
277 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
278 erreuran <- as.numeric(as.character(sglm1[,2])) #### erreur standard sur le coefficient de regression de la variable annee / standard error on the regression coefficient of the year |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
279 erreurannee1 <- c(0,erreuran*exp(coefan))## erreur standard par année / the standard error per year ###### LA J AI UN DOUTE NORMALEMENT INTERVAL DE CONF C CI_lower <- coefficients(lin_mod)[2] - 1.96*summary(lin_mod)$coefficients[2,2] |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
280 ####CI_upper <- coefficients(lin_mod)[2] + 1.96*summary(lin_mod)$coefficients[2,2] |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
281 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
282 pval <- c(1,as.numeric(as.character(sglm1[,4])))###### p value |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
283 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
284 ## calcul des intervalle de confiance avec methode de bootstrap pour simuler des coef de regress sur lequel intervalle de conf sont mesurés/ calcul of the confidence interval using bootstrap method to simulate set regression coefficients and s.e.with uncertainty POURQUOI PAS UTILISE confint.glm() ou boot() ou ci.boot() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
285 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
286 if(assessIC) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
287 glm1.sim <- sim(glm1) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
288 ic_inf_sim <- c(1,exp(tail(apply(coef(glm1.sim), 2, quantile,.025),pasdetemps))) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
289 ic_sup_sim <- c(1,exp(tail(apply(coef(glm1.sim), 2, quantile,.975),pasdetemps))) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
290 } else { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
291 ic_inf_sim <- NA |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
292 ic_sup_sim <- NA |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
293 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
294 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
295 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
296 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
297 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
298 tab1 <- data.frame(annee,val=coefannee, ## tab1 table pour la realisation des figures / table for the graphical outputs ### 2EME POUR GRAPH ici ce sont le coef de regress annee en fonction des annéés alors que tab3 c'est les abondance en fct des années et tab2 nombre de carré total et avec presence |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
299 LL=ic_inf_sim,UL=ic_sup_sim, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
300 catPoint=ifelse(pval<seuilSignif,"significatif",NA),pval, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
301 courbe=vpan[1], |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
302 panel=vpan[1]) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
303 ## netoyage des intervalle de confiance mal estimés et qd donnees pas suffisantes pour calcul d'IC /cleaning of wrong or biaised measures of the confidence interval |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
304 if(assessIC) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
305 tab1$UL <- ifelse( nb_carre_presence==0,NA,tab1$UL) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
306 tab1$UL <- ifelse(tab1$UL == Inf, NA,tab1$UL) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
307 tab1$UL <- ifelse(tab1$UL > 1.000000e+20, NA,tab1$UL) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
308 tab1$UL[1] <- 1 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
309 tab1$val <- ifelse(tab1$val > 1.000000e+20,1.000000e+20,tab1$val) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
310 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
311 ## indice de surdispersion / overdispersion index |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
312 ## browser() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
313 if(assessIC) dispAn <- glm1$deviance/glm1$null.deviance else dispAn <- glm1$deviance/glm1$nulldev |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
314 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
315 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
316 ## tabAn table de sauvegarde des resultats par année / table of the results per year ###### reprends bcp de tabl DIFFERENCE AVEC tab2 c les abondances relatives, alors que nb de carre, nb de carre presnce, p val sont aussi ds tab2 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
317 tabAn <- data.frame(id,code_espece=sp, nom_espece = nomSp,indicateur = indic,annee = tab1$annee, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
318 abondance_relative=round(tab1$val,3), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
319 IC_inferieur = round(tab1$LL,3), IC_superieur = round(tab1$UL,3), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
320 erreur_standard = round(erreurannee1,4), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
321 p_value = round(tab1$pval,3),significatif = !is.na(tab1$catPoint), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
322 nb_carre,nb_carre_presence,abondance=abond) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
323 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
324 ## GLM pour calcul des tendance generale sur la periode avec modele log lineaire / GLM to measure the tendency of population evolution on the studied period with log linear model |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
325 formule <- as.formula(paste("abond~ as.factor(carre) + annee",sep="")) ### |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
326 # browser() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
327 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
328 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
329 if(assessIC) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
330 md2 <- glm(formule,data=d,family=quasipoisson) } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
331 else { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
332 md2 <- try(speedglm(formule,data=d,family=quasipoisson()),silent=TRUE) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
333 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
334 if(class(md2)[1]=="try-error") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
335 md2 <- glm(formule,data=d,family=quasipoisson) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
336 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
337 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
338 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
339 smd2 <- summary(md2) #### sortie du modele / output of the model |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
340 smd2 <- coefficients(smd2) ### coefficient regression de chaque variable avec les résultats des tests statistiques / regression coefficient of each predictive variables with results of the statistical tests |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
341 smd2 <- tail(smd2,1) ### coefficient regression de variable annee avec les résultats des tests statistiques / regression coefficient of the variable year with results of the statistical tests |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
342 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
343 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
344 coefan <- as.numeric(as.character(smd2[,1])) ## tendences sur la periode = coefficient regression de variable annee / tendency of population evolution on the studied period = regression coefficient of the variable year |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
345 trend <- round(exp(coefan),3) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
346 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
347 pourcentage <- round((exp(coefan*pasdetemps)-1)*100,2) ## pourcentage de variation sur la periode / percentage of population variation on the studied period |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
348 pval <- as.numeric(as.character(smd2[,4])) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
349 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
350 erreuran <- as.numeric(as.character(smd2[,2])) #### récuperer l'erreur standard / retrieve the error |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
351 ## erreur standard |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
352 erreurannee2 <- erreuran*exp(coefan) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
353 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
354 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
355 ## calcul des intervalle de confiance avec methode de bootstrap pour simuler des coef de regress sur lequel intervalle de conf sont mesurés/ calculating the confidence interval based on bootstrap method to simulate set regression coefficients and s.e.with uncertainty |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
356 LL <- NA |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
357 UL <- NA |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
358 if(assessIC) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
359 md2.sim <- sim(md2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
360 LL <- round(exp(tail(apply(coef(md2.sim), 2, quantile,.025),1)),3) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
361 UL <- round(exp(tail(apply(coef(md2.sim), 2, quantile,.975),1)),3) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
362 } else { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
363 LL <- NA |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
364 UL <- NA |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
365 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
366 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
367 ## tab1t table utile pour la realisation des figures / table used for the figures |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
368 tab1t <- data.frame(Est=trend, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
369 LL , UL, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
370 pourcent=pourcentage,signif=pval<seuilSignif,pval) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
371 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
372 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
373 trendsignif <- tab1t$signif |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
374 pourcent <- round((exp(coefan*pasdetemps)-1)*100,3) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
375 ## mesure de la surdispersion / overdispersion measurment |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
376 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
377 if(assessIC) dispTrend <- md2$deviance/md2$null.deviance else dispTrend <- md2$deviance/md2$nulldev |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
378 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
379 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
380 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
381 ## classement en categorie incertain /classifying wrong or not reliable results |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
382 # browser() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
383 if(assessIC) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
384 if(dispTrend > 2 | dispAn > 2 | median( nb_carre_presence)<seuilOccu) catIncert <- "Incertain" else catIncert <-"bon" ##### en fonction de l'indice de surdispersion et presence < à seuil occurence / based on the overdispersion index and the presence on a minimum number of plots |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
385 vecLib <- NULL |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
386 if(dispTrend > 2 | dispAn > 2 | median( nb_carre_presence)<seuilOccu) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
387 if(median( nb_carre_presence)<seuilOccu) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
388 vecLib <- c(vecLib,"espece trop rare") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
389 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
390 if(dispTrend > 2 | dispAn > 2) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
391 vecLib <- c(vecLib,"deviance") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
392 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
393 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
394 raisonIncert <- paste(vecLib,collapse=" et ") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
395 } else { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
396 catIncert <- NA |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
397 raisonIncert <- NA |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
398 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
399 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
400 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
401 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
402 ## affectation des tendence EBCC / retrieve the trend of population evolution on the studied period |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
403 catEBCC <- NA |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
404 if(assessIC) catEBCC <- affectCatEBCC(trend = as.vector(trend),pVal = pval,ICinf=as.vector(LL),ICsup=as.vector(UL)) else catEBCC <- NA |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
405 ## table complete de resultats pour la periode etudiée / complete table with results for the studied period |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
406 # browser() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
407 tabTrend <- data.frame( |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
408 id,code_espece=sp,nom_espece = nomSp,indicateur = indic, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
409 nombre_annees = pasdetemps,premiere_annee = firstY,derniere_annee = lastY, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
410 tendance = as.vector(trend) , IC_inferieur=as.vector(LL) , IC_superieur = as.vector(UL),pourcentage_variation=as.vector(pourcent), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
411 erreur_standard = as.vector(round(erreurannee2,4)), p_value = round(pval,3), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
412 significatif = trendsignif,categorie_tendance_EBCC=catEBCC,mediane_occurrence=median( nb_carre_presence) , |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
413 valide = catIncert,raison_incertitude = raisonIncert) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
414 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
415 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
416 if(assessIC) listGLMsp <- list(list(glm1,glm1.sim,md2,md2.sim)) else listGLMsp <- list(list(glm1,md2)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
417 names(listGLMsp)[[1]] <-sp |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
418 fileSaveGLMsp <- paste(fileSaveGLMs,"_",sp,".Rdata",sep="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
419 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
420 save(listGLMsp,file=fileSaveGLMsp) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
421 cat("--->",fileSaveGLMsp,"\n") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
422 flush.console() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
423 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
424 if(sp==listSp[1]) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
425 glmAn <- tabAn |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
426 glmTrend <- tabTrend |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
427 } else { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
428 glmAn <- rbind(glmAn,tabAn) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
429 glmTrend <- rbind(glmTrend,tabTrend) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
430 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
431 ## les figures |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
432 if(figure) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
433 ## table complete pour la figure en panel par ggplot2 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
434 ## table pour graphe en panel par ggplot2 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
435 if(description) dgg <- rbind(tab1,tab2,tab3) else dgg <- tab1 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
436 ## les figures |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
437 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
438 ggplot.espece(dgg,tab1t,id,serie=NULL,sp,valide=catIncert,nomSp,description,tendanceSurFigure,seuilOccu=14,vpan = vpan,assessIC=assessIC) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
439 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
440 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
441 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
442 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
443 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
444 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
445 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
446 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
447 write.table(glmAn,filesaveAn,row.names=FALSE,quote=FALSE,sep="\t",dec=".",fileEncoding="UTF-8") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
448 cat("--->",filesaveAn,"\n") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
449 write.table(glmTrend,filesaveTrend,row.names=FALSE,quote=FALSE,sep="\t",dec=".",fileEncoding="UTF-8") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
450 cat("--->",filesaveTrend,"\n") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
451 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
452 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
453 flush.console() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
454 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
455 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
456 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
457 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
458 ########################################################################################################## Fin de la fonction main.glm / end of the function main.glm |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
459 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
460 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
461 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
462 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
463 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
464 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
465 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
466 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
467 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
468 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
469 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
470 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
471 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
472 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
473 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
474 ########################################################################################################### fonction appelée par main.glm renvoyant la categorie European Bird Census Council en fonction des resultats des modèles / function called by main.glm to classify results depending on the quality of the data and analyses |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
475 ## renvoie la categorie EBCC de la tendance en fonction |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
476 ## trend l'estimateur de la tendance / estimation of the trends |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
477 ## pVal la p value |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
478 ## ICinf ICsup l intervalle de confiance a 95 pourcent |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
479 affectCatEBCC <- function(trend,pVal,ICinf,ICsup){ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
480 catEBCC <- ifelse(pVal>0.05, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
481 ifelse(ICinf < 0.95 | ICsup > 1.05,"Incertain","Stable"), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
482 ifelse(trend<1, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
483 ifelse(ICsup<0.95,"Fort declin","Declin moderee"), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
484 ifelse(ICinf>1.05,"Forte augmentation","Augmentation modere"))) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
485 return(catEBCC) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
486 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
487 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
488 ############################################################################################################ fin de la fonction renvoyant la categorie EBCC / end of the function main.glm |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
489 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
490 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
491 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
492 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
493 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
494 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
495 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
496 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
497 ############################################################################################################ fonction graphique appelée par main.glm / function called by main.glm for graphical output |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
498 ggplot.espece <- function(dgg,tab1t,id,serie=NULL,sp,valide,nomSp=NULL,description=TRUE, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
499 tendanceSurFigure=TRUE,seuilOccu=14, vpan,assessIC=TRUE) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
500 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
501 # serie=NULL;nomSp=NULL;description=TRUE;valide=catIncert |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
502 # tendanceSurFigure=TRUE;seuilOccu=14 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
503 require(ggplot2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
504 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
505 figname<- paste("Output/",id,"/",ifelse(valide=="Incertain","Incertain/",""), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
506 sp,"_",id,serie, ".png", |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
507 sep = "") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
508 ## coordonnee des ligne horizontal de seuil pour les abondances et les occurences |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
509 hline.data1 <- data.frame(z = c(1), panel = c(vpan[1]),couleur = "variation abondance",type="variation abondance") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
510 hline.data2 <- data.frame(z = c(0,seuilOccu), panel = c(vpan[2],vpan[2]),couleur = "seuil",type="seuil") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
511 hline.data3 <- data.frame(z = 0, panel = vpan[3] ,couleur = "seuil",type="seuil") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
512 hline.data <- rbind(hline.data1,hline.data2,hline.data3) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
513 titre <- paste(nomSp)#,"\n",min(annee)," - ",max(annee),sep="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
514 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
515 ## texte de la tendance / text for the population evolution trend |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
516 tab1 <- subset(dgg,panel =="Variation abondance") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
517 pasdetemps <- max(dgg$annee) - min(dgg$annee) + 1 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
518 if(assessIC){ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
519 txtPente1 <- paste(tab1t$Est, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
520 ifelse(tab1t$signif," *","")," [",tab1t$LL," , ",tab1t$UL,"]", |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
521 ifelse(tab1t$signif,paste("\n",ifelse(tab1t$pourcent>0,"+ ","- "), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
522 abs(tab1t$pourcent)," % en ",pasdetemps," ans",sep=""),""),sep="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
523 }else{ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
524 txtPente1 <- ifelse(tab1t$signif,paste("\n",ifelse(tab1t$pourcent>0,"+ ","- "), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
525 abs(tab1t$pourcent)," % en ",pasdetemps," ans",sep=""),"") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
526 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
527 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
528 ## table du texte de la tendance / table of the text for the population evolution trend |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
529 tabTextPent <- data.frame(y=c(max(c(tab1$val,tab1$UL),na.rm=TRUE)*.9), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
530 x=median(tab1$annee), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
531 txt=ifelse(tendanceSurFigure,c(txtPente1),""), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
532 courbe=c(vpan[1]),panel=c(vpan[1])) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
533 ## les couleurs / the colors |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
534 vecColPoint <- c("#ffffff","#eeb40f","#ee0f59") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
535 names(vecColPoint) <- c("significatif","infSeuil","0") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
536 vecColCourbe <- c("#3c47e0","#5b754d","#55bb1d","#973ce0") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
537 names(vecColCourbe) <- c(vpan[1],"carre","presence",vpan[3]) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
538 vecColHline <- c("#ffffff","#e76060") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
539 names(vecColHline) <- c("variation abondance","seuil") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
540 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
541 col <- c(vecColPoint,vecColCourbe,vecColHline) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
542 names(col) <- c(names(vecColPoint),names(vecColCourbe),names(vecColHline)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
543 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
544 ## si description graphique en 3 panels |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
545 if(description) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
546 p <- ggplot(data = dgg, mapping = aes(x = annee, y = val)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
547 ## Titre, axes ... |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
548 p <- p + facet_grid(panel ~ ., scale = "free") + |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
549 theme(legend.position="none", |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
550 panel.grid.minor=element_blank(), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
551 panel.grid.major.y=element_blank()) + |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
552 ylab("") + xlab("Annee")+ ggtitle(titre) + |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
553 scale_colour_manual(values=col, name = "" , |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
554 breaks = names(col))+ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
555 scale_x_continuous(breaks=min(dgg$annee):max(dgg$annee)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
556 p <- p + geom_hline(data =hline.data,mapping = aes(yintercept=z, colour = couleur,linetype=type ), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
557 alpha=1,size=1.2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
558 if(assessIC){ ############# ONLY FOR THE CONFIDENCE INTERVAL |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
559 p <- p + geom_ribbon(mapping=aes(ymin=LL,ymax=UL),fill=col[vpan[1]],alpha=.2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
560 p <- p + geom_pointrange(mapping= aes(y=val,ymin=LL,ymax=UL),fill=col[vpan[1]],alpha=.2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
561 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
562 p <- p + geom_line(mapping=aes(colour=courbe),size = 1.5) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
563 p <- p + geom_point(mapping=aes(colour=courbe),size = 3) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
564 p <- p + geom_point(mapping=aes(colour=catPoint,alpha=ifelse(!is.na(catPoint),1,0)),size = 2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
565 p <- p + geom_text(data=tabTextPent, mapping=aes(x,y,label=txt),parse=FALSE,color=col[vpan[1]],fontface=2, size=4) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
566 ggsave(figname, p,width=16,height=21, units="cm") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
567 print (figname) ##### CAN BE REMOVED IF YOU DO NOT WANT THE GRAPH TO BE PLOTTED |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
568 } else { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
569 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
570 p <- ggplot(data = subset(dgg,panel=="Variation abondance"), mapping = aes(x = annee, y = val)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
571 ## Titre, axes ... |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
572 p <- p + facet_grid(panel ~ ., scale = "free") + |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
573 theme(legend.position="none", |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
574 panel.grid.minor=element_blank(), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
575 panel.grid.major.y=element_blank()) + |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
576 ylab("") + xlab("Annee")+ ggtitle(titre) + |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
577 scale_colour_manual(values=col, name = "" , |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
578 breaks = names(col))+ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
579 scale_x_continuous(breaks=min(dgg$annee):max(dgg$annee)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
580 p <- p + geom_hline(data =subset(hline.data,panel=="Variation abondance"),mapping = aes(yintercept=z, colour = couleur,linetype=type ), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
581 alpha=1,size=1.2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
582 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
583 if(assessIC){ ############# ONLY FOR THE CONFIDENCE INTERVAL |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
584 p <- p + geom_ribbon(mapping=aes(ymin=LL,ymax=UL),fill=col[vpan[1]],alpha=.2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
585 p <- p + geom_pointrange(mapping= aes(y=val,ymin=LL,ymax=UL),fill=col[vpan[1]],alpha=.2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
586 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
587 p <- p + geom_line(mapping=aes(colour=courbe),size = 1.5) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
588 p <- p + geom_point(mapping=aes(colour=courbe),size = 3) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
589 p <- p + geom_point(mapping=aes(colour=catPoint,alpha=ifelse(!is.na(catPoint),1,0)),size = 2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
590 p <- p + geom_text(data=tabTextPent, mapping=aes(x,y,label=txt),parse=FALSE,color=col[vpan[1]],fontface=2, size=4) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
591 ggsave(figname, p,width=15,height=9,units="cm") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
592 print (figname) ##### CAN BE REMOVED IF YOU DO NOT WANT THE GRAPH TO BE PLOTTED |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
593 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
594 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
595 ############################################################################################################ fin fonction graphique / end of function for graphical output |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
596 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
597 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
598 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
599 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
600 #################################################################################################################### debut de la fonction de moyenne geometrique pondere / start of the geometric weighted mean function |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
601 geometriqueWeighted <- function(x,w=1) exp(sum(w*log(x))/sum(w)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
602 #################################################################################################################### fin de la fonction de moyenne geometrique pondere / end of the geometric weighted mean function |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
603 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
604 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
605 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
606 ##################################################################################################################### debut de la fonction analyseGroupe / start of the function analyseGroupe |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
607 ## Analyse par groupe de specialisation a partir des resulats de variation d'abondance par especes / analysis by specialization group based on results of the analysis of population evolution trend |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
608 # |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
609 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
610 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
611 analyseGroupe <- function(id="france",tabsp=tabsp,donnees=donnees,donneesTrend=donneesTrend,ICfigureGroupeSp=TRUE,powerWeight=2, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
612 correctionAbondanceNull = 0.000001, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
613 groupeNom = c("generaliste","milieux batis","milieux forestiers","milieux agricoles"), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
614 groupeCouleur = c("black","firebrick3","chartreuse4","orange")) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
615 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
616 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
617 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
618 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
619 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
620 ## donnees tendances globales / results of the global trends |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
621 donneesTrend <- subset(donneesTrend, select = c(code_espece,valide,mediane_occurrence)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
622 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
623 ## table de reference espece / reference table for species |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
624 tabsp <- subset(tabsp, select= c(sp,nom,indicateur, specialisation)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
625 donnees <- merge(donnees,donneesTrend,by="code_espece") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
626 donnees <- merge(donnees,tabsp,by.x="code_espece",by.y="sp") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
627 ## table de correspondance de biais en fonction des medianes des occuerences |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
628 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
629 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
630 nameFileSpe <- paste("Output/",id,"/variationsAnnuellesGroupes_",id, ############# Declare le fichier de sortie des variations annuelles par groupe / declare the name of the outputfile for annual population evolution trend by group |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
631 ".tabular",sep="" ) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
632 nameFileSpepng <- paste("Output/",id,"/variationsAnnuellesGroupes_",id, ############# Declare le fichier de sortie graphique des variations annuelles par groupe / declare the name of the graphical output file for annual population evolution trend by group |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
633 ".png",sep="" ) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
634 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
635 grpe <- donnees$specialisation |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
636 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
637 ####### valeur seuil sont obtenues à partir de simulations / threshold values are obtained from simulations |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
638 ff <- function(x,y) max(which(y<=x)) ## fonction pour recherche le poid associé à valeur max parmi valeur seuil d'occurence inferieur ou egale à occurence mediane obs / function to retrieve the weight associated with the max occurence threshold equal or smaller than the occurence mediane observed |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
639 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
640 IncertW <- ifelse(donnees$valide=="Incertain",tBiais$biais[sapply(as.vector(donnees$mediane_occurrence),ff,y=tBiais$occurrenceMed)],1) ## pr verifier poids de l'espèce dans analyse, récupére seuil occurence minimum pour lequel tendance pas bonne, et compare avec mediane occurence des données / to check the weight of species in the analysis, this retrieve occurence threshold with wich real occurence measured on data are compared in order to verify the accuracy of the trend measurment |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
641 ## poids du a la qualite de l'estimation |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
642 # erreur_stW <- 1/((donnees$erreur_st+1)^powerWeight) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
643 # erreur_stW <- ifelse( is.na(donnees$IC_superieur),0,erreur_stW) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
644 erreur_stW <- ifelse(is.na(donnees$IC_superieur),0,1)##### si pas d'interval de confiance met 0 et donne un poid de 0 à l'esps (voir ci dessous) / if no confidence interval calculated give a weight of 0 for the sps |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
645 ## calcul du poids total de chaque espèce / calcul of the weight of each species |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
646 W <- IncertW * erreur_stW |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
647 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
648 ## variable de regroupement pour les calculs par groupe de specialisation et par an / variables gathered to identify group for the calculation (per specialization and per year) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
649 grAn <- paste(donnees$specialisation,donnees$annee,sep="_") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
650 ## data frame pour le calcul / dataframe made for the calcul |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
651 dd <- data.frame(grAn,annee = donnees$annee, grpe,W,ab=donnees$abondance_relative,ICinf= donnees$IC_inferieur, ICsup= ifelse(is.na(donnees$IC_superieur),10000,donnees$IC_superieur)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
652 ## table resumer de tous les poids / table to sum up the weights of each species depending on the incertainty in the calcul of the poulation evolution trends |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
653 ddd <- data.frame(code_espece = donnees$code_espece,nom_espece = donnees$nom_espece,annee = donnees$annee, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
654 groupe_indicateur = grpe, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
655 poids_erreur_standard = round(erreur_stW,3), poids_incertitude = round(IncertW,3),poids_final = round(W,3), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
656 abondance_relative=donnees$abondance_relative, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
657 IC_inferieur= donnees$IC_inferieur, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
658 IC_superieur= ifelse(is.na(donnees$IC_superieur),10000,donnees$IC_superieur), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
659 valide = donnees$valide, mediane_occurrence = donnees$mediane_occurrence) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
660 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
661 nomFileResum <- paste("Output/",id,"/donneesGroupes_",id, ###### declaration du nom du repertoire et des fichiers de sortie / declaring the name of the output folder and files |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
662 ".tabular",sep="" ) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
663 write.table(ddd,nomFileResum,row.names=FALSE,sep="\t",dec=".",fileEncoding="UTF-8") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
664 cat("-->",nomFileResum,"\n") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
665 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
666 ## calcul des moyennes ponderees par groupe par an et pour les abondance et les IC / calcul of weighted means per specialization group and per year for the abundance and confidence interval |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
667 for(j in 5:7) dd[,j] <- ifelse(dd[,j]==0,correctionAbondanceNull,dd[,j]) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
668 ag <- apply(dd[,5:7], 2, ######## sur les abondances relatives, les ICinf et ICsup |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
669 function(x) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
670 sapply(split(data.frame(dd[,1:4], x), dd$grAn), ###### fait les moyennes pondérés par groupe grAn / calculate the weighted mean by group grAn |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
671 function(y) round(geometriqueWeighted(y[,5], w = y$W),3)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
672 }) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
673 ## gg <- subset(dd,as.character(dd$grAn)=="milieux forestier_2014") ############################################################# |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
674 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
675 ag <- ifelse(is.na(ag),1,ag) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
676 ag <- as.data.frame(ag) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
677 ag$grAn <- rownames(ag) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
678 dbon <- subset(donnees,valide=="bon") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
679 dIncert <- subset(donnees,valide=="Incertain") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
680 ## calcul nombre d'espece "bonne" pour le calcul / calculating the number of species with low level of incertainty, "good" species |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
681 bon <- tapply(dbon$nom,dbon$specialisation,FUN=function(X)length(unique(X)) ) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
682 bon <- ifelse(is.na(bon),0,bon) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
683 tbon <- data.frame(groupe=names(bon),bon) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
684 ## calcul nombre d'especes "incertaines" pour le calcul / calculating the number of species with high level of incertainty, "bad" species |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
685 Incert <- tapply(dIncert$nom,dIncert$specialisation,FUN=function(X)length(unique(X)) ) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
686 Incert <- ifelse(is.na(Incert),0,Incert) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
687 tIncert <- data.frame(groupe=names(Incert),Incertain=Incert) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
688 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
689 tIncert <- merge(tIncert,tbon,by="groupe") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
690 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
691 ## table de données avec les moyennes ponderees par groupe / table of the data with the weighted mean by group |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
692 da <- merge(unique(dd[,1:3]),ag,by="grAn")[,-1] |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
693 colnames(da) <- c("annee","groupe","abondance_relative","IC_inferieur","IC_superieur") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
694 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
695 da$annee <- as.numeric(da$annee) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
696 da <- merge(da,tIncert,by="groupe") #### ajoute le nombre d'espece "incertaines" et "bonne" aux resultats / add the number of "good" and "bad" species to the overall resutls |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
697 da <- subset(da, groupe != "non") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
698 colnames(da)[6:7] <- c("nombre_especes_incertaines","nombre_espece_bonnes") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
699 a <- data.frame(id,da) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
700 write.table(da,file=nameFileSpe,row.names=FALSE,quote=FALSE,sep="\t",dec=".",fileEncoding="UTF-8") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
701 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
702 cat("-->",nameFileSpe,"\n") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
703 yearsrange <- c(min(da$annee),max(da$annee)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
704 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
705 ## figure par ggplot2 / plots with ggplot2 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
706 titre <- paste("Variation de l'indicateur groupe de specialisation",sep="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
707 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
708 vecCouleur <- setNames(groupeCouleur,groupeNom) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
709 #browser() |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
710 p <- ggplot(data = da, mapping = aes(x = annee, y = abondance_relative, colour=groupe,fill=groupe)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
711 p <- p + geom_hline(aes(yintercept = 1), colour="white", alpha=1,size=1.2) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
712 if(ICfigureGroupeSp) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
713 p <- p + geom_ribbon(mapping=aes(ymin=IC_inferieur,ymax=IC_superieur),linetype=2,alpha=.1,size=0.1) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
714 p <- p + geom_line(size=1.5) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
715 p <- p + ylab("") + xlab("Annee")+ ggtitle(titre) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
716 if(!is.null(groupeNom)) p <- p + scale_colour_manual(values=vecCouleur, name = "" )+ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
717 scale_x_continuous(breaks=unique(da$annee)) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
718 if(!is.null(groupeNom)) p <- p + scale_fill_manual(values=vecCouleur, name="") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
719 p <- p + theme(panel.grid.minor=element_blank(), panel.grid.major.y=element_blank()) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
720 ggsave(nameFileSpepng, p,width=17,height=10,units="cm") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
721 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
722 # cat(" <==",nameFileSpepng,"\n") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
723 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
724 ## calul pour chaque groupe une pente de regression d'evolution des abondances sur la periode étudiée / calculating for each group the regression slope for the abundance evolution on the studied period |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
725 vecSpe <- unique(da$groupe) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
726 datasum <- data.frame(groupe=NULL,tendance=NULL,pourcentage_variation=NULL) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
727 for(spe in 1:4){ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
728 # print(spe) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
729 subtab <- subset(da,groupe==vecSpe[spe]) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
730 if(nrow(subtab)>1) { |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
731 sumlm <- summary(lm(abondance_relative~annee,data=subtab)) ##### recupère les resultats du modèle linéaire / retrieve the results of the linear model |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
732 subdatasum <- data.frame(groupe=vecSpe[spe], |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
733 tendance=round(sumlm$coefficients[2,1],3), |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
734 pourcentage_variation=round(sumlm$coefficients[2,1]*(nrow(subtab)-1)*100,3)) #### assemble les resultats pour en faire une sortie / bring together the results for an output file |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
735 datasum <- rbind(datasum,subdatasum) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
736 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
737 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
738 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
739 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
740 datasum <- merge(datasum,tIncert,by="groupe") #### |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
741 datasum <- data.frame(id,datasum) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
742 #datasum$cat_tendance_EBCC <- affectCatEBCC(trend,pVal,ICinf,ICsup |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
743 namefilesum <- paste("Output/",id,"/tendancesGlobalesGroupes_",id, |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
744 ".tabular",sep="" ) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
745 write.table(datasum,file=namefilesum,row.names=FALSE,quote=FALSE,sep="\t",dec=".",fileEncoding="UTF-8") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
746 cat("-->",namefilesum,"\n") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
747 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
748 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
749 ################################################################################################################## fin de la fonction analyseGroupe / end of the function analyseGroupe |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
750 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
751 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
752 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
753 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
754 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
755 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
756 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
757 ################################################################################################################### debut de la fonction check_file / start of the function check_file |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
758 # Fonction pour verifier les données d'entrée / General function to check integrity of input file. Will check numbers and contents of variables(colnames). |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
759 #return an error message and exit if mismatch detected |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
760 #Faut rentrer le nom du jeu de données, le nbre et le nom des variables / Enter dataset name, expected number and names of variables. + an exit error message to guide user. |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
761 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
762 check_file<-function(dataset,err_msg,vars,nb_vars){ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
763 if(ncol(dataset)!=nb_vars){ #Verifiction de la présence du bon nb de colonnes, si c'est pas le cas= message d'erreur / checking for right number of columns in the file if not = error message |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
764 cat("\nerr nb var\n") |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
765 stop(err_msg, call.=FALSE) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
766 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
767 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
768 for(i in vars){ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
769 if(!(i %in% names(dataset))){ |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
770 stop(err_msg,call.=FALSE) |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
771 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
772 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
773 } |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
774 |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
775 ##################################################################################################################### |
df3ce23d0d23
"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff
changeset
|
776 |