KMG01
Kaplan-Meier Plot
Code
variables$strata <- c("STRATA1", "STRATA2")
plot <- g_km(
df = anl,
variables = variables,
control_surv = control_surv_timepoint(conf_level = 0.8),
xlab = "Time (Days)",
ylim = c(0, 1),
annot_coxph = TRUE,
control_coxph_pw = control_coxph(
pval_method = "wald",
ties = "breslow",
conf_level = 0.8
)
)
plot
Code
library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
ADSL <- random.cdisc.data::cadsl
ADTTE <- random.cdisc.data::cadtte
})
datanames <- c("ADSL", "ADTTE")
datanames(data) <- datanames
join_keys(data) <- default_cdisc_join_keys[datanames]
arm_ref_comp <- list(
ACTARMCD = list(
ref = "ARM B",
comp = c("ARM A", "ARM C")
),
ARM = list(
ref = "B: Placebo",
comp = c("A: Drug X", "C: Combination")
)
)
## Reusable Configuration For Modules
ADSL <- data[["ADSL"]]
ADTTE <- data[["ADTTE"]]
## Setup App
app <- init(
data = data,
modules = modules(
tm_g_km(
label = "KM PLOT",
plot_height = c(600, 100, 2000),
dataname = "ADTTE",
arm_var = choices_selected(
variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")),
"ARM"
),
paramcd = choices_selected(
value_choices(ADTTE, "PARAMCD", "PARAM"),
"OS"
),
arm_ref_comp = arm_ref_comp,
strata_var = choices_selected(
variable_choices(ADSL, c("SEX", "BMRKR2")),
"SEX"
),
facet_var = choices_selected(
variable_choices(ADSL, c("SEX", "BMRKR2")),
NULL
)
)
)
)
shinyApp(app$ui, app$server)
Experimental use!
shinylive
allow you to modify to run shiny
application entirely in the web browser. Modify the code below and click re-run the app to see the results. The performance is slighly worse and some of the features (e.g. downloading) might not work at all.
#| standalone: true
#| viewerHeight: 800
#| components: [viewer, editor]
#| layout: vertical
# -- WEBR HELPERS --
options(webr_pkg_repos = c("r-universe" = "https://pharmaverse.r-universe.dev", getOption("webr_pkg_repos")))
if (packageVersion("webr") < "0.3.0") {
.e <- as.environment("webr_shims")
.e[["library"]] <- function(pkg, ...) {
package <- as.character(substitute(pkg))
if (length(find.package(package, quiet = TRUE)) == 0) {
webr::install(package)
}
base::library(package, character.only = TRUE, ...)
}
}
# -- APP CODE --
library(teal.modules.clinical)
## Data reproducible code
data <- teal_data()
data <- within(data, {
ADSL <- random.cdisc.data::cadsl
ADTTE <- random.cdisc.data::cadtte
})
datanames <- c("ADSL", "ADTTE")
datanames(data) <- datanames
join_keys(data) <- default_cdisc_join_keys[datanames]
arm_ref_comp <- list(
ACTARMCD = list(
ref = "ARM B",
comp = c("ARM A", "ARM C")
),
ARM = list(
ref = "B: Placebo",
comp = c("A: Drug X", "C: Combination")
)
)
## Reusable Configuration For Modules
ADSL <- data[["ADSL"]]
ADTTE <- data[["ADTTE"]]
## Setup App
app <- init(
data = data,
modules = modules(
tm_g_km(
label = "KM PLOT",
plot_height = c(600, 100, 2000),
dataname = "ADTTE",
arm_var = choices_selected(
variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")),
"ARM"
),
paramcd = choices_selected(
value_choices(ADTTE, "PARAMCD", "PARAM"),
"OS"
),
arm_ref_comp = arm_ref_comp,
strata_var = choices_selected(
variable_choices(ADSL, c("SEX", "BMRKR2")),
"SEX"
),
facet_var = choices_selected(
variable_choices(ADSL, c("SEX", "BMRKR2")),
NULL
)
)
)
)
shinyApp(app$ui, app$server)
Timestamp
Session Info
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0
locale:
[1] C
time zone: Etc/UTC
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] teal.modules.clinical_0.9.1.9005 teal.transform_0.5.0.9005
[3] teal_0.15.2.9036 teal.slice_0.5.1.9002
[5] teal.data_0.6.0.9002 teal.code_0.5.0.9005
[7] shiny_1.8.1.1 nestcolor_0.1.2.9010
[9] dplyr_1.1.4 tern_0.9.4.9007
[11] rtables_0.6.7.9002 magrittr_2.0.3
[13] formatters_0.5.6.9004
loaded via a namespace (and not attached):
[1] tidyselect_1.2.1 farver_2.1.1
[3] fastmap_1.1.1 random.cdisc.data_0.3.15.9003
[5] TH.data_1.1-2 webshot2_0.1.1
[7] shinyjs_2.1.0 promises_1.3.0
[9] digest_0.6.35 estimability_1.5
[11] mime_0.12 tern.gee_0.1.3.9006
[13] lifecycle_1.0.4 survival_3.6-4
[15] processx_3.8.4 compiler_4.4.0
[17] sass_0.4.9 rlang_1.1.3
[19] tools_4.4.0 utf8_1.2.4
[21] yaml_2.3.8 knitr_1.46
[23] labeling_0.4.3 htmlwidgets_1.6.4
[25] multcomp_1.4-25 websocket_1.4.1
[27] withr_3.0.0 purrr_1.0.2
[29] shinyWidgets_0.8.6 geepack_1.3.10
[31] grid_4.4.0 fansi_1.0.6
[33] teal.logger_0.2.0.9002 xtable_1.8-4
[35] colorspace_2.1-0 ggplot2_3.5.1
[37] emmeans_1.10.1 scales_1.3.0
[39] MASS_7.3-60.2 cli_3.6.2
[41] mvtnorm_1.2-4 rmarkdown_2.26
[43] ragg_1.3.0 generics_0.1.3
[45] cachem_1.0.8 chromote_0.2.0
[47] stringr_1.5.1 splines_4.4.0
[49] formatR_1.14 vctrs_0.6.5
[51] webshot_0.5.5 Matrix_1.7-0
[53] sandwich_3.1-0 jsonlite_1.8.8
[55] callr_3.7.6 systemfonts_1.0.6
[57] teal.widgets_0.4.2.9011 testthat_3.2.1.1
[59] fontawesome_0.5.2 jquerylib_0.1.4
[61] tidyr_1.3.1 glue_1.7.0
[63] codetools_0.2-20 ps_1.7.6
[65] cowplot_1.1.3 stringi_1.8.3
[67] gtable_0.3.5 later_1.3.2
[69] shinycssloaders_1.0.0 munsell_0.5.1
[71] tibble_3.2.1 logger_0.3.0
[73] pillar_1.9.0 htmltools_0.5.8.1
[75] brio_1.1.5 R6_2.5.1
[77] textshaping_0.3.7 Rdpack_2.6
[79] evaluate_0.23 lattice_0.22-6
[81] rbibutils_2.2.16 backports_1.4.1
[83] memoise_2.0.1 broom_1.0.5
[85] teal.reporter_0.3.1.9005 bslib_0.7.0
[87] httpuv_1.6.15 Rcpp_1.0.12
[89] shinyvalidate_0.1.3 coda_0.19-4.1
[91] nlme_3.1-164 checkmate_2.3.1
[93] xfun_0.43 zoo_1.8-12
[95] pkgconfig_2.0.3
.lock
file
Download the .lock
file and use renv::restore()
on it to recreate environment used to generate this website.
Code
parent_file_path <- knitr::current_input(dir = TRUE)
book_root_dir <- parent_file_path
while (!file.exists(file.path(book_root_dir, "_quarto.yml"))) book_root_dir <- dirname(book_root_dir)
lock_path <- file.path(
"../../assets/www/lock",
paste0(
gsub(
file.path(book_root_dir, ""),
"",
gsub(
"\\.rmarkdown$",
"",
knitr::current_input(dir = TRUE)
)
),
".lock"
)
)
withr::with_options(
list(renv.verbose = FALSE),
renv::snapshot(parent_file_path, lockfile = lock_path, prompt = FALSE, force = TRUE)
)