# HG changeset patch
# User ufz
# Date 1737462360 0
# Node ID 2aa9da0a84a4b0f3336b097497a1977afb53b012
# Parent c122403ac78abb0c97d0b4a7fa5750c6119da1c2
planemo upload for repository https://github.com/Helmholtz-UFZ/galaxy-tools/tree/main/tools/tox_tools/dose_responses commit 707eca86fc2de2e563fb5c89889f54eb13f529d0
diff -r c122403ac78a -r 2aa9da0a84a4 dose_response.R
--- a/dose_response.R Wed Dec 18 09:11:40 2024 +0000
+++ b/dose_response.R Tue Jan 21 12:26:00 2025 +0000
@@ -26,7 +26,7 @@
return(list(EC50 = ec50, EC25 = ec25, EC10 = ec10))
}
-plot_dose_response <- function(model, data, ec_values, concentration_col, response_col, plot_file, compound_name, concentration_unit) {
+plot_dose_response <- function(model, data, ec_values, concentration_col, response_col, replicate_col, plot_file, compound_name, concentration_unit) {
# Generate a grid of concentration values for predictions
concentration_grid <- seq(min(data[[concentration_col]]), max(data[[concentration_col]]), length.out = 100)
prediction_data <- data.frame(concentration_grid)
@@ -40,19 +40,21 @@
print(prediction_data)
- data$rep <- factor(data$rep)
+ # Ensure replicate_col is treated as a factor
+ data[[replicate_col]] <- factor(data[[replicate_col]])
# Create the plot
p <- ggplot(data, aes_string(x = concentration_col, y = response_col)) +
- geom_point(aes(colour = rep)) + # Original data points
- geom_line(data = prediction_data, aes_string(x = "conc", y = "resp"), color = "blue") + # Predicted curve
- geom_ribbon(data = prediction_data, aes_string(x = "conc", ymin = "lower", ymax = "upper"), alpha = 0.2, fill = "blue") + # Confidence intervals
+ geom_point(aes_string(colour = replicate_col)) + # Original data points
+ geom_line(data = prediction_data, aes_string(x = concentration_col, y = response_col), color = "blue") + # Predicted curve
+ geom_ribbon(data = prediction_data, aes_string(x = concentration_col, ymin = "lower", ymax = "upper"), alpha = 0.2, fill = "blue") + # Confidence intervals
geom_vline(xintercept = ec_values$EC10[1], color = "green", linetype = "dashed") +
geom_vline(xintercept = ec_values$EC50[1], color = "red", linetype = "dashed") +
labs(
title = paste(compound_name, "- Dose-Response Curve"),
x = paste("Dose [", concentration_unit, "]"),
- y = "Response %"
+ y = "Response %",
+ colour = "Replicates"
) +
theme_minimal() +
theme(
@@ -66,10 +68,11 @@
dev.off()
}
-dose_response_analysis <- function(data, concentration_col, response_col, plot_file, ec_file, compound_name, concentration_unit) {
+dose_response_analysis <- function(data, concentration_col, response_col, replicate_col, plot_file, ec_file, compound_name, concentration_unit) {
# Ensure column names are correctly selected
concentration_col <- colnames(data)[as.integer(concentration_col)]
response_col <- colnames(data)[as.integer(response_col)]
+ replicate_col <- colnames(data)[as.integer(replicate_col)]
# Fit models and select the best one
models <- fit_models(data, concentration_col, response_col)
@@ -81,7 +84,7 @@
ec_values <- calculate_ec_values(best_model)
# Plot the dose-response curve
- plot_dose_response(best_model, data, ec_values, concentration_col, response_col, plot_file, compound_name, concentration_unit)
+ plot_dose_response(best_model, data, ec_values, concentration_col, response_col, replicate_col, plot_file, compound_name, concentration_unit)
# Get model summary and AIC value
model_summary <- summary(best_model)
@@ -108,11 +111,12 @@
data_file <- args[1]
concentration_col <- args[2]
response_col <- args[3]
-plot_file <- args[4]
-ec_file <- args[5]
-compound_name <- args[6]
-concentration_unit <- args[7]
+replicate_col <- args[4]
+plot_file <- args[5]
+ec_file <- args[6]
+compound_name <- args[7]
+concentration_unit <- args[8]
data <- read.csv(data_file, header = TRUE, sep = "\t")
print(data)
-dose_response_analysis(data, concentration_col, response_col, plot_file, ec_file, compound_name, concentration_unit)
+dose_response_analysis(data, concentration_col, response_col, replicate_col, plot_file, ec_file, compound_name, concentration_unit)
diff -r c122403ac78a -r 2aa9da0a84a4 dose_response.xml
--- a/dose_response.xml Wed Dec 18 09:11:40 2024 +0000
+++ b/dose_response.xml Tue Jan 21 12:26:00 2025 +0000
@@ -2,7 +2,7 @@
for Toxicological Risk Assessment
3.0.1
- 3
+ 4
+
^^[a-zA-Z0-9\[\]()_-]+$
@@ -45,6 +47,7 @@
+