-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tet01.qmd file and content according to template
- Loading branch information
Showing
1 changed file
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
--- | ||
title: TET1 | ||
subtitle: Time-to-Event Summary Tables | ||
--- | ||
|
||
------------------------------------------------------------------------ | ||
|
||
::: panel-tabset | ||
## Setup | ||
|
||
We will use the `synthetic_cdisc_data$adtte` data set from the `scda` package for the time-to-event summary table. | ||
We start by filtering the `adtte` data set for the overall survival observations, converting time of overall survival to months, creating new variables for event and non-event information and binarizing the `ARM` variable. | ||
|
||
```{r, message = FALSE} | ||
library(tern) | ||
library(dplyr) | ||
adtte <- scda::synthetic_cdisc_data("rcd_2022_06_27")$adtte %>% | ||
df_explicit_na() %>% | ||
filter( | ||
PARAMCD == "OS" | ||
) %>% | ||
mutate( | ||
AVAL = day2month(AVAL), | ||
AVALU = "Months", | ||
is_event = CNSR == 0, | ||
is_not_event = CNSR == 1, | ||
ARM_BIN = fct_collapse_only( | ||
ARM, | ||
CTRL = c("B: Placebo"), | ||
TRT = c("A: Drug X", "C: Combination") | ||
) | ||
) | ||
``` | ||
|
||
## Table | ||
|
||
This time-to-event summary table splits the columns by treatment arm using `split_cols_by()`, creates a summary for patients with and without event using `summarize_vars()`, summarizes survival time using `surv_time()` and summarizes the analysis from unstratified Cox Proportional Hazards models using `coxph_pairwise()`. | ||
|
||
```{r} | ||
lyt <- basic_table() %>% | ||
split_cols_by( | ||
var = "ARM_BIN", | ||
ref_group = "CTRL" | ||
) %>% | ||
add_colcounts() %>% | ||
summarize_vars( | ||
vars = "is_event", | ||
.stats = "count_fraction", | ||
.labels = c(count_fraction = "Patients with event (%)"), | ||
nested = FALSE, | ||
show_labels = "hidden" | ||
) %>% | ||
summarize_vars( | ||
vars = "is_not_event", | ||
.stats = "count_fraction", | ||
.labels = c(count_fraction = "Patients without event (%)"), | ||
nested = FALSE, | ||
show_labels = "hidden" | ||
) %>% | ||
surv_time( | ||
vars = "AVAL", | ||
var_labels = "Time to Event (months)", | ||
is_event = "is_event", | ||
table_names = "time_to_event" | ||
) %>% | ||
coxph_pairwise( | ||
vars = "AVAL", | ||
is_event = "is_event", | ||
var_labels = c("Unstratified Analysis"), | ||
control = control_coxph(pval_method = "log-rank"), | ||
table_names = "coxph_unstratified" | ||
) | ||
build_table(lyt, adtte) | ||
``` | ||
|
||
## Time-to-Event Summary Table with Stratified Analysis (TET1A) | ||
|
||
We can add the summary of an analysis with Cox Proportional Hazards models stratified by `SEX` to the table above using `coxph_pairwise()`. | ||
|
||
```{r} | ||
lyt2 <- lyt %>% | ||
coxph_pairwise( | ||
vars = "AVAL", | ||
is_event = "is_event", | ||
var_labels = c("Stratified Analysis"), | ||
strat = "SEX", | ||
control = control_coxph(pval_method = "log-rank"), | ||
table_names = "coxph_stratified" | ||
) | ||
build_table(lyt2, adtte) | ||
``` | ||
|
||
{{< include ../session_info.qmd >}} | ||
::: |