Nothing
make_followup_plot_fit <- function(seed = 711) {
raw <- simulate_tls(family = "binomial", CTmax = 36, z = 4, seed = seed)
standardized <- standardize_data(
raw, temp = "temp", duration = "duration", n_total = "total",
n_surv = "survived", duration_unit = "minutes"
)
fit_4pl(standardized, family = "binomial", t_ref = 60, quiet = TRUE)
}
test_that("plot_tdt_curve accepts threshold and panel compatibility arguments", {
fit <- make_followup_plot_fit()
p_alias <- plot_tdt_curve(fit, target_surv = "absolute")
p_numeric <- plot_tdt_curve(fit, p = 0.5)
expect_equal(ggplot2::ggplot_build(p_alias)$data,
ggplot2::ggplot_build(p_numeric)$data)
p_linear <- plot_tdt_curve(fit, target_surv = "relative", panels = "linear")
p_log <- plot_tdt_curve(fit, target_surv = "relative", panels = "log")
expect_s3_class(p_linear, "ggplot")
expect_s3_class(p_log, "ggplot")
expect_false(any(vapply(p_linear$scales$scales,
function(s) "y" %in% s$aesthetics &&
identical(s$trans$name, "log-10"), logical(1))))
expect_true(any(vapply(p_log$scales$scales,
function(s) "y" %in% s$aesthetics &&
identical(s$trans$name, "log-10"), logical(1))))
p_both <- plot_tdt_curve(fit, panels = "both", colour = "#146C7C")
if (requireNamespace("patchwork", quietly = TRUE)) {
expect_s3_class(p_both, "patchwork")
} else {
expect_named(p_both, c("linear", "log"))
}
expect_error(plot_tdt_curve(fit, p = 0.5, target_surv = "absolute"),
"not both")
expect_error(plot_tdt_curve(fit, target_surv = "invalid"),
"relative.*absolute")
})
test_that("a fixed TDT line colour keeps grouped curves separate", {
raw_a <- simulate_tls(family = "binomial", CTmax = 34, z = 4, seed = 712)
raw_b <- simulate_tls(family = "binomial", CTmax = 38, z = 4, seed = 713)
raw_a$group <- "A"
raw_b$group <- "B"
standardized <- standardize_data(
rbind(raw_a, raw_b), temp = "temp", duration = "duration",
n_total = "total", n_surv = "survived", duration_unit = "minutes"
)
fit <- fit_4pl(standardized, by = "group", family = "binomial",
t_ref = 60, quiet = TRUE)
plotted <- plot_tdt_curve(
fit, panels = "linear", colour = "#146C7C", temps = c(34, 36, 38)
)
built <- ggplot2::ggplot_build(plotted)$data[[1]]
expect_length(unique(built$group), 2L)
expect_equal(as.integer(table(built$group)), c(3L, 3L))
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.