annotate FunctTrendSTOCGalaxy.r @ 0:22a784d2b0e0 draft

"planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
author ecology
date Thu, 02 Apr 2020 03:33:29 -0400
parents
children af4987066235
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
2
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
3
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
4 ##################################################################################################################################
22a784d2b0e0 "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 ##############################
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
6 ##################################################################################################################################
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
7
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
10
22a784d2b0e0 "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)
22a784d2b0e0 "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:
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
20
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
21
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
22
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
25
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
26 makeTableAnalyse <- function(data) {
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
27 tab <- reshape(data
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
28 ,v.names="abond"
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
30 ,timevar="espece"
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
31 ,direction="wide")
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
33
22a784d2b0e0 "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 ""
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
35 return(tab)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
36 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
37
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
39
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
40
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
41
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
42
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
43
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
45
22a784d2b0e0 "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){
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
49
22a784d2b0e0 "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
22a784d2b0e0 "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) {
22a784d2b0e0 "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
22a784d2b0e0 "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]
22a784d2b0e0 "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
22a784d2b0e0 "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)])
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
56 }
22a784d2b0e0 "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
22a784d2b0e0 "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))
22a784d2b0e0 "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
22a784d2b0e0 "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))
22a784d2b0e0 "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
22a784d2b0e0 "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){
22a784d2b0e0 "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="")
22a784d2b0e0 "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"])
22a784d2b0e0 "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="")
22a784d2b0e0 "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)]
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
67 }
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
69 return(tab)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
70 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
71
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
72
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
73
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
74
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
77
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
78 ###
22a784d2b0e0 "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){
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
80 exclude_threshold <- NULL
22a784d2b0e0 "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
22a784d2b0e0 "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)) {
22a784d2b0e0 "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
22a784d2b0e0 "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) ####################
22a784d2b0e0 "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
22a784d2b0e0 "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) #####
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
88
22a784d2b0e0 "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)
22a784d2b0e0 "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
22a784d2b0e0 "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"
22a784d2b0e0 "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))####
22a784d2b0e0 "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"
22a784d2b0e0 "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")))) ####
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
99 }
22a784d2b0e0 "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)]
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
101
22a784d2b0e0 "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
22a784d2b0e0 "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"]
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
104
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
105
22a784d2b0e0 "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
22a784d2b0e0 "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"]
22a784d2b0e0 "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
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
110
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
111 #################################################################################
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
112
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
114 colConserve <- lfiltre$colConserve
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
116 colSupr <- lfiltre$colSupr
22a784d2b0e0 "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
22a784d2b0e0 "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){
22a784d2b0e0 "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="")
22a784d2b0e0 "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"))
22a784d2b0e0 "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),]
22a784d2b0e0 "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="")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
123
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
124 }
22a784d2b0e0 "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) {
22a784d2b0e0 "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."
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
127 stop(mess)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
128 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
129
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
130 tabCLEAN <- lfiltre$tabCLEAN
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
131
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
134
22a784d2b0e0 "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")
22a784d2b0e0 "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))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
137 ################################################################################
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
138 return(tabCLEAN)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
139 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
140
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
142
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
143
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
144
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
145
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
146
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
147
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
148
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
149
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
150
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
151
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
152
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
153
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
154
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
155
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
156
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
157
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
158
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
159
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
160
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
161
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
162
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
163
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
164
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
165
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
166
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
167
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
169
22a784d2b0e0 "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
22a784d2b0e0 "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) {
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
172
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
173
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
174
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
176 sep = "")
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
178 sep = "")
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
180
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
181
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
182
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
183
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
185
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
186
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
188
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
189
22a784d2b0e0 "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
22a784d2b0e0 "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")
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
193
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
194
22a784d2b0e0 "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
22a784d2b0e0 "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))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
197 nbans <- length(annee)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
198 pasdetemps <- nbans-1
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
199 firstY <- min(annee)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
200 lastY <- max(annee)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
201
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
202
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
203
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
204
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
205
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
209
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
211
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
212
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
213 listSp <- spOrdre$espece
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
214 i <- 0
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
215 nbSp <- length(listSp)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
216 # browser()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
217 ## analyse par espece
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
218 ### browser()
22a784d2b0e0 "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
22a784d2b0e0 "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="")
22a784d2b0e0 "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
22a784d2b0e0 "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])
22a784d2b0e0 "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"])
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
224 #print(tabCons)
22a784d2b0e0 "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="")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
226 flush.console()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
227
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
228
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
230
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
231
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
232 ##browser()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
233
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
235
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
236
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
237 i <- i + 1
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
238
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
240
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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="")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
244 flush.console()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
245
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
249
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
251
22a784d2b0e0 "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
22a784d2b0e0 "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,
22a784d2b0e0 "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])
22a784d2b0e0 "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))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
256
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
258
22a784d2b0e0 "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
22a784d2b0e0 "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))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
261
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
266 } else {
22a784d2b0e0 "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
22a784d2b0e0 "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")
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
270 }
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
275
22a784d2b0e0 "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()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
277
22a784d2b0e0 "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
22a784d2b0e0 "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]
22a784d2b0e0 "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]
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
281
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
283
22a784d2b0e0 "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()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
285
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
286 if(assessIC) {
22a784d2b0e0 "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)
22a784d2b0e0 "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)))
22a784d2b0e0 "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)))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
290 } else {
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
293
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
294 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
295
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
296
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
297
22a784d2b0e0 "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
22a784d2b0e0 "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,
22a784d2b0e0 "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,
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
301 courbe=vpan[1],
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
302 panel=vpan[1])
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
304 if(assessIC) {
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
310 }
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
312 ## browser()
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
314
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
315
22a784d2b0e0 "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
22a784d2b0e0 "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,
22a784d2b0e0 "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),
22a784d2b0e0 "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),
22a784d2b0e0 "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),
22a784d2b0e0 "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),
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
323
22a784d2b0e0 "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
22a784d2b0e0 "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="")) ###
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
326 # browser()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
327
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
328
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
329 if(assessIC) {
22a784d2b0e0 "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) }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
331 else {
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
333
22a784d2b0e0 "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")
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
336 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
337
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
338
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
342
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
343
22a784d2b0e0 "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
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
346
22a784d2b0e0 "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
22a784d2b0e0 "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]))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
349
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
351 ## erreur standard
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
353
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
354
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
356 LL <- NA
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
357 UL <- NA
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
358 if(assessIC) {
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
362 } else {
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
363 LL <- NA
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
364 UL <- NA
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
365 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
366
22a784d2b0e0 "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
22a784d2b0e0 "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,
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
369 LL , UL,
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
371
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
372
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
373 trendsignif <- tab1t$signif
22a784d2b0e0 "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)
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
376
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
378
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
379
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
380
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
382 # browser()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
383 if(assessIC) {
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
385 vecLib <- NULL
22a784d2b0e0 "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) {
22a784d2b0e0 "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) {
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
389 }
22a784d2b0e0 "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) {
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
392 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
393 }
22a784d2b0e0 "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 ")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
395 } else {
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
396 catIncert <- NA
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
397 raisonIncert <- NA
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
398 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
399
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
400
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
401
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
403 catEBCC <- NA
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
406 # browser()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
407 tabTrend <- data.frame(
22a784d2b0e0 "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,
22a784d2b0e0 "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,
22a784d2b0e0 "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),
22a784d2b0e0 "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),
22a784d2b0e0 "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) ,
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
414
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
415
22a784d2b0e0 "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))
22a784d2b0e0 "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
22a784d2b0e0 "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="")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
419
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
421 cat("--->",fileSaveGLMsp,"\n")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
422 flush.console()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
423
22a784d2b0e0 "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]) {
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
425 glmAn <- tabAn
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
426 glmTrend <- tabTrend
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
427 } else {
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
430 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
431 ## les figures
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
432 if(figure) {
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
436 ## les figures
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
437
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
439
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
440 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
441
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
442
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
443
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
444
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
445 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
446
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
448 cat("--->",filesaveAn,"\n")
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
450 cat("--->",filesaveTrend,"\n")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
451
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
452
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
453 flush.console()
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
454
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
455
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
456
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
457 }
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
459
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
460
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
461
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
462
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
463
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
464
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
465
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
466
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
467
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
468
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
469
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
470
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
471
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
472
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
473
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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){
22a784d2b0e0 "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,
22a784d2b0e0 "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"),
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
482 ifelse(trend<1,
22a784d2b0e0 "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"),
22a784d2b0e0 "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")))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
485 return(catEBCC)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
486 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
487
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
489
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
490
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
491
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
492
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
493
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
494
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
495
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
496
22a784d2b0e0 "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
22a784d2b0e0 "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,
22a784d2b0e0 "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) {
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
500
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
503 require(ggplot2)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
504
22a784d2b0e0 "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/",""),
22a784d2b0e0 "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",
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
507 sep = "")
22a784d2b0e0 "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
22a784d2b0e0 "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")
22a784d2b0e0 "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")
22a784d2b0e0 "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")
22a784d2b0e0 "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)
22a784d2b0e0 "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="")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
514
22a784d2b0e0 "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
22a784d2b0e0 "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")
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
518 if(assessIC){
22a784d2b0e0 "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,
22a784d2b0e0 "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,"]",
22a784d2b0e0 "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,"+ ","- "),
22a784d2b0e0 "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="")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
523 }else{
22a784d2b0e0 "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,"+ ","- "),
22a784d2b0e0 "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=""),"")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
526
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
527 }
22a784d2b0e0 "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
22a784d2b0e0 "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),
22a784d2b0e0 "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),
22a784d2b0e0 "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),""),
22a784d2b0e0 "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]))
22a784d2b0e0 "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
22a784d2b0e0 "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")
22a784d2b0e0 "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")
22a784d2b0e0 "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")
22a784d2b0e0 "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])
22a784d2b0e0 "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")
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
540
22a784d2b0e0 "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)
22a784d2b0e0 "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))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
543
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
545 if(description) {
22a784d2b0e0 "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))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
547 ## Titre, axes ...
22a784d2b0e0 "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") +
22a784d2b0e0 "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",
22a784d2b0e0 "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(),
22a784d2b0e0 "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()) +
22a784d2b0e0 "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) +
22a784d2b0e0 "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 = "" ,
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
554 breaks = names(col))+
22a784d2b0e0 "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))
22a784d2b0e0 "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 ),
22a784d2b0e0 "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)
22a784d2b0e0 "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
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
561 }
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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")
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
568 } else {
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
569
22a784d2b0e0 "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))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
571 ## Titre, axes ...
22a784d2b0e0 "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") +
22a784d2b0e0 "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",
22a784d2b0e0 "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(),
22a784d2b0e0 "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()) +
22a784d2b0e0 "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) +
22a784d2b0e0 "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 = "" ,
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
578 breaks = names(col))+
22a784d2b0e0 "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))
22a784d2b0e0 "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 ),
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
582
22a784d2b0e0 "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
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
586 }
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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")
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
593 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
594 }
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
596
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
597
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
598
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
599
22a784d2b0e0 "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
22a784d2b0e0 "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))
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
603
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
604
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
605
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
608 #
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
609
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
610
22a784d2b0e0 "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,
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
612 correctionAbondanceNull = 0.000001,
22a784d2b0e0 "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"),
22a784d2b0e0 "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")) {
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
615
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
616
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
617
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
618
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
619
22a784d2b0e0 "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
22a784d2b0e0 "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))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
622
22a784d2b0e0 "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
22a784d2b0e0 "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))
22a784d2b0e0 "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")
22a784d2b0e0 "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")
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
628
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
629
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
631 ".tabular",sep="" )
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
633 ".png",sep="" )
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
634
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
635 grpe <- donnees$specialisation
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
636
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
639
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
647
22a784d2b0e0 "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)
22a784d2b0e0 "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="_")
22a784d2b0e0 "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
22a784d2b0e0 "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))
22a784d2b0e0 "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
22a784d2b0e0 "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,
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
654 groupe_indicateur = grpe,
22a784d2b0e0 "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),
22a784d2b0e0 "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,
22a784d2b0e0 "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,
22a784d2b0e0 "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),
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
660
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
662 ".tabular",sep="" )
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
664 cat("-->",nomFileResum,"\n")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
665
22a784d2b0e0 "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
22a784d2b0e0 "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])
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
669 function(x) {
22a784d2b0e0 "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
22a784d2b0e0 "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))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
672 })
22a784d2b0e0 "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") #############################################################
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
674
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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")
22a784d2b0e0 "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")
22a784d2b0e0 "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
22a784d2b0e0 "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)) )
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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
22a784d2b0e0 "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)) )
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
688
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
690
22a784d2b0e0 "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
22a784d2b0e0 "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]
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
694
22a784d2b0e0 "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)
22a784d2b0e0 "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
22a784d2b0e0 "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")
22a784d2b0e0 "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")
22a784d2b0e0 "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)
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
701
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
702 cat("-->",nameFileSpe,"\n")
22a784d2b0e0 "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))
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
704
22a784d2b0e0 "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
22a784d2b0e0 "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="")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
707
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
709 #browser()
22a784d2b0e0 "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))
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
712 if(ICfigureGroupeSp)
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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 = "" )+
22a784d2b0e0 "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))
22a784d2b0e0 "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="")
22a784d2b0e0 "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())
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
721
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
722 # cat(" <==",nameFileSpepng,"\n")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
723
22a784d2b0e0 "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
22a784d2b0e0 "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)
22a784d2b0e0 "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)
22a784d2b0e0 "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){
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
728 # print(spe)
22a784d2b0e0 "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])
22a784d2b0e0 "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) {
22a784d2b0e0 "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
22a784d2b0e0 "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],
22a784d2b0e0 "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),
22a784d2b0e0 "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
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
736
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
737 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
738
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
739 }
22a784d2b0e0 "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") ####
22a784d2b0e0 "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)
22a784d2b0e0 "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
22a784d2b0e0 "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,
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
744 ".tabular",sep="" )
22a784d2b0e0 "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")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
746 cat("-->",namefilesum,"\n")
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
747 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
748
22a784d2b0e0 "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
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
750
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
751
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
752
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
753
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
754
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
755
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
756
22a784d2b0e0 "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
22a784d2b0e0 "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).
22a784d2b0e0 "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
22a784d2b0e0 "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.
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
761
22a784d2b0e0 "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){
22a784d2b0e0 "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
22a784d2b0e0 "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")
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
766 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
767
22a784d2b0e0 "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){
22a784d2b0e0 "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))){
22a784d2b0e0 "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)
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
771 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
772 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
773 }
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
774
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
775 #####################################################################################################################
22a784d2b0e0 "planemo upload for repository https://github.com/Alanamosse/Galaxy-E/tree/stoctool/tools/stoc commit f82f897ab22464de40c878e17616333855814e25"
ecology
parents:
diff changeset
776