ADTTE
Introduction
This article provides a step-by-step explanation for creating an ADaM ADTTE
(Time-to-Event) dataset with common oncology endpoint parameters using key pharmaverse packages along with tidyverse components. ADTTE
datasets often involve calculating time-to-event variables for endpoints such as Overall Survival (OS) and Progression-Free Survival (PFS).
For the purpose of this example, we will use the ADSL
and ADRS_ONCO
datasets from pharmaverseadam.
Load Required Packages
First, we will load the necessary packages:
Load Specifications and Source Data
We will load our specification file into a metacore object to trace the dataset variables and attributes. Then, we will read the source data.
Define Event and Censoring Sources
We define event and censoring sources using the admiral::event_source()
and admiral::censor_source()
functions. This forms the basis for calculating time-to-event endpoints.
# Define event and censoring sources
death_event <- event_source(
dataset_name = "adrs",
filter = PARAMCD == "DEATH" & AVALC == "Y" & ANL01FL == "Y",
date = ADT,
set_values_to = exprs(
EVNTDESC = "Death",
SRCDOM = "ADRS",
SRCVAR = "ADT"
)
)
pd_event <- event_source(
dataset_name = "adrs",
filter = PARAMCD == "PD" & ANL01FL == "Y",
date = ADT,
set_values_to = exprs(
EVNTDESC = "Progressive Disease",
SRCDOM = "ADRS",
SRCVAR = "ADT"
)
)
lastalive_censor <- censor_source(
dataset_name = "adsl",
date = LSTALVDT,
set_values_to = exprs(
EVNTDESC = "Last Known Alive",
CNSDTDSC = "Last Known Alive Date",
SRCDOM = "ADSL",
SRCVAR = "LSTALVDT"
)
)
lasta_censor <- censor_source(
dataset_name = "adrs",
filter = PARAMCD == "LSTA" & ANL01FL == "Y",
date = ADT,
set_values_to = exprs(
EVNTDESC = "Progression Free Alive",
CNSDTDSC = "Last Tumor Assessment",
SRCDOM = "ADRS",
SRCVAR = "ADT"
)
)
rand_censor <- censor_source(
dataset_name = "adsl",
date = RANDDT,
set_values_to = exprs(
EVNTDESC = "Randomization Date",
CNSDTDSC = "Randomization Date",
SRCDOM = "ADSL",
SRCVAR = "RANDDT"
)
)
Derive Time-to-Event Parameters
The admiral::derive_param_tte()
function is used to derive parameters such as OS (Overall Survival) and PFS (Progression-Free Survival).
# Derive Overall Survival (OS)
adtte <- derive_param_tte(
dataset_adsl = adsl,
start_date = RANDDT,
event_conditions = list(death_event),
censor_conditions = list(lastalive_censor, rand_censor),
source_datasets = list(adsl = adsl, adrs = adrs),
set_values_to = exprs(PARAMCD = "OS", PARAM = "Overall Survival")
)
# Derive Progression-Free Survival (PFS)
adtte_pfs <- adtte %>%
derive_param_tte(
dataset_adsl = adsl,
start_date = RANDDT,
event_conditions = list(pd_event, death_event),
censor_conditions = list(lasta_censor, rand_censor),
source_datasets = list(adsl = adsl, adrs = adrs),
set_values_to = exprs(PARAMCD = "PFS", PARAM = "Progression-Free Survival")
)
Sample of Data
Derive Analysis Value (AVAL
)
The analysis value (AVAL
) can be derived by calling the admiral::derive_vars_duration()
function.
Sample of Data
Derive Analysis Sequence Number (ASEQ
)
We derive the sequence number for each record to uniquely identify them using the admiral::derive_var_obs_number()
function.
Add ADSL Variables
Additional variables from the ADSL
dataset are merged into the ADTTE
dataset using the admiral::derive_vars_merged()
function to enrich it.
Apply Metadata and eSub Checks
We use metatools and xportr to perform checks, apply metadata such as types, lengths, labels, and write the dataset to an XPT file.
# Apply metadata and perform checks
adtte_adsl_checked <- adtte_adsl %>%
add_variables(metacore) %>%
drop_unspec_vars(metacore) %>%
check_variables(metacore) %>%
check_ct_data(metacore) %>%
order_cols(metacore) %>%
sort_by_key(metacore)
# Apply apply labels, formats, and export the dataset to an XPT file.
adtte_final <- adtte_adsl_checked %>%
xportr_type(metacore, domain = "ADTTE") %>%
xportr_length(metacore) %>%
xportr_label(metacore) %>%
xportr_df_label(metacore)
# Write dataset to XPT file (optional)
dir <- tempdir()
xportr_write(adtte_final, file.path(dir, "adtte.xpt"))