Mercurial > repos > iuc > ggplot2_barplot
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ggplot2_barplot.xml Thu May 15 13:01:57 2025 +0000 @@ -0,0 +1,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.1">r-tidyr</requirement> + <requirement type="package" version="19.0.0">r-arrow</requirement> + <requirement type="package" version="1.1.5">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> \ No newline at end of file