# \donttest{
data("combination_tests_delayed")
combination_tests_delayed |>
results_pivot_longer() |>
head()
# }
# \donttest{
library("ggplot2")
library("patchwork")
data("combination_tests_delayed")
results_long <- results_pivot_longer(combination_tests_delayed)
# plot the rejection rate of two methods
combined_plot(
results_long,
c("logrank", "mwlrt", "maxcombo"),
c("hr", "n_pat_design", "delay", "hazard_ctrl", "recruitment"),
"rejection_0.025",
grid_level=2
)
# use custom colour and shape scales
# this can be used to group methods by shape or colour
# this is also helpful if methods should have the same aesthetics across plots
my_colours <- c(
logrank="black",
mwlrt="blue",
maxcombo="green"
)
my_shapes <- c(
logrank=1,
mwlrt=2,
maxcombo=2
)
combined_plot(
results_long,
c("logrank", "mwlrt", "maxcombo"),
c("hr", "n_pat_design", "delay", "hazard_ctrl", "recruitment"),
"rejection_0.025",
grid_level=2,
use_colours = my_colours,
use_shapes = my_shapes
)
# if one has a dataset of metadata with categories of methods
# one could uses those two definitions
# colours for methods, same shapes for methods of same category
metadata <- data.frame(
method = c("logrank", "mwlrt", "maxcombo"),
method_name = c("logrank test", "modestly weighed logrank test", "maxcombo test"),
category = c("logrank test", "combination test", "combination test")
)
my_colours <- ggplot2::scale_colour_discrete()$palette(n=nrow(metadata)) |>
sample() |>
setNames(metadata$method)
my_shapes <- metadata$category |>
as.factor() |>
as.integer() |>
setNames(metadata$method)
combined_plot(
results_long,
c("logrank", "mwlrt", "maxcombo"),
c("hr", "n_pat_design", "delay", "hazard_ctrl", "recruitment"),
"rejection_0.025",
grid_level=2,
use_colours = my_colours,
use_shapes = my_shapes
)
# }
Run the code above in your browser using DataLab