-
Notifications
You must be signed in to change notification settings - Fork 509
Expand file tree
/
Copy pathggplot2_barplot.xml
More file actions
142 lines (123 loc) · 7.11 KB
/
ggplot2_barplot.xml
File metadata and controls
142 lines (123 loc) · 7.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<tool id="ggplot2_barplot" name="Barplot w ggplot2" version="@TOOL_VERSION@+galaxy0" profile="23.0">
<description>Barplot visualization tool using ggplot2</description>
<macros>
<import>macros.xml</import>
</macros>
<expand macro="requirements">
<requirement type="package" version="1.3.2">r-tidyr</requirement>
<requirement type="package" version="24.0.0">r-arrow</requirement>
<requirement type="package" version="1.2.0">r-rlang</requirement>
</expand>
<required_files>
<include path="utils.r" />
</required_files>
<creator>
<person
givenName="Kristina"
familyName="Gomoryova"
url="https://github.com/KristinaGomoryova"
identifier="0000-0003-4407-3917" />
<person
givenName="Helge"
familyName="Hecht"
url="https://github.com/hechth"
identifier="0000-0001-6744-996X" />
<organization
url="https://www.recetox.muni.cz/"
email="GalaxyToolsDevelopmentandDeployment@space.muni.cz"
name="RECETOX MUNI" />
</creator>
<command detect_errors="exit_code"><![CDATA[
Rscript -e 'source("${__tool_directory__}/utils.r")' -e 'source("${run_script}")'
#if $export_R_script
&& cat ${run_script} >> $script
#end if
]]></command>
<configfiles>
<configfile name="run_script"><![CDATA[
file_name <- "$input_data"
file_extension <- "$input_data.ext"
data_input <- load_data(file_name, file_extension)
quant_col <- colnames(data_input)[$quant_col]
grouping_col <- colnames(data_input)[$grouping_col]
data_input[[grouping_col]] <- as.factor(data_input[[grouping_col]])
#if $color_col
color_col <- colnames(data_input)[$color_col]
data_input[[color_col]] <- as.factor(data_input[[color_col]])
#end if
plot_barplot <- ggplot2::ggplot(data_input,
ggplot2::aes(x = !!rlang::sym(grouping_col),
y = !!rlang::sym(quant_col),
#if $color_col
fill = !!rlang::sym(color_col)
#end if
)) +
ggplot2::geom_bar(stat="identity"
#if $position
, position = ggplot2::position_dodge()
#end if
) +
ggplot2::theme_bw()+
ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, hjust=1))
#if $xlab
plot_barplot <- plot_barplot + ggplot2::xlab("$xlab")
#end if
#if $ylab
plot_barplot <- plot_barplot + ggplot2::ylab("$ylab")
#end if
ggplot2::ggsave(filename = "barplot.png", plot_barplot)
]]></configfile>
</configfiles>
<inputs>
<param name="input_data" type="data" format="csv,tsv,txt,tabular,parquet" label="Input table in a long format" help= "Input file in a tabular/tsv/csv/parquet format"/>
<param name="quant_col" type="data_column" data_ref="input_data" use_header_names="true" label="Which column contains the quantitative information?" help="Select the column containing quantitative information."/>
<param name="grouping_col" type="data_column" data_ref="input_data" use_header_names="true" label="Which column contains the categories?" help="Select the column which contains the categories."/>
<param name="color_col" type="data_column" data_ref="input_data" use_header_names="true" optional="true" label="Which column to color according to?" help="Select the column which contains levels for color."/>
<param name="position" type="boolean" checked="false" truevalue="TRUE" falsevalue="FALSE" label="Use position dodge?" help="If a column for color is specified, should be the categories placed side-by-side or stacked (default)?"/>
<expand macro="axes_labels"/>
<expand macro="export_data"/>
</inputs>
<outputs>
<data name="barplot" format="png" label="Barplot on ${on_string}" from_work_dir="barplot.png"/>
<data name="script" format="txt" label="R script">
<filter>export_R_script</filter>
</data>
</outputs>
<tests>
<test expect_num_outputs="1">
<param name="input_data" value="barplot_test_data.txt"/>
<param name="quant_col" value="3"/>
<param name="grouping_col" value="4"/>
<output name="barplot" ftype="png">
<assert_contents>
<has_image_channels channels="1"/>
<has_image_height height="2100"/>
<has_image_width width="2100" />
<has_image_center_of_mass center_of_mass="1030.12, 1008.25" eps="0.1"/>
</assert_contents>
</output>
</test>
</tests>
<help><![CDATA[
recetox-barplot help
=====================
Overview
--------
recetox-barplot allows creating barplots from tabular/csv/parquet data. On the input, data in a long format are expected, meaning that each column represents a variable, each row represents an observation as shown below.
User has to define which column holds the quantitative information (e.g. counts for particular category) and which column contains the categories to be plotted. It is also possible to use another variable to color the bars. Finally, `Use position dodge?` parameter defines whether the bars will be stacked above each other (default behavior when set to FALSE) or will be placed side-by-side (when set to TRUE). If no color column is supplied, setting this parameter will have no effect on the resulting barplots.
Example barplot input
----------------------
+----------------------+-------------------+-----------------------+--------------------+
| SampleName | replicate | condition | Value |
+======================+===================+=======================+====================+
| sample1 | 1 | control | 20 |
+----------------------+-------------------+-----------------------+--------------------+
| sample2 | 1 | treatment | 40 |
+----------------------+-------------------+-----------------------+--------------------+
| sample3 | 2 | treatment | 10 |
+----------------------+-------------------+-----------------------+--------------------+
| ... | ... | ... | ... |
+----------------------+-------------------+-----------------------+--------------------+
]]></help>
<expand macro="citations" />
</tool>