comparison Bar_plot.R @ 0:985f8839aebd 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:01 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:985f8839aebd
1 #Script pour bar plot simple
2
3 #### loading required R libraries
4 #### chargement des packages R utilisés
5 library(ggplot2)
6
7 ###### overall parameters and settings
8 ###### paramètres globaux utilisés
9
10 args = commandArgs(trailingOnly=TRUE)
11 if (length(args)==0)
12 {
13 stop("This tool needs at least one argument")
14 }else{
15 data <- args[1]
16 title <- as.character(args[2])
17 error_bar <- args[3]
18 color <- as.character(args[4])
19 ylab <- as.character(args[5])
20 }
21
22 histo_data = read.table(data, header= T)
23
24 if (error_bar == "true"){
25
26 ggplot(histo_data, aes(x = variable_name, y = variable, fill = variable_name)) +
27 geom_bar(stat = "identity", position = "dodge", fill = color) +
28 geom_errorbar(aes(ymin = variable - standard_deviation, ymax = variable + standard_deviation),
29 position = position_dodge(0.9), width = 0.25) +
30 geom_text(aes(label = variable), vjust = -2, color = "black", size = 4) +
31 ggtitle(title) +
32 ylab(ylab) +
33 theme_minimal()+
34 theme(legend.position = "none",
35 axis.title.x = element_blank())
36
37 ggsave("bar_plot.pdf", device = pdf, width = 20, height = 20, units = "cm")
38
39 }else{
40
41 ggplot(histo_data, aes(x = variable_name, y = variable, fill = variable_name)) +
42 geom_bar(stat = "identity", position = "dodge", fill = color) +
43 geom_text(aes(label = variable), vjust = -1, color = "black", size = 4) +
44 ggtitle(title) +
45 ylab(ylab) +
46 theme_minimal()+
47 theme(legend.position = "none",
48 axis.title.x = element_blank())
49
50 ggsave("bar_plot.pdf", device = pdf, width = 20, height = 20, units = "cm")}
51
52