# Layout for post-baseline evaluable patient variables from adab dataset.lyt_adab <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM",split_fun = drop_split_levels ) %>%count_patients_with_flags("USUBJID",flag_variables ="ADPBLPFL",.stats ="count",table_names ="post_baseline" ) %>%count_patients_with_flags("USUBJID",flag_variables ="TI_ADA" )# Layout for treatment-induced patient variables from adab dataset.lyt_adab_ti <-basic_table(show_colcounts =TRUE) %>%split_cols_by("ACTARM",split_fun =keep_split_levels(levels(adab_ti$ACTARM)[-2]) # temp fix ) %>%count_patients_with_flags("USUBJID",flag_variables =c("Transient ADA", "Persistent ADA"),var_labels ="Treatment-induced ADA patients with",show_labels ="visible" ) %>%analyze_vars("Time to onset of ADA",.stats ="median",nested =FALSE,.labels =c(median ="Median time to onset of ADA (weeks)") ) %>%analyze_vars("Antibody titer units",.stats ="range",nested =FALSE,.labels =c(range ="ADA titer range (min - max)") )result_adab <-build_table(lyt_adab, df = adab, alt_counts_df = adsl)result_adab_ti <-build_table(lyt_adab_ti, df = adab_ti, alt_counts_df = adsl)# Combine tables.col_info(result_adab) <-col_info(result_adab_ti)result <-rbind( result_adab, result_adab_ti)main_title(result) <-paste("Summary of Patients with Treatment-Induced ADA, PK Population")subtitles(result) <-paste("Protocol:", unique(adab$PARCAT1)[1])main_footer(result) <-paste("ADA = Anti-Drug Antibodies (is also referred to as ATA, or Anti-Therapeutic Antibodies) Treatment-induced ADA = negative or missing baseline. ADA result(s) and at least one positive post-baseline ADA result. Transient ADA = ADA positive result detected (a) at only one post-baseline sampling timepoint (excluding last timepoint) OR (b) at 2 or more timepoints during treatment where the first and last ADA positive samples are separated by a period of < 16 weeks, irrespective of any negative samples in between. Persistent ADA = ADA positive result detected (a) at the last post-baseline sampling timepoint, OR (b) at 2 or more time points during treatment where the first and last ADA positive samples are separated by a period ≥ 16 weeks, irrespective of any negative samples in between.")result
Summary of Patients with Treatment-Induced ADA, PK Population
Protocol: A: Drug X Antibody
—————————————————————————————————————————————————————————————————
A: Drug X C: Combination
(N=134) (N=132)
—————————————————————————————————————————————————————————————————
Post-baseline evaluable patients 134 132
Treatment-induced ADA patients 38 (28.4%) 26 (19.7%)
Treatment-induced ADA patients with
Transient ADA 0 0
Persistent ADA 0 0
Median time to onset of ADA (weeks) 0.1 0.1
ADA titer range (min - max) NA NA
—————————————————————————————————————————————————————————————————
ADA = Anti-Drug Antibodies (is also referred to as ATA, or Anti-Therapeutic
Antibodies)
Treatment-induced ADA = negative or missing baseline.
ADA result(s) and at least one positive post-baseline ADA result.
Transient ADA = ADA positive result detected (a) at only one post-baseline
sampling timepoint (excluding last timepoint) OR (b) at 2 or more timepoints
during treatment where the first and last ADA positive samples are separated
by a period of < 16 weeks, irrespective of any negative samples in between.
Persistent ADA = ADA positive result detected (a) at the last post-baseline
sampling timepoint, OR (b) at 2 or more time points during treatment where
the first and last ADA positive samples are separated by a period ≥ 16
weeks, irrespective of any negative samples in between.
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
Code
library(tern)library(dplyr)adsl <- random.cdisc.data::cadsladab <- random.cdisc.data::cadab# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adsl <-df_explicit_na(adsl)adab <-df_explicit_na(adab) %>%mutate(ADPBLPFL ="Y") %>%# temp fixfilter( ADPBLPFL =="Y",!PARAM %in%c("NAB interpreted per sample result","NAB Status of a patient","Treatment enhanced ADA" ) ) %>%select(-PARAMCD, -AVALC, -AVALU, -ARRLT, -NRRLT) %>%unique() %>% tidyr::pivot_wider(names_from = PARAM,values_from = AVAL ) %>%mutate(across(any_of(c("Treatment induced ADA","Transient ADA","Persistent ADA" )), as.logical ) ) %>%mutate(ADPBLPFL = ADPBLPFL =="Y",TI_ADA =if (exists("Treatment induced ADA", where = .)) `Treatment induced ADA`elseFALSE ) %>%var_relabel(ADPBLPFL ="Post-baseline evaluable patients",TI_ADA ="Treatment-induced ADA patients" )adab_ti <- adab %>%filter(TI_ADA)
---title: ADAT02subtitle: Summary of Patients with Treatment-Induced ADA---------------------------------------------------------------------------{{< include ../../_utils/envir_hook.qmd >}}:::: {.panel-tabset}```{r setup, echo = FALSE}library(tern)library(dplyr)adsl <- random.cdisc.data::cadsladab <- random.cdisc.data::cadab# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adsl <- df_explicit_na(adsl)adab <- df_explicit_na(adab) %>% mutate(ADPBLPFL = "Y") %>% # temp fix filter( ADPBLPFL == "Y", !PARAM %in% c( "NAB interpreted per sample result", "NAB Status of a patient", "Treatment enhanced ADA" ) ) %>% select(-PARAMCD, -AVALC, -AVALU, -ARRLT, -NRRLT) %>% unique() %>% tidyr::pivot_wider( names_from = PARAM, values_from = AVAL ) %>% mutate( across( any_of(c( "Treatment induced ADA", "Transient ADA", "Persistent ADA" )), as.logical ) ) %>% mutate( ADPBLPFL = ADPBLPFL == "Y", TI_ADA = if (exists("Treatment induced ADA", where = .)) `Treatment induced ADA` else FALSE ) %>% var_relabel( ADPBLPFL = "Post-baseline evaluable patients", TI_ADA = "Treatment-induced ADA patients" )adab_ti <- adab %>% filter(TI_ADA)```## Standard Table::: {.panel-tabset .nav-justified group="webr"}## {{< fa regular file-lines sm fw >}} Preview```{r variant1, test = list(result_v1 = "result")}# Layout for post-baseline evaluable patient variables from adab dataset.lyt_adab <- basic_table(show_colcounts = TRUE) %>% split_cols_by( "ACTARM", split_fun = drop_split_levels ) %>% count_patients_with_flags( "USUBJID", flag_variables = "ADPBLPFL", .stats = "count", table_names = "post_baseline" ) %>% count_patients_with_flags( "USUBJID", flag_variables = "TI_ADA" )# Layout for treatment-induced patient variables from adab dataset.lyt_adab_ti <- basic_table(show_colcounts = TRUE) %>% split_cols_by( "ACTARM", split_fun = keep_split_levels(levels(adab_ti$ACTARM)[-2]) # temp fix ) %>% count_patients_with_flags( "USUBJID", flag_variables = c("Transient ADA", "Persistent ADA"), var_labels = "Treatment-induced ADA patients with", show_labels = "visible" ) %>% analyze_vars( "Time to onset of ADA", .stats = "median", nested = FALSE, .labels = c(median = "Median time to onset of ADA (weeks)") ) %>% analyze_vars( "Antibody titer units", .stats = "range", nested = FALSE, .labels = c(range = "ADA titer range (min - max)") )result_adab <- build_table(lyt_adab, df = adab, alt_counts_df = adsl)result_adab_ti <- build_table(lyt_adab_ti, df = adab_ti, alt_counts_df = adsl)# Combine tables.col_info(result_adab) <- col_info(result_adab_ti)result <- rbind( result_adab, result_adab_ti)main_title(result) <- paste( "Summary of Patients with Treatment-Induced ADA, PK Population")subtitles(result) <- paste("Protocol:", unique(adab$PARCAT1)[1])main_footer(result) <- paste( "ADA = Anti-Drug Antibodies (is also referred to as ATA, or Anti-Therapeutic Antibodies) Treatment-induced ADA = negative or missing baseline. ADA result(s) and at least one positive post-baseline ADA result. Transient ADA = ADA positive result detected (a) at only one post-baseline sampling timepoint (excluding last timepoint) OR (b) at 2 or more timepoints during treatment where the first and last ADA positive samples are separated by a period of < 16 weeks, irrespective of any negative samples in between. Persistent ADA = ADA positive result detected (a) at the last post-baseline sampling timepoint, OR (b) at 2 or more time points during treatment where the first and last ADA positive samples are separated by a period ≥ 16 weeks, irrespective of any negative samples in between.")result````r webr_code_labels <- c("setup", "variant1")`{{< include ../../_utils/webr.qmd >}}:::## Data Setup```{r setup}#| code-fold: show```::::{{< include ../../_utils/save_results.qmd >}}{{< include ../../repro.qmd >}}