comparison ggplot2_barplot.xml @ 0:41e9114cc7cd draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ggplot2 commit 57b86418a4f032a5664b8dc1c9585a11be629158
author iuc
date Thu, 15 May 2025 13:01:57 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:41e9114cc7cd
1 <tool id="ggplot2_barplot" name="Barplot w ggplot2" version="@TOOL_VERSION@+galaxy0" profile="23.0">
2 <description>Barplot visualization tool using ggplot2</description>
3 <macros>
4 <import>macros.xml</import>
5 </macros>
6 <expand macro="requirements">
7 <requirement type="package" version="1.3.1">r-tidyr</requirement>
8 <requirement type="package" version="19.0.0">r-arrow</requirement>
9 <requirement type="package" version="1.1.5">r-rlang</requirement>
10 </expand>
11 <required_files>
12 <include path="utils.r" />
13 </required_files>
14 <creator>
15 <person
16 givenName="Kristina"
17 familyName="Gomoryova"
18 url="https://github.com/KristinaGomoryova"
19 identifier="0000-0003-4407-3917" />
20 <person
21 givenName="Helge"
22 familyName="Hecht"
23 url="https://github.com/hechth"
24 identifier="0000-0001-6744-996X" />
25 <organization
26 url="https://www.recetox.muni.cz/"
27 email="GalaxyToolsDevelopmentandDeployment@space.muni.cz"
28 name="RECETOX MUNI" />
29 </creator>
30
31 <command detect_errors="exit_code"><![CDATA[
32 Rscript -e 'source("${__tool_directory__}/utils.r")' -e 'source("${run_script}")'
33 #if $export_R_script
34 && cat ${run_script} >> $script
35 #end if
36 ]]></command>
37
38 <configfiles>
39 <configfile name="run_script"><![CDATA[
40 file_name <- "$input_data"
41 file_extension <- "$input_data.ext"
42 data_input <- load_data(file_name, file_extension)
43
44 quant_col <- colnames(data_input)[$quant_col]
45 grouping_col <- colnames(data_input)[$grouping_col]
46 data_input[[grouping_col]] <- as.factor(data_input[[grouping_col]])
47
48 #if $color_col
49 color_col <- colnames(data_input)[$color_col]
50 data_input[[color_col]] <- as.factor(data_input[[color_col]])
51 #end if
52
53 plot_barplot <- ggplot2::ggplot(data_input,
54 ggplot2::aes(x = !!rlang::sym(grouping_col),
55 y = !!rlang::sym(quant_col),
56 #if $color_col
57 fill = !!rlang::sym(color_col)
58 #end if
59 )) +
60 ggplot2::geom_bar(stat="identity"
61 #if $position
62 , position = ggplot2::position_dodge()
63 #end if
64 ) +
65 ggplot2::theme_bw()+
66 ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, hjust=1))
67
68 #if $xlab
69 plot_barplot <- plot_barplot + ggplot2::xlab("$xlab")
70 #end if
71
72 #if $ylab
73 plot_barplot <- plot_barplot + ggplot2::ylab("$ylab")
74 #end if
75
76 ggplot2::ggsave(filename = "barplot.png", plot_barplot)
77
78 ]]></configfile>
79 </configfiles>
80
81 <inputs>
82 <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"/>
83 <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."/>
84 <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."/>
85 <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."/>
86 <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)?"/>
87 <expand macro="axes_labels"/>
88 <expand macro="export_data"/>
89 </inputs>
90
91 <outputs>
92 <data name="barplot" format="png" label="Barplot on ${on_string}" from_work_dir="barplot.png"/>
93 <data name="script" format="txt" label="R script">
94 <filter>export_R_script</filter>
95 </data>
96 </outputs>
97
98 <tests>
99 <test expect_num_outputs="1">
100 <param name="input_data" value="barplot_test_data.txt"/>
101 <param name="quant_col" value="3"/>
102 <param name="grouping_col" value="4"/>
103 <output name="barplot" ftype="png">
104 <assert_contents>
105 <has_image_channels channels="1"/>
106 <has_image_height height="2100"/>
107 <has_image_width width="2100" />
108 <has_image_center_of_mass center_of_mass="1030.12, 1008.25" eps="0.1"/>
109 </assert_contents>
110 </output>
111 </test>
112 </tests>
113
114 <help><![CDATA[
115 recetox-barplot help
116 =====================
117
118 Overview
119 --------
120
121 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.
122
123 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.
124
125 Example barplot input
126 ----------------------
127
128 +----------------------+-------------------+-----------------------+--------------------+
129 | SampleName | replicate | condition | Value |
130 +======================+===================+=======================+====================+
131 | sample1 | 1 | control | 20 |
132 +----------------------+-------------------+-----------------------+--------------------+
133 | sample2 | 1 | treatment | 40 |
134 +----------------------+-------------------+-----------------------+--------------------+
135 | sample3 | 2 | treatment | 10 |
136 +----------------------+-------------------+-----------------------+--------------------+
137 | ... | ... | ... | ... |
138 +----------------------+-------------------+-----------------------+--------------------+
139 ]]></help>
140
141 <expand macro="citations" />
142 </tool>