h_survival_biomarkers_subgroups {tern} | R Documentation |
Helper functions for tabulating biomarker effects on survival by subgroup
Description
Helper functions which are documented here separately to not confuse the user when reading about the user-facing functions.
Usage
h_surv_to_coxreg_variables(variables, biomarker)
h_coxreg_mult_cont_df(variables, data, control = control_coxreg())
h_tab_surv_one_biomarker(
df,
vars,
time_unit,
na_str = default_na_str(),
.indent_mods = 0L,
...
)
Arguments
variables |
(named |
biomarker |
( |
data |
( |
control |
( |
df |
( |
vars |
(
|
time_unit |
( |
na_str |
( |
.indent_mods |
(named |
... |
additional arguments for the lower level functions. |
Value
-
h_surv_to_coxreg_variables()
returns a namedlist
of elementstime
,event
,arm
,covariates
, andstrata
.
-
h_coxreg_mult_cont_df()
returns adata.frame
containing estimates and statistics for the selected biomarkers.
-
h_tab_surv_one_biomarker()
returns anrtables
table object with the given statistics arranged in columns.
Functions
-
h_surv_to_coxreg_variables()
: Helps with converting the "survival" function variable list to the "Cox regression" variable list. The reason is that currently there is an inconsistency between the variable names accepted byextract_survival_subgroups()
andfit_coxreg_multivar()
. -
h_coxreg_mult_cont_df()
: Prepares estimates for number of events, patients and median survival times, as well as hazard ratio estimates, confidence intervals and p-values, for multiple biomarkers in a given single data set.variables
corresponds to names of variables found indata
, passed as a named list and requires elementstte
,is_event
,biomarkers
(vector of continuous biomarker variables) and optionallysubgroups
andstrata
. -
h_tab_surv_one_biomarker()
: Prepares a single sub-table given adf_sub
containing the results for a single biomarker.
Examples
library(dplyr)
library(forcats)
adtte <- tern_ex_adtte
# Save variable labels before data processing steps.
adtte_labels <- formatters::var_labels(adtte, fill = FALSE)
adtte_f <- adtte %>%
filter(PARAMCD == "OS") %>%
mutate(
AVALU = as.character(AVALU),
is_event = CNSR == 0
)
labels <- c("AVALU" = adtte_labels[["AVALU"]], "is_event" = "Event Flag")
formatters::var_labels(adtte_f)[names(labels)] <- labels
# This is how the variable list is converted internally.
h_surv_to_coxreg_variables(
variables = list(
tte = "AVAL",
is_event = "EVNT",
covariates = c("A", "B"),
strata = "D"
),
biomarker = "AGE"
)
# For a single population, estimate separately the effects
# of two biomarkers.
df <- h_coxreg_mult_cont_df(
variables = list(
tte = "AVAL",
is_event = "is_event",
biomarkers = c("BMRKR1", "AGE"),
covariates = "SEX",
strata = c("STRATA1", "STRATA2")
),
data = adtte_f
)
df
# If the data set is empty, still the corresponding rows with missings are returned.
h_coxreg_mult_cont_df(
variables = list(
tte = "AVAL",
is_event = "is_event",
biomarkers = c("BMRKR1", "AGE"),
covariates = "REGION1",
strata = c("STRATA1", "STRATA2")
),
data = adtte_f[NULL, ]
)
# Starting from above `df`, zoom in on one biomarker and add required columns.
df1 <- df[1, ]
df1$subgroup <- "All patients"
df1$row_type <- "content"
df1$var <- "ALL"
df1$var_label <- "All patients"
h_tab_surv_one_biomarker(
df1,
vars = c("n_tot", "n_tot_events", "median", "hr", "ci", "pval"),
time_unit = "days"
)