Mercurial > repos > recetox > rcx_boxplot
comparison rcx_boxplot.xml @ 0:92325ed91115 draft default tip
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools commit 68159a987b0597222625834e235441b95e8c3a5e
author | recetox |
---|---|
date | Mon, 03 Feb 2025 16:18:52 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:92325ed91115 |
---|---|
1 <tool id="rcx_boxplot" name="recetox-boxplot" version="@TOOL_VERSION@+galaxy0" profile="23.0"> | |
2 <description>Boxplot visualization tool using ggplot2</description> | |
3 <macros> | |
4 <import>macros.xml</import> | |
5 <import>help.xml</import> | |
6 </macros> | |
7 | |
8 <expand macro="creator" /> | |
9 <expand macro="requirements" /> | |
10 | |
11 <command detect_errors="exit_code"><![CDATA[ | |
12 Rscript '${run_script}' | |
13 #if $export_R_script | |
14 && cat ${run_script} >> $script | |
15 #end if | |
16 ]]></command> | |
17 | |
18 <configfiles> | |
19 <configfile name="run_script"><![CDATA[ | |
20 | |
21 #if $input_data.ext == "csv" | |
22 data_input <- read.csv("$input_data", check.names = "false") | |
23 #else if $input_data.ext in ["tsv", "txt", "tabular"] | |
24 data_input <- read.delim("$input_data", sep="\t", check.names = "false") | |
25 #else if $input_data.ext == "parquet" | |
26 data_input <- arrow::read_parquet("$input_data") | |
27 #end if | |
28 | |
29 #if $has_rownames | |
30 rownames(data_input) <- data_input[, 1] | |
31 data_input <- data_input[ ,-1] | |
32 #end if | |
33 | |
34 y_colname <- "intensity" | |
35 data_long <- tidyr::pivot_longer(data_input, | |
36 cols = c(1:ncol(data_input)), | |
37 names_to = "samples", | |
38 values_to = y_colname) | |
39 | |
40 #if $transform_data == "replace_zero" | |
41 data_long[data_long == 0] <- NA | |
42 #else if $transform_data == "log2" | |
43 data_long[[y_colname]] <- log2(data_long[[y_colname]]) | |
44 #else if $transform_data == "log10" | |
45 data_long[[y_colname]] <- log10(data_long[[y_colname]]) | |
46 #end if | |
47 | |
48 #if $grouping_boxplot.use_grouping == "yes" | |
49 metadata_input <- read.delim("$grouping_boxplot.input_metadata", sep="\t", check.names = "false") | |
50 sampleID_column <- colnames(metadata_input)[$grouping_boxplot.sampleID] | |
51 plotting_column <- colnames(metadata_input)[$grouping_boxplot.groupingCol] | |
52 metadata_input <- data.frame(lapply(metadata_input, as.factor)) | |
53 | |
54 data_long <- dplyr::left_join(data_long, metadata_input, by = c("samples" = sampleID_column), keep = TRUE) | |
55 | |
56 #if $grouping_boxplot.facet_x | |
57 facet_x <- rlang::sym(colnames(metadata_input)[$grouping_boxplot.facet_x]) | |
58 #else | |
59 facet_x <- NULL | |
60 #end if | |
61 | |
62 #if $grouping_boxplot.facet_y | |
63 facet_y <- rlang::sym(colnames(metadata_input)[$grouping_boxplot.facet_y]) | |
64 #else | |
65 facet_y <- NULL | |
66 #end if | |
67 | |
68 plot_boxplot <- ggplot2::ggplot(data_long, ggplot2::aes( | |
69 x = !!rlang::sym(plotting_column), | |
70 y = intensity, | |
71 #if $grouping_boxplot.colorCol | |
72 fill = !!rlang::sym(colnames(metadata_input)[$grouping_boxplot.colorCol]) | |
73 #end if | |
74 )) + | |
75 ggplot2::geom_boxplot() + | |
76 ggplot2::theme_bw()+ | |
77 ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, hjust=1)) + | |
78 ggplot2::facet_grid(rows = if(!is.null(facet_y)) dplyr::vars(!!facet_y) else NULL, | |
79 cols = if(!is.null(facet_x)) dplyr::vars(!!facet_x) else NULL, | |
80 scales = "free") | |
81 | |
82 | |
83 #else | |
84 | |
85 plot_boxplot <- ggplot2::ggplot(data_long, ggplot2::aes(x = samples, y = intensity)) + | |
86 ggplot2::geom_boxplot() + | |
87 ggplot2::theme_bw()+ | |
88 ggplot2::theme(axis.text.x = ggplot2::element_text(angle = 45, hjust=1)) | |
89 | |
90 #end if | |
91 | |
92 #if $xlab | |
93 plot_boxplot <- plot_boxplot + ggplot2::xlab("$xlab") | |
94 #end if | |
95 | |
96 #if $ylab | |
97 plot_boxplot <- plot_boxplot + ggplot2::ylab("$ylab") | |
98 #end if | |
99 | |
100 #if $flip_axes == "true" | |
101 plot_boxplot <- plot_boxplot + ggplot2::coord_flip() | |
102 #end if | |
103 | |
104 ggplot2::ggsave(filename = "boxplot.png", plot_boxplot) | |
105 | |
106 ]]></configfile> | |
107 </configfiles> | |
108 | |
109 <inputs> | |
110 <expand macro="boxplot_param"/> | |
111 </inputs> | |
112 | |
113 <outputs> | |
114 <data name="boxplot" format="png" label="Boxplot on ${on_string}" from_work_dir="boxplot.png"/> | |
115 <data name="script" format="txt" label="R script"> | |
116 <filter>export_R_script</filter> | |
117 </data> | |
118 </outputs> | |
119 | |
120 <tests> | |
121 <test expect_num_outputs="1"> | |
122 <param name="input_data" value="test_data.txt"/> | |
123 <param name="has_rownames" value="true"/> | |
124 <output name="boxplot" ftype="png"> | |
125 <assert_contents> | |
126 <has_size size="1164615" delta="200"/> | |
127 </assert_contents> | |
128 </output> | |
129 </test> | |
130 <test expect_num_outputs="2"> | |
131 <param name="input_data" value="test_data.txt"/> | |
132 <param name="has_rownames" value="true"/> | |
133 <param name="use_grouping" value="yes"/> | |
134 <param name="input_metadata" value="test_expDesign.txt"/> | |
135 <param name="sampleID" value="1"/> | |
136 <param name="groupingCol" value="1"/> | |
137 <param name="export_R_script" value="TRUE"/> | |
138 <output name="boxplot" ftype="png"> | |
139 <assert_contents> | |
140 <has_size size="1164615" delta="200"/> | |
141 </assert_contents> | |
142 </output> | |
143 </test> | |
144 </tests> | |
145 | |
146 <help><![CDATA[ | |
147 @GENERAL_HELP@ | |
148 ]]></help> | |
149 | |
150 <expand macro="citations" /> | |
151 </tool> |