diff --git a/main/coverage-report/index.html b/main/coverage-report/index.html index b1403180..a526617a 100644 --- a/main/coverage-report/index.html +++ b/main/coverage-report/index.html @@ -95,7 +95,7 @@ font-size: 11px; }
names(tte_ipd) <- toupper(names(tte_ipd))
names(tte_pseudo_ipd) <- toupper(names(tte_pseudo_ipd))
trt_var_ipd <- toupper(trt_var_ipd)
trt_var_agd <- toupper(trt_var_agd)
# pre check
if (!"maicplus_estimate_weights" %in% class(weights_object)) {
}
if (!all(c("USUBJID", "TIME", "EVENT", trt_var_ipd) %in% names(tte_ipd))) {
}
if (!all(c("TIME", "EVENT", trt_var_agd) %in% names(tte_pseudo_ipd))) {
}
km_layout <- match.arg(km_layout, choices = c("all", "by_trial", "by_arm"), several.ok = FALSE)
# preparing data
is_anchored <- !is.null(trt_common)
tte_ipd <- tte_ipd[tte_ipd[[trt_var_ipd]] %in% c(trt_ipd, trt_common), , drop = FALSE]
tte_pseudo_ipd <- tte_pseudo_ipd[tte_pseudo_ipd[[trt_var_agd]] %in% c(trt_agd, trt_common), , drop = FALSE]
tte_ipd$weights <- weights_object$data$weights[match(weights_object$data$USUBJID, tte_ipd$USUBJID)]
tte_pseudo_ipd$weights <- 1
tte_ipd$TIME <- get_time_as(tte_ipd$TIME, as = time_scale)
tte_pseudo_ipd$TIME <- get_time_as(tte_pseudo_ipd$TIME, as = time_scale)
my_survfit <- function(data, weighted = FALSE) {
if (weighted) {
survfit(Surv(TIME, EVENT) ~ 1, data = data, conf.type = km_conf_type, weights = data$weights)
} else {
survfit(Surv(TIME, EVENT) ~ 1, data = data, conf.type = km_conf_type)
if (!is_anchored) {
basic_kmplot2(kmlist, kmlist_name, ...)
} else if (is_anchored) {
all_km <- list(
kmobj_A = my_survfit(data = tte_ipd[tte_ipd[, trt_var_ipd] == trt_ipd, ]),
kmobj_B = my_survfit(data = tte_pseudo_ipd[tte_pseudo_ipd[, trt_var_agd] == trt_agd, ]),
kmobj_A_adj = my_survfit(data = tte_ipd[tte_ipd[, trt_var_ipd] == trt_ipd, ], weighted = TRUE),
kmobj_C = my_survfit(data = tte_ipd[tte_ipd[, trt_var_ipd] == trt_common, ]),
kmobj_C_adj = my_survfit(data = tte_ipd[tte_ipd[, trt_var_ipd] == trt_common, ], weighted = TRUE),
kmobj_C_agd = my_survfit(data = tte_pseudo_ipd[tte_pseudo_ipd[, trt_var_agd] == trt_common, ])
kmlist_combined <- list()
if (km_layout %in% c("by_trial", "all")) {
kmlist_1_2 <- list(
setNames(
all_km[c(4, 1, 3, 5)],
c(trt_ipd, trt_common, paste0(trt_ipd, " (weighted)"), paste0(trt_common, " (weighted)"))
),
setNames(all_km[c(6, 2)], c(trt_common, trt_agd))
)
names(kmlist_1_2) <- c(
paste0("Kaplan-Meier Curves \n(", trt_ipd, " vs ", trt_common, ") in the IPD trial"),
paste0("Kaplan-Meier Curves \n(", trt_agd, " vs ", trt_common, ") in the AgD trial")
)
kmlist_combined <- c(kmlist_combined, kmlist_1_2)
}
if (km_layout %in% c("by_arm", "all")) {
}
if (km_layout == "all") {
splots <- mapply(
FUN = basic_kmplot2,
kmlist = kmlist_combined,
kmlist_name = lapply(kmlist_combined, names),
main_title = names(kmlist_combined),
MoreArgs = list(...),
SIMPLIFY = FALSE
)
survminer::arrange_ggsurvplots(splots, nrow = 1 + (km_layout == "all"))
if (is.null(use_line_types)) {
use_line_types <- c(1, 1, 2, 2)
if (is.null(use_colors)) {
use_colors <- c("#5450E4", "#00857C", "#6ECEB2", "#7B68EE")
# Produce the Kaplan-Meier plot
survminer_plot <- survminer::ggsurvplot(kmlist,
linetype = use_line_types,
palette = use_colors,
size = 0.2,
combine = TRUE,
risk.table = show_risk_set,
risk.table.y.text.col = TRUE,
risk.table.y.text = FALSE,
break.x.by = break_x_by,
censor = censor,
censor.size = 2,
xlab = "Time",
ylab = endpoint_name,
legend.title = "Treatment",
legend = c(0.85, 0.82),
title = paste0(main_title, "\nEndpoint: ", endpoint_name),
legend.labs = kmlist_name,
tables.theme = survminer::theme_cleantable(),
ggtheme = ggplot2::theme_classic(base_size = 10),
fontsize = 3,
conf.int = FALSE,
xlim = xlim
)
survminer_plot
factor <- match.arg(factor, several.ok = TRUE)
if (!exists("time_conversion", settings_env)) {
settings_env$time_conversion[factor]
as <- match.arg(as)
times / get_time_conversion(as)