Mercurial > repos > ecology > map_shp
annotate Bar_plot.R @ 0:ce9979488ebb draft default tip
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
author | ecology |
---|---|
date | Sat, 25 Nov 2023 15:18:33 +0000 |
parents | |
children |
rev | line source |
---|---|
0
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
1 #Script pour bar plot simple |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
2 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
3 #### loading required R libraries |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
4 #### chargement des packages R utilisés |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
5 library(ggplot2) |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
6 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
7 ###### overall parameters and settings |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
8 ###### paramètres globaux utilisés |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
9 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
10 args = commandArgs(trailingOnly=TRUE) |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
11 if (length(args)==0) |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
12 { |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
13 stop("This tool needs at least one argument") |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
14 }else{ |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
15 data <- args[1] |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
16 title <- as.character(args[2]) |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
17 error_bar <- args[3] |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
18 color <- as.character(args[4]) |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
19 ylab <- as.character(args[5]) |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
20 } |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
21 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
22 histo_data = read.table(data, header= T) |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
23 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
24 if (error_bar == "true"){ |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
25 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
26 ggplot(histo_data, aes(x = variable_name, y = variable, fill = variable_name)) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
27 geom_bar(stat = "identity", position = "dodge", fill = color) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
28 geom_errorbar(aes(ymin = variable - standard_deviation, ymax = variable + standard_deviation), |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
29 position = position_dodge(0.9), width = 0.25) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
30 geom_text(aes(label = variable), vjust = -2, color = "black", size = 4) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
31 ggtitle(title) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
32 ylab(ylab) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
33 theme_minimal()+ |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
34 theme(legend.position = "none", |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
35 axis.title.x = element_blank()) |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
36 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
37 ggsave("bar_plot.pdf", device = pdf, width = 20, height = 20, units = "cm") |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
38 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
39 }else{ |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
40 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
41 ggplot(histo_data, aes(x = variable_name, y = variable, fill = variable_name)) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
42 geom_bar(stat = "identity", position = "dodge", fill = color) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
43 geom_text(aes(label = variable), vjust = -1, color = "black", size = 4) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
44 ggtitle(title) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
45 ylab(ylab) + |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
46 theme_minimal()+ |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
47 theme(legend.position = "none", |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
48 axis.title.x = element_blank()) |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
49 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
50 ggsave("bar_plot.pdf", device = pdf, width = 20, height = 20, units = "cm")} |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
51 |
ce9979488ebb
planemo upload for repository https://github.com/galaxyecology/tools-ecology/tree/master/tools/Geom_mean_workflow commit 3f11e193fd9ba5bf0c706cd5d65d6398166776cb
ecology
parents:
diff
changeset
|
52 |