changeset 1:8a1b524ed9d8 draft

planemo upload for repository https://github.com/bernt-matthias/mb-galaxy-tools/tools/tox_tools/baseline_calculator commit dca5f947ae4c9697ac0cfce0b313170b541124e5
author ufz
date Tue, 08 Oct 2024 12:41:07 +0000
parents 082e9d22c38d
children c122403ac78a
files dose_response.R dose_response.xml test-data/drc_EC_output.tsv test-data/drc_input.tsv test-data/test_summary.csv test-data/test_summary.tsv
diffstat 6 files changed, 34 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/dose_response.R	Mon Jun 10 11:57:52 2024 +0000
+++ b/dose_response.R	Tue Oct 08 12:41:07 2024 +0000
@@ -45,10 +45,14 @@
             plot.background = element_rect(fill = "white", color = NA)
         )
 
-    ggsave(filename = plot_file, plot = p, device = "jpg")
+    jpeg(filename = plot_file)
+    print(p)
+    dev.off()
 }
 
 dose_response_analysis <- function(data, concentration_col, response_col, plot_file, ec_file) {
+    concentration_col <- colnames(data)[as.integer(concentration_col)]
+    response_col <- colnames(data)[as.integer(response_col)]
     models <- fit_models(data, concentration_col, response_col)
     best_model_info <- select_best_model(models)
     ec_values <- calculate_ec_values(best_model_info$model)
@@ -59,7 +63,7 @@
         EC25 = ec_values$EC25[1],
         EC50 = ec_values$EC50[1]
     )
-    write.csv(ec_data, ec_file, row.names = FALSE)
+    write.table(ec_data, ec_file, sep = "\t", row.names = FALSE, col.names = TRUE, quote = FALSE)
 
     return(list(best_model = best_model_info$name, ec_values = ec_values))
 }
@@ -72,5 +76,5 @@
 plot_file <- args[4]
 ec_file <- args[5]
 
-data <- read.csv(data_file, header = TRUE)
+data <- read.csv(data_file, header = TRUE, sep = "\t")
 dose_response_analysis(data, concentration_col, response_col, plot_file, ec_file)
--- a/dose_response.xml	Mon Jun 10 11:57:52 2024 +0000
+++ b/dose_response.xml	Tue Oct 08 12:41:07 2024 +0000
@@ -1,8 +1,8 @@
 <tool id="dr_curve" name="Dose Response Curve for Toxicological Risk Assessment" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="23.0">
-    <description>Toxicity prediction tool - Dose response Curve</description>
+    <description>for Toxicological Risk Assessment</description>
     <macros>
-        <token name="@TOOL_VERSION@">3.0_1</token>
-        <token name="@VERSION_SUFFIX@">0</token>
+        <token name="@TOOL_VERSION@">3.0.1</token>
+        <token name="@VERSION_SUFFIX@">1</token>
     </macros>
     <creator>
         <organization name="Helmholtz Centre for Environmental Research - UFZ, Department of Ecotoxicology"
@@ -15,7 +15,7 @@
     </requirements>
     <command detect_errors="aggressive">
         <![CDATA[
-        Rscript $__tool_directory__/dose_response.R
+        Rscript '$__tool_directory__'/dose_response.R
             '$input_csv'
             '$concentration_column'
             '$response_column'
@@ -26,7 +26,7 @@
     <inputs>
         <param name="input_csv" type="data" format="tabular" label="Concentration - Response Tabular Input"/>
         <param name="concentration_column" type="data_column" data_ref="input_csv" label="Concentration Column" help="Name of the column for concentration values"/>
-        <param name="response_column" type="data_column" label="Response Column" help="Name of the column for response values"/>
+        <param name="response_column" type="data_column" data_ref="input_csv" label="Response Column" help="Name of the column for response values"/>
     </inputs>
     <outputs>
         <data name="plot_output" format="jpg" label="Dose Response Plot"/>
@@ -34,22 +34,27 @@
     </outputs>
         <tests>
         <test>
-            <param name="input_csv" value="test_summary.tsv"/>
-            <param name="concentration_column" value="concentration"/>
-            <param name="response_column" value="lethal"/>
-            <output name="plot_output" value="result.jpeg" ftype="jpg"/>
-            <output name="ec_output" value="results_EC.csv" ftype="csv" />
+            <param name="input_csv" value="drc_input.tsv"/>
+            <param name="concentration_column" value="1"/>
+            <param name="response_column" value="2"/>
+            <output name="plot_output" ftype="jpg">
+                <assert_contents>
+                    <has_image_width width="480"/>
+                    <has_image_height height="480"/>
+                </assert_contents>
+            </output>
+            <output name="ec_output" value="drc_EC_output.tsv" ftype="tabular" />
         </test>
     </tests>
     <help><![CDATA[
         This tool performs dose-response analysis on the provided CSV file,
         generates a dose-response plot, and calculates EC values (EC10, EC25, EC50).
 
-        - `input_csv`: A CSV file containing the dose-response data.
+        - `input_csv`: A TSV file containing the dose-response data.
         - `concentration_column`: The name of the column in the CSV file that contains the concentration values.
         - `response_column`: The name of the column in the CSV file that contains the response values
         - `plot_output`: A JPG image file of the dose-response plot.
-        - `ec_output`: A CSV file containing the calculated EC values.
+        - `ec_output`: A tabular file containing the calculated EC values.
     ]]></help>
         <citations>
     <citation type="doi">10.1371/journal.pone.0146021</citation>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/drc_EC_output.tsv	Tue Oct 08 12:41:07 2024 +0000
@@ -0,0 +1,2 @@
+EC10	EC25	EC50
+5.08340659604631	10.6579575265526	22.3456566952853
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/drc_input.tsv	Tue Oct 08 12:41:07 2024 +0000
@@ -0,0 +1,8 @@
+conc	resp
+0	0
+5	0.1
+10	0.3
+25	0.5
+50	0.6
+75	0.9
+100	1
--- a/test-data/test_summary.csv	Mon Jun 10 11:57:52 2024 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-lethal,concentration
-0,0
-0.1,10
-0.25,25
-0.5,50
-0.75,75
-1,100
--- a/test-data/test_summary.tsv	Mon Jun 10 11:57:52 2024 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-concentration	lethal
-0	0
-10	0.1
-25	0.2
-50	0.5
-75	0.7
-100	1