Skip to content

Commit

Permalink
added tet01.qmd file and content according to template
Browse files Browse the repository at this point in the history
  • Loading branch information
moronip81 committed May 3, 2023
1 parent 397d3ee commit 91c2d05
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions tables/tet01.qmd
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 >}}
:::

0 comments on commit 91c2d05

Please sign in to comment.