annotate butterfly_crossplot.R @ 6:a3260d4f7868 draft

Uploaded
author mnhn65mo
date Mon, 13 Aug 2018 09:38:57 -0400
parents af2cdd97a434
children 22813beb2fa8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
1 ##################################################################
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
2 #### Script generique pour realiser les figures en croix ######
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
3 #### a partir des donnees brut ######
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
4 ##################################################################
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
5
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
6 ### Version V1.2 _ 2018-07-31
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
7
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
8 library(ggplot2)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
9 library(RColorBrewer)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
10
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
11 args <- commandArgs(trailingOnly = TRUE)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
12
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
13 ### importation code
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
14 sourcefunctions<-args[1]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
15 source(sourcefunctions)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
16
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
17 ## fonction d'importation des fichier des donnes
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
18 ### fonction d'importation, de concatenation des fichiers
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
19 ### verification des nom de colonnes
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
20 ### verification des doublon de ligne
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
21 read.data <- function(file=NULL,decimalSigne=".") {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
22 # cat("1) IMPORTATION \n--------------\n")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
23 # cat("<--",file,"\n")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
24 data <- read.table(file,sep="\t",stringsAsFactors=FALSE,header=TRUE,dec=decimalSigne)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
25 ## verification qu'il y a plusieur colonnes et essaye different separateur
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
26 if(ncol(data)==1) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
27 data <- read.table(file,sep=";",stringsAsFactors=FALSE,header=TRUE,dec=decimalSigne)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
28 if(ncol(data)==1) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
29 data <- read.table(file,sep=",",stringsAsFactors=FALSE,header=TRUE,dec=decimalSigne)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
30 if(ncol(data)==1) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
31 data <- read.table(file,sep=" ",stringsAsFactors=FALSE,header=TRUE,dec=decimalSigne)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
32 if(ncol(data)==1) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
33 stop("!!!! L'importation a echoue\n les seperatateurs de colonne utilise ne sont pas parmi ([tabulation], ';' ',' [espace])\n -> veuillez verifier votre fichier de donnees\n")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
34 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
35 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
36 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
37 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
38 return(data)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
39 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
40
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
41
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
42
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
43
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
44
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
45 filtre1niveau <- function(func,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
46 nom_fichier = filename,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
47 dec=".",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
48 nom_fichierCouleur= color_filename,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
49 col_abscisse = "AB_MOYENNE",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
50 figure_abscisse = "Abondance",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
51 col_ordonnee = "DIVERSITE_MOYENNE",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
52 figure_ordonnee = "Diversite",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
53 nomGenerique="GLOBAL",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
54 vec_figure_titre = c("Les Papillons"),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
55 colourProtocole = TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
56 nomProtocole = "Papillons",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
57 vec_col_filtre = vec_col_filtre_usr,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
58 col_sousGroup = NULL,#
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
59 val_filtre = NULL,#
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
60 figure_nom_filtre = NULL,#
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
61 bagplot = TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
62 bagProp=c(.05,.5,.95),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
63 seuilSegment=30,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
64 segmentSousSeuil=TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
65 forcageMajusculeFiltre=TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
66 forcageMajusculeSousGroupe=TRUE){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
67
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
68 dCouleur <- read.data(file=nom_fichierCouleur)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
69 d <- read.data(file=nom_fichier,decimalSigne=dec)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
70 if(colourProtocole & !is.null(nomProtocole)) colourProtocole_p <- as.character(dCouleur[dCouleur[,2]==nomProtocole,3]) else colourProtocole_p <- NULL
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
71
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
72 for(f in 1:length(vec_col_filtre)) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
73 if(length(vec_figure_titre)==1){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
74 figure_titre_f <- vec_figure_titre
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
75 }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
76 figure_titre_f <- vec_figure_titre[f]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
77 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
78 col_filtre_f <- vec_col_filtre[f]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
79 cat(col_sousGroup) #Just to check
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
80 if(func=="ggfiltre1niveau"){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
81 cat("ggfiltre1niveau")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
82 ggfiltre1niveau(d,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
83 col_abscisse,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
84 figure_abscisse,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
85 col_ordonnee,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
86 figure_ordonnee,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
87 figure_titre = figure_titre_f,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
88 col_filtre = col_filtre_f,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
89 nomGenerique,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
90 val_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
91 figure_nom_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
92 tab_figure_couleur= subset(dCouleur,Filtre==col_filtre_f),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
93 colourProtocole = colourProtocole_p,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
94 nomProtocole,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
95 bagplot,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
96 bagProp=c(.05,.5,.95),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
97 seuilSegment,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
98 segmentSousSeuil,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
99 forcageMajusculeFiltre)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
100 }else if(func=="gglocal"){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
101 cat("gglocal")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
102 gglocal(d,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
103 col_abscisse,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
104 figure_abscisse,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
105 col_ordonnee,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
106 figure_ordonnee,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
107 figure_titre = figure_titre_f,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
108 col_filtre = col_filtre_f,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
109 nomGenerique = nomGenerique,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
110 col_sousGroup = col_sousGroup,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
111 val_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
112 figure_nom_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
113 tab_figure_couleur= subset(dCouleur,Filtre==col_filtre_f),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
114 colourProtocole = colourProtocole_p,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
115 nomProtocole,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
116 couleurLocal="#f609c1",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
117 bagplot,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
118 bagProp,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
119 seuilSegment,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
120 segmentSousSeuil,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
121 forcageMajusculeFiltre,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
122 forcageMajusculeSousGroupe)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
123 }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
124 cat("ggCompareLevel")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
125 ggCompareLevel(d,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
126 col_abscisse,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
127 figure_abscisse,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
128 col_ordonnee,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
129 figure_ordonnee,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
130 figure_titre = figure_titre_f,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
131 col_filtre = col_filtre_f,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
132 nomGenerique = nomGenerique,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
133 val_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
134 figure_nom_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
135 tab_figure_couleur= subset(dCouleur,Filtre==col_filtre_f),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
136 colourProtocole = colourProtocole_p,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
137 nomProtocole,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
138 bagplot,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
139 bagProp,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
140 seuilSegment,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
141 segmentSousSeuil,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
142 forcageMajusculeFiltre)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
143 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
144 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
145 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
146
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
147 ggfiltre1niveau <- function(d,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
148 col_abscisse = "AB_MOYENNE",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
149 figure_abscisse = "Abondance",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
150 col_ordonnee = "DIVERSITE_MOYENNE",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
151 figure_ordonnee = "Diversite",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
152 figure_titre = "Referentiel papillon",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
153 col_filtre = "nom_reseau",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
154 nomGenerique = "Global",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
155 val_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
156 figure_nom_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
157 tab_figure_couleur= NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
158 colourProtocole = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
159 nomProtocole = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
160 bagplot = TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
161 bagProp=c(.05,.5,.95),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
162 seuilSegment=30,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
163 segmentSousSeuil=TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
164 forcageMajusculeFiltre=TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
165 result_dir="resultats/") {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
166
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
167 d$groupe <- as.character(d[,col_filtre])
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
168 d$abscisse <- d[,col_abscisse]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
169 d$ordonnee <- d[,col_ordonnee]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
170 d$groupe <-gsub("/","_",d$groupe)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
171 d$groupe <-gsub("!","",d$groupe)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
172
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
173 if(forcageMajusculeFiltre){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
174 d$groupe <- toupper(d$groupe)}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
175
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
176 d <- subset(d,!(is.na(groupe)) & !(is.na(abscisse)) & !(is.na(ordonnee)) & groupe != "")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
177
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
178 if(is.null(val_filtre)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
179 lesModalites <- unique(d$groupe)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
180 }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
181 lesModalites <- val_filtre
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
182 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
183
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
184 # repResult <- dir(result_dir)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
185 # current_dir<-getwd()
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
186 # dir.create(file.path(current_dir,result_dir))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
187 #
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
188 # if(!(col_filtre %in% repResult)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
189 # dir.create(file.path(".",paste(result_dir,col_filtre,sep="")))}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
190 #
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
191 # nomRep1 <- paste(result_dir,col_filtre,"/",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
192
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
193 d.autre <- d
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
194 d.autre$groupe <- nomGenerique
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
195
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
196 for(m in lesModalites) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
197 d.reseau <- subset(d,groupe==m)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
198 d.reseau$groupe <- m
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
199 ggTable <- rbind(d.autre,d.reseau)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
200
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
201 seuilResum <- nrow(d.reseau) >= seuilSegment
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
202
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
203 ggTableResum <- aggregate(cbind(ordonnee, abscisse) ~ groupe, data = ggTable,quantile, c(.25,.5,.75))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
204 ggTableResum <- data.frame(ggTableResum[,1],ggTableResum[,2][,1:3],ggTableResum[,3][,1:3])
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
205 colnames(ggTableResum) <- c("groupe","ordonnee.inf","ordonnee.med","ordonnee.sup","abscisse.inf","abscisse.med","abscisse.sup")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
206
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
207 if(ggTableResum$groupe[2]==nomGenerique){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
208 ggTableResum <- ggTableResum[c(2,1),]}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
209
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
210 if(!(is.null(tab_figure_couleur))) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
211 if(m %in% tab_figure_couleur$Modalite) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
212 figure_couleur <- setNames(c(as.character(tab_figure_couleur$couleur[tab_figure_couleur$Modalite == nomGenerique]),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
213 as.character(tab_figure_couleur$couleur[tab_figure_couleur$Modalite == m])),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
214 c(nomGenerique,m))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
215 }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
216 figure_couleur <- setNames(c(as.character(tab_figure_couleur$couleur[tab_figure_couleur$Modalite == nomGenerique]),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
217 as.character(tab_figure_couleur$couleur[tab_figure_couleur$Modalite == ""])),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
218 c(nomGenerique,m))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
219 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
220 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
221
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
222 # repResult <- dir(nomRep1)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
223 # if(!(m %in% repResult)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
224 # dir.create(paste(nomRep1,m,sep=""))}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
225 # nomRep <- paste(nomRep1,m,"/",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
226 #
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
227 #
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
228 # if(!is.null(nomProtocole)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
229 # repResult <- dir(nomRep)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
230 # if(!(nomProtocole %in% repResult)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
231 # dir.create(paste(nomRep,nomProtocole,sep=""))}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
232 # nomRep <- paste(nomRep,nomProtocole,"/",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
233 # }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
234
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
235
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
236 gg <- ggplot(ggTable,aes(x=abscisse,y=ordonnee,colour=groupe,fill=groupe))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
237 if(bagplot){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
238 gg <- gg + stat_bag(data=d.autre,prop=bagProp[1],colour=NA,alpha=.7) + stat_bag(data=d.autre,prop=bagProp[2],colour=NA,alpha=.4) + stat_bag(data=d.autre,prop=bagProp[3],colour=NA,alpha=.2) }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
239 else {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
240 gg <- gg + geom_point(alpha=.2)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
241 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
242 gg <- gg + geom_hline(data=subset(ggTableResum,groupe== nomGenerique),aes(yintercept = ordonnee.med,colour=groupe),size=.5,linetype="dashed") + geom_vline(data=subset(ggTableResum,groupe==nomGenerique),aes(xintercept = abscisse.med,colour=groupe),size=.5,linetype="dashed")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
243 if(segmentSousSeuil) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
244 gg <- gg + geom_segment(data=ggTableResum,aes(x = abscisse.med, y = ordonnee.inf, xend = abscisse.med, yend = ordonnee.sup),alpha=.8,size=2.5)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
245 gg <- gg + geom_segment(data=ggTableResum,aes(x = abscisse.inf, y = ordonnee.med, xend = abscisse.sup, yend = ordonnee.med),alpha=.8,size=2.5)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
246 if(!(seuilResum)) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
247 gg <- gg + geom_segment(data=subset(ggTableResum,groupe!=nomGenerique),aes(x = abscisse.med, y = ordonnee.inf, xend = abscisse.med, yend = ordonnee.sup),alpha=.5,size = 1.5,colour="white")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
248 gg <- gg + geom_segment(data=subset(ggTableResum,groupe!=nomGenerique),aes(x = abscisse.inf, y = ordonnee.med, xend = abscisse.sup, yend = ordonnee.med),alpha=.5,size = 1.5,colour="white")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
249 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
250 } else {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
251 gg <- gg + geom_segment(data=subset(ggTableResum,groupe==nomGenerique),aes(x = abscisse.med, y = ordonnee.inf, xend = abscisse.med, yend = ordonnee.sup),alpha=.8,size = 2.5)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
252 gg <- gg + geom_segment(data=subset(ggTableResum,groupe==nomGenerique),aes(x = abscisse.inf, y = ordonnee.med, xend = abscisse.sup, yend = ordonnee.med),alpha=.8,size = 2.5)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
253 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
254
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
255 gg <- gg + geom_point(data=d.reseau,size=2)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
256 gg <- gg + labs(list(title=figure_titre,x=figure_abscisse,y=figure_ordonnee))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
257
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
258 if(!is.null(colourProtocole)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
259 gg <- gg + theme(legend.justification=c(1,0), legend.position=c(1,0),legend.text = element_text(size = 7),legend.background = element_rect(fill=NA), axis.ticks = element_line(colour = colourProtocole, size = 1), axis.ticks.length = unit(0.3, "cm"),plot.title = element_text(colour = colourProtocole))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
260 }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
261 gg <- gg + theme(legend.justification=c(1,0), legend.position=c(1,0),legend.text = element_text(size = 7),legend.background = element_rect(fill=NA))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
262 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
263
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
264 if(!(is.null(tab_figure_couleur))){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
265 gg <- gg + scale_colour_manual(values = figure_couleur,name = "") + scale_fill_manual(values = figure_couleur,name = "",guide=FALSE)}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
266
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
267 ggfile <- paste(nomRep,nomProtocole,"_",m,".png",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
268 cat("Check",ggfile,":")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
269 ggsave(ggfile,gg)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
270 cat("\n")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
271 flush.console()
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
272 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
273 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
274
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
275
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
276 ##############################################################
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
277 gglocal <- function(d,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
278 col_abscisse = "AB_MOYENNE",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
279 figure_abscisse = "Abondance",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
280 col_ordonnee = "DIVERSITE_MOYENNE",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
281 figure_ordonnee = "Diversite",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
282 figure_titre = "Graphe referentiel",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
283 col_filtre = "NOM_RESEAU",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
284 nomGenerique = "GLOBAL",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
285 col_sousGroup = "PARCELLEID",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
286 val_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
287 figure_nom_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
288 tab_figure_couleur= NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
289 colourProtocole = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
290 nomProtocole = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
291 couleurLocal="#f609c1",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
292 bagplot = TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
293 bagProp=c(.05,.5,.95),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
294 seuilSegment=30,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
295 segmentSousSeuil=TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
296 forcageMajusculeFiltre=TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
297 forcageMajusculeSousGroupe=TRUE) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
298
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
299 d$groupe <- d[,col_filtre]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
300 d$abscisse <- d[,col_abscisse]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
301 d$ordonnee <- d[,col_ordonnee]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
302 d$sousGroup <- d[,col_sousGroup]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
303 d$groupe <-gsub("/","_",d$groupe)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
304 d$groupe <-gsub("!","",d$groupe)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
305 d$sousGroup <-gsub("/","_",d$sousGroup)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
306 d$sousGroup <-gsub("!","",d$sousGroup)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
307 if(forcageMajusculeFiltre){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
308 d$groupe <- toupper(d$groupe)}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
309 if(forcageMajusculeSousGroupe){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
310 d$sousGroup <- toupper(d$sousGroup)}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
311 d <- subset(d,!(is.na(groupe)) & !(is.na(sousGroup)) & !(is.na(abscisse)) & !(is.na(ordonnee)) & groupe != "")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
312 vecSousGroup <- as.character(unique(d$sousGroup))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
313 if(is.null(val_filtre)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
314 lesModalites <- unique(d$groupe)}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
315 else{ lesModalites <- val_filtre}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
316 repResult <- dir("resultats/")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
317 # if(!(col_filtre %in% repResult)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
318 # dir.create(paste("resultats/",col_filtre,sep=""))}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
319 # nomRep1 <- paste("resultats/",col_filtre,"/",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
320 d.autre <- d
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
321 d.autre$groupe <- nomGenerique
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
322 for(m in lesModalites) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
323 d.reseau <- subset(d,groupe==m)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
324 d.reseau$groupe <- m
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
325 ggTable <- rbind(d.autre,d.reseau)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
326 seuilResum <- nrow(d.reseau) >= seuilSegment
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
327 ggTableResum <- aggregate(cbind(ordonnee, abscisse) ~ groupe, data = ggTable,quantile, c(.25,.5,.75))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
328 ggTableResum <- data.frame(ggTableResum[,1],ggTableResum[,2][,1:3],ggTableResum[,3][,1:3])
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
329 colnames(ggTableResum) <- c("groupe","ordonnee.inf","ordonnee.med","ordonnee.sup","abscisse.inf","abscisse.med","abscisse.sup")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
330 if(ggTableResum$groupe[2]==nomGenerique){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
331 ggTableResum <- ggTableResum[c(2,1),]}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
332 if(!(is.null(tab_figure_couleur))) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
333 if(m %in% tab_figure_couleur$Modalite) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
334 figure_couleur <- setNames(c(as.character(tab_figure_couleur$couleur[tab_figure_couleur$Modalite == nomGenerique]),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
335 as.character(tab_figure_couleur$couleur[tab_figure_couleur$Modalite == m]),couleurLocal),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
336 c(nomGenerique,m,""))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
337 } else {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
338 figure_couleur <- setNames(c(as.character(tab_figure_couleur$couleur[tab_figure_couleur$Modalite == nomGenerique]),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
339 as.character(tab_figure_couleur$couleur[tab_figure_couleur$Modalite == ""]),couleurLocal),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
340 c(nomGenerique,m,""))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
341 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
342 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
343 # repResult <- dir(nomRep1)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
344 # if(!(m %in% repResult)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
345 # dir.create(paste(nomRep1,m,sep=""))}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
346 # nomRep <- paste(nomRep1,m,"/",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
347 # if(!is.null(nomProtocole)) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
348 # repResult <- dir(nomRep)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
349 # if(!(nomProtocole %in% repResult)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
350 # dir.create(paste(nomRep,nomProtocole,sep=""))}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
351 # nomRep <- paste(nomRep,nomProtocole,"/",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
352 # }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
353 d.reseau <- subset(d.reseau, !(is.na(sousGroup)))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
354 figure_size<- setNames(c(1,3,2.5), c(nomGenerique,m,""))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
355 figure_shape<- setNames(c(16,16,20), c(nomGenerique,m,""))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
356 vecSousGroup <- as.character(unique(d.reseau$sousGroup))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
357 for(p in vecSousGroup) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
358 dp <- subset(d.reseau,sousGroup == p)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
359 dp$groupe <- dp$sousGroup
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
360 ggTableSous <- rbind(d.reseau,dp)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
361 ggTableSous <- rbind(d.autre,d.reseau,dp)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
362 names(figure_couleur)[3] <- p
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
363 names(figure_shape)[3] <- p
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
364 names(figure_size)[3] <- p
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
365 gg <- ggplot(ggTableSous,aes(x=abscisse,y=ordonnee,colour=groupe,fill=groupe,shape=groupe,size=groupe))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
366 if(bagplot){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
367 gg <- gg + stat_bag(data=d.autre,prop=bagProp[1],colour=NA,alpha=.7) + stat_bag(data=d.autre,prop=bagProp[2],colour=NA,alpha=.4) + stat_bag(data=d.autre,prop=bagProp[3],colour=NA,alpha=.2)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
368 }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
369 gg <- gg + geom_point(alpha=.2)}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
370 gg <- gg + geom_hline(data=subset(ggTableResum,groupe == nomGenerique),aes(yintercept = ordonnee.med,colour=groupe),size=.5,linetype="dashed")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
371 gg <- gg + geom_vline(data=subset(ggTableResum,groupe == nomGenerique),aes(xintercept = abscisse.med,colour=groupe),size=.5,linetype="dashed")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
372 if(segmentSousSeuil) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
373 gg <- gg + geom_segment(data=ggTableResum,aes(x = abscisse.med, y = ordonnee.inf, xend = abscisse.med, yend = ordonnee.sup),alpha=.8,size=2.5)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
374 gg <- gg + geom_segment(data=ggTableResum,aes(x = abscisse.inf, y = ordonnee.med, xend = abscisse.sup, yend = ordonnee.med),alpha=.8,size=2.5)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
375 if(!(seuilResum)) {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
376 gg <- gg + geom_segment(data=subset(ggTableResum,groupe!=nomGenerique),aes(x = abscisse.med, y = ordonnee.inf, xend = abscisse.med, yend = ordonnee.sup),alpha=.5,size = 1.5,colour="white")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
377 gg <- gg + geom_segment(data=subset(ggTableResum,groupe!=nomGenerique),aes(x = abscisse.inf, y = ordonnee.med, xend = abscisse.sup, yend = ordonnee.med),alpha=.5,size = 1.5,colour="white")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
378 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
379 } else {
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
380 gg <- gg + geom_segment(data=subset(ggTableResum,groupe==nomGenerique),aes(x = abscisse.med, y = ordonnee.inf, xend = abscisse.med, yend = ordonnee.sup),alpha=.8,size = 2.5)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
381 gg <- gg + geom_segment(data=subset(ggTableResum,groupe==nomGenerique),aes(x = abscisse.inf, y = ordonnee.med, xend = abscisse.sup, yend = ordonnee.med),alpha=.8,size = 2.5)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
382 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
383 gg <- gg + geom_point(data=subset(ggTableSous,groupe != nomGenerique))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
384 if(!(is.null(tab_figure_couleur))){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
385 gg <- gg + scale_colour_manual(values = figure_couleur,name = "") + scale_fill_manual(values = figure_couleur,name = "",guide=FALSE)}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
386 gg <- gg + scale_shape_manual(values = figure_shape,name = "",guide=FALSE) + scale_size_manual(values = figure_size,guide=FALSE)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
387 gg <- gg + labs(list(title=figure_titre,x=figure_abscisse,y=figure_ordonnee))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
388 if(!is.null(colourProtocole)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
389 gg <- gg + theme(legend.justification=c(1,0), legend.position=c(1,0),legend.text = element_text(size = 7),legend.background = element_rect(fill=NA), axis.ticks = element_line(colour = colourProtocole, size = 1), axis.ticks.length = unit(0.3, "cm"),plot.title = element_text(colour = colourProtocole)) }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
390 else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
391 gg <- gg + theme(legend.justification=c(1,0), legend.position=c(1,0),legend.text = element_text(size = 7),legend.background = element_rect(fill=NA))}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
392 ggfile <- paste(nomRep,nomProtocole,"_",m,"-",p,".png",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
393 cat("Check",ggfile,":")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
394 ggsave(ggfile,gg)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
395 cat("\n")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
396 flush.console()
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
397 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
398 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
399 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
400
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
401
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
402
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
403 #####################################################
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
404 ggCompareLevel <- function(d,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
405 col_abscisse = "abond_moyenne",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
406 figure_abscisse = "Abondance",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
407 col_ordonnee = "diversite_moyenne",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
408 figure_ordonnee = "Diversite",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
409 figure_titre = "Rhooo il dechire ce graphe",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
410 col_filtre = "nom_reseau",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
411 nomGenerique = "Global",
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
412 val_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
413 figure_nom_filtre = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
414 tab_figure_couleur= NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
415 colourProtocole = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
416 nomProtocole = NULL,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
417 bagplot = TRUE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
418 bagProp=c(.05,.5,.95),
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
419 seuilSegment=30,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
420 segmentSousSeuil=FALSE,
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
421 forcageMajusculeFiltre=TRUE){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
422
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
423 d$groupe <- d[,col_filtre]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
424 d$abscisse <- d[,col_abscisse]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
425 d$ordonnee <- d[,col_ordonnee]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
426 d$groupe <-gsub("/","_",d$groupe)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
427 d$groupe <-gsub("!","",d$groupe)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
428
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
429 if(forcageMajusculeFiltre){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
430 d$groupe <- toupper(d$groupe)}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
431 d <- subset(d,!(is.na(groupe)) & !(is.na(abscisse)) & !(is.na(ordonnee)) & groupe != "")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
432 if(is.null(val_filtre)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
433 lesModalites <- unique(d$groupe)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
434 }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
435 lesModalites <- val_filtre
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
436 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
437 # repResult <- dir("resultats/")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
438 # if(!(col_filtre %in% repResult)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
439 # dir.create(paste("resultats/",col_filtre,sep=""))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
440 # }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
441 # if(!is.null(nomProtocole)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
442 # repResult <- dir(paste("resultats/",col_filtre,sep=""))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
443 # if(!(nomProtocole %in% repResult)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
444 # dir.create(paste("resultats/",col_filtre,"/",nomProtocole,sep=""))}
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
445 # nomRep <- paste("resultats/",col_filtre,"/",nomProtocole,"/",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
446 # }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
447 # nomRep <- paste("resultats/",col_filtre,"/",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
448 # }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
449 d.autre <- d
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
450 d.autre$groupe <- nomGenerique
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
451 d.reseau <- subset(d,groupe %in% lesModalites)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
452 ggTable <- rbind(d.autre,d.reseau)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
453 ggTableResum <- aggregate(cbind(ordonnee, abscisse) ~ groupe, data = ggTable,quantile, c(.25,.5,.75))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
454 ggTableResum <- data.frame(ggTableResum[,1],ggTableResum[,2][,1:3],ggTableResum[,3][,1:3])
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
455 colnames(ggTableResum) <- c("groupe","ordonnee.inf","ordonnee.med","ordonnee.sup","abscisse.inf","abscisse.med","abscisse.sup")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
456 ggSeuil <- aggregate(ordonnee ~ groupe, data=ggTable,length)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
457 ggSeuil$seuilResum <- ggSeuil$ordonnee >= seuilSegment
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
458 colnames(ggSeuil)[ncol(ggSeuil)] <- "seuil"
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
459 ggTableResum <- merge(ggTableResum,ggSeuil,by="groupe")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
460 t_figure_couleur <- subset(tab_figure_couleur,Modalite %in% c(nomGenerique,lesModalites))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
461 modaliteSansCouleur <- lesModalites[(!(lesModalites %in% t_figure_couleur$Modalite))]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
462 nbNxCol <- length(modaliteSansCouleur)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
463 mypalette<-brewer.pal(nbNxCol,"YlGnBu")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
464 figure_couleur <- setNames(c(as.character(t_figure_couleur$couleur),mypalette),c(as.character(t_figure_couleur$Modalite),modaliteSansCouleur))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
465 tab_coul <- data.frame(groupe=names(figure_couleur),couleur=figure_couleur)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
466 tab_coul <- merge(tab_coul,ggTableResum,"groupe")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
467 tab_coul$nom <- paste(tab_coul$groupe," (",tab_coul$ordonnee,")",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
468 figure_couleur <- setNames(as.character(tab_coul$couleur),tab_coul$groupe)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
469 figure_couleur_nom<- tab_coul$nom
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
470 gg <- ggplot(ggTable,aes(x=abscisse,y=ordonnee,colour=groupe,fill=groupe))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
471 if(bagplot){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
472 gg <- gg + stat_bag(data=d.autre,prop=bagProp[1],colour=NA,alpha=.7) + stat_bag(data=d.autre,prop=bagProp[2],colour=NA,alpha=.4) + stat_bag(data=d.autre,prop=bagProp[3],colour=NA,alpha=.2)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
473 }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
474 gg <- gg + geom_point(alpha=.2)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
475 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
476 gg <- gg + geom_hline(data=subset(ggTableResum,groupe=="Autre"),aes(yintercept = ordonnee.med,colour=groupe),size=.5,linetype="dashed") + geom_vline(data=subset(ggTableResum,groupe=="Autre"),aes(xintercept = abscisse.med,colour=groupe),size=.5,linetype="dashed")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
477 gg <- gg + geom_segment(data=ggTableResum,aes(x = abscisse.med, y = ordonnee.inf, xend = abscisse.med, yend = ordonnee.sup),alpha=.7,size = 2.5)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
478 gg <- gg + geom_segment(data=ggTableResum,aes(x = abscisse.inf, y = ordonnee.med, xend = abscisse.sup, yend = ordonnee.med),alpha=.7,size = 2.5)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
479 if(any(ggTableResum$seuil)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
480 gg <- gg + geom_segment(data=subset(ggTableResum,!(seuil)),aes(x = abscisse.med, y = ordonnee.inf, xend = abscisse.med, yend = ordonnee.sup),alpha=.5,size = 1.5,colour="white")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
481 gg <- gg + geom_segment(data=subset(ggTableResum,!(seuil)),aes(x = abscisse.inf, y = ordonnee.med, xend = abscisse.sup, yend = ordonnee.med),alpha=.5,size = 1.5,colour="white")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
482 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
483
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
484 #browser() # gg <- gg + geom_point(data=d.reseau,size=2)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
485 gg <- gg + scale_colour_manual(values = figure_couleur,name = "",labels = figure_couleur_nom) + scale_fill_manual(values = figure_couleur,name = "",guide=FALSE)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
486 gg <- gg + labs(list(title=figure_titre,x=figure_abscisse,y=figure_ordonnee))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
487 if(!is.null(colourProtocole)){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
488 gg <- gg + theme(legend.justification=c(1,0), legend.position=c(1,0),legend.text = element_text(size = 7),legend.background = element_rect(fill=NA), axis.ticks = element_line(colour = colourProtocole, size = 1), axis.ticks.length = unit(0.3, "cm"),plot.title = element_text(colour = colourProtocole))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
489 }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
490 gg <- gg + theme(legend.justification=c(1,0), legend.position=c(1,0),legend.text = element_text(size = 7),legend.background = element_rect(fill=NA))
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
491 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
492 ggfile <- paste(nomRep,nomProtocole,"_",col_filtre,"_","comparaison.png",sep="")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
493 cat("Check",ggfile,":")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
494 ggsave(ggfile,gg)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
495 cat("\n")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
496 flush.console()
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
497 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
498
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
499
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
500 #########################################
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
501
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
502 #Lancement des fonctions :
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
503
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
504 #Variables a definir :
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
505
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
506 #filename="BDD_PAPILLONS_2016.txt"
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
507 #color_filename<-"code_couleurs.csv"
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
508
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
509 #func
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
510 #func="ggCompareLevel"
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
511 #func="ggfiltre1niveau"
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
512 #func="gglocal"
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
513
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
514 #colSousGroupe
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
515 #col_sousGroup_usr = NULL #ggfiltre #ggCompareLevel
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
516 #col_sousGroup_usr = "PARCELLENOM" #gglocal
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
517
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
518 #vec_col_filtre_usr
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
519 #vec_col_filtre_usr = c("CONDUITEPARCELLE") #ggCompareLevel
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
520 #vec_col_filtre_usr = c("REGION") #ggfiltre
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
521 #vec_col_filtre_usr = c("NOM_RESEAU") #gglocal
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
522
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
523
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
524
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
525 #Exe fonction :
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
526
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
527 #filtre1niveau(func=func,nom_fichier=filename,nom_fichierCouleur=color_filename,col_sousGroup=NULL) #ggfiltre ou ggCompareLevel, depend de func et de vec_col_filtre_usr
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
528 #filtre1niveau(func=func,nom_fichier=filename,nom_fichierCouleur=color_filename,col_sousGroup = col_sousGroup_usr,vec_col_filtre=vec_col_filtre_usr) ## ==local
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
529
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
530 ########################################################
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
531
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
532 filename=args[2]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
533 color_filename=args[3]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
534 func=args[4]
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
535
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
536 if(func=="ggCompareLevel"){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
537 col_sousGroup_usr=NULL
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
538 vec_col_filtre_usr=c("CONDUITEPARCELLE")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
539 }else if(func=="ggfiltre1niveau"){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
540 col_sousGroup_usr=NULL
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
541 vec_col_filtre_usr=c("REGION")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
542 }else if(func=="gglocal"){
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
543 col_sousGroup_usr="PARCELLENOM"
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
544 vec_col_filtre_usr=c("NOM_RESEAU")
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
545 }else{
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
546 #sortie erreur
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
547 write("Error, unknown function. Exit(1).", stderr())
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
548 q('no')
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
549 }
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
550
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
551 #create result dir
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
552 nomRep="resultats/"
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
553 dir.create(file.path(".", nomRep), showWarnings = FALSE)
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
554
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
555
af2cdd97a434 Uploaded
mnhn65mo
parents:
diff changeset
556 filtre1niveau(func=func,nom_fichier=filename,nom_fichierCouleur=color_filename,col_sousGroup=col_sousGroup_usr,vec_col_filtre=vec_col_filtre_usr)