Skip to content
Snippets Groups Projects
Commit 0f474df3 authored by Sebastian Henz's avatar Sebastian Henz
Browse files

Resolve TODOs and FIXMEs in plotting functions,

closes #20
parent 162d8533
No related branches found
No related tags found
1 merge request!3V2.0
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* New function `predict_ecxsys()` replaces `fn()` from the `ecxsys` output. * New function `predict_ecxsys()` replaces `fn()` from the `ecxsys` output.
* Renamed the arguments in `ec()`. * Renamed the arguments in `ec()`.
* Made `ec()` more flexible. It now also accepts a data.frame with a concentration column and a column of response values. * Made `ec()` more flexible. It now also accepts a data.frame with a concentration column and a column of response values.
* Mention LL5 curves in legend of `plot_effect()`.
* Improved the internal structure of the package. * Improved the internal structure of the package.
* Improved the tests. * Improved the tests.
* Improved documentation. * Improved documentation.
......
...@@ -12,7 +12,7 @@ plot_effect <- function(model, ...@@ -12,7 +12,7 @@ plot_effect <- function(model,
) )
curves <- temp$curves curves <- temp$curves
log_ticks <- get_log_ticks(curves$concentration) log_ticks <- get_log_ticks(curves$concentration)
model$args$concentration[1] <- curves$concentration[1] concentration <- c(curves$concentration[1], model$args$concentration[-1])
plot( plot(
NA, NA,
...@@ -26,18 +26,19 @@ plot_effect <- function(model, ...@@ -26,18 +26,19 @@ plot_effect <- function(model,
bty = "L", bty = "L",
las = 1 las = 1
) )
if (show_simple_model) { if (show_simple_model) {
lines( lines(
curves$concentration, curves$concentration,
curves$effect_tox_simple, curves$effect_tox_simple,
col = rgb(112, 112, 207, maxColorValue = 255), col = "darkblue",
lty = 4 lty = 4
) )
if (model$with_env) { if (model$with_env) {
lines( lines(
curves$concentration, curves$concentration,
curves$effect_tox_env_simple, curves$effect_tox_env_simple,
col = rgb(207, 112, 112, maxColorValue = 255), col = "darkred",
lty = 4 lty = 4
) )
} }
...@@ -48,63 +49,59 @@ plot_effect <- function(model, ...@@ -48,63 +49,59 @@ plot_effect <- function(model,
curves$effect_tox_sys, curves$effect_tox_sys,
col = "blue" col = "blue"
) )
if (model$with_env) {
lines(
curves$concentration,
curves$effect_tox_env_sys,
col = "red"
)
}
lines( lines(
curves$concentration, curves$concentration,
curves$effect_tox, curves$effect_tox,
col = "deepskyblue", col = "deepskyblue",
lty = 2 lty = 2
) )
points(
concentration,
model$args$effect_tox_observed,
pch = 16,
col = "blue"
)
if (model$with_env) { if (model$with_env) {
lines(
curves$concentration,
curves$effect_tox_env_sys,
col = "red"
)
lines( lines(
curves$concentration, curves$concentration,
curves$effect_tox_env, curves$effect_tox_env,
col = "orange", col = "orange",
lty = 2 lty = 2
) )
}
points(
model$args$concentration,
model$args$effect_tox_observed,
pch = 16,
col = "blue"
)
if (model$with_env) {
# TODO: merge this with the same condition above.
points( points(
model$args$concentration, concentration,
model$args$effect_tox_env_observed, model$args$effect_tox_env_observed,
pch = 16, pch = 16,
col = "red" col = "red"
) )
} }
axis(1, at = log_ticks$major, labels = log_ticks$major_labels) axis(1, at = log_ticks$major, labels = log_ticks$major_labels)
axis(1, at = log_ticks$minor, labels = FALSE, tcl = -0.25) axis(1, at = log_ticks$minor, labels = FALSE, tcl = -0.25)
plotrix::axis.break(1, breakpos = temp$axis_break_conc) plotrix::axis.break(1, breakpos = temp$axis_break_conc)
if (show_legend) { if (show_legend) {
# TODO: Maybe do proper subscript in legend legend_text <- c("tox", "tox + sys")
# TODO: Add simple models to the legend legend_pch <- c(NA, 16)
legend_text <- c( legend_lty <- c(2, 1)
"effect (tox+sys)", legend_col <- c("deepskyblue", "blue")
"effect (tox+env+sys)", if (model$with_env) {
"toxicant effect", legend_text <- c(legend_text, "tox + env", "tox + env + sys")
"tox_env effect" legend_pch <- c(legend_pch, NA, 16)
) legend_lty <- c(legend_lty, 2, 1)
legend_pch <- c(16, 16, NA, NA) legend_col <- c(legend_col, "orange", "red")
legend_lty <- c(1, 1, 2, 2) }
legend_col <- c("blue", "red", "deepskyblue", "orange") if (show_simple_model) {
if (!model$with_env) { legend_text <- c(legend_text, "tox (LL5)", "tox + env (LL5)")
keep <- c(1, 3) legend_pch <- c(legend_pch, NA, NA)
legend_text <- legend_text[keep] legend_lty <- c(legend_lty, 4, 4)
legend_pch <- legend_pch[keep] legend_col <- c(legend_col, "darkblue", "darkred")
legend_lty <- legend_lty[keep]
legend_col <- legend_col[keep]
} }
legend( legend(
"topright", "topright",
......
...@@ -9,8 +9,7 @@ plot_system_stress <- function(model, show_legend = FALSE) { ...@@ -9,8 +9,7 @@ plot_system_stress <- function(model, show_legend = FALSE) {
curves <- temp$curves curves <- temp$curves
axis_break_conc <- temp$axis_break_conc axis_break_conc <- temp$axis_break_conc
log_ticks <- get_log_ticks(curves$concentration) log_ticks <- get_log_ticks(curves$concentration)
# FIXME: Don't overwrite this arg. Make a new variable instead. concentration <- c(curves$concentration[1], model$args$concentration[-1])
model$args$concentration[1] <- curves$concentration[1]
plot( plot(
NA, NA,
...@@ -24,17 +23,19 @@ plot_system_stress <- function(model, show_legend = FALSE) { ...@@ -24,17 +23,19 @@ plot_system_stress <- function(model, show_legend = FALSE) {
las = 1, las = 1,
bty = "L" bty = "L"
) )
lines( lines(
curves$concentration, curves$concentration,
curves$sys_stress_tox, curves$sys_stress_tox,
col = "blue" col = "blue"
) )
points( points(
model$args$concentration, concentration,
model$sys_stress_tox, model$sys_stress_tox,
pch = 16, pch = 16,
col = "blue" col = "blue"
) )
if (model$with_env) { if (model$with_env) {
lines( lines(
curves$concentration, curves$concentration,
...@@ -42,25 +43,23 @@ plot_system_stress <- function(model, show_legend = FALSE) { ...@@ -42,25 +43,23 @@ plot_system_stress <- function(model, show_legend = FALSE) {
col = "red" col = "red"
) )
points( points(
model$args$concentration, concentration,
model$sys_stress_tox_env, model$sys_stress_tox_env,
pch = 16, pch = 16,
col = "red" col = "red"
) )
} }
axis(1, at = log_ticks$major, labels = log_ticks$major_labels) axis(1, at = log_ticks$major, labels = log_ticks$major_labels)
axis(1, at = log_ticks$minor, labels = FALSE, tcl = -0.25) axis(1, at = log_ticks$minor, labels = FALSE, tcl = -0.25)
plotrix::axis.break(1, breakpos = axis_break_conc) plotrix::axis.break(1, breakpos = axis_break_conc)
if (show_legend) { if (show_legend) {
legend_text <- c( legend_text <- c("tox")
# TODO: Maybe do proper subscript in legend legend_col <- c("blue")
"system stress (tox)", if (model$with_env) {
"system stress (tox+env)" legend_text <- c(legend_text, "tox + env")
) legend_col <- c(legend_col, "red")
legend_col <- c("blue", "red")
if (!model$with_env) {
legend_text <- legend_text[1]
legend_col <- legend_col[1]
} }
legend( legend(
"topright", "topright",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment