Skip to contents

[Stable]

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 across population subgroups in a single data frame. variables corresponds to the names of variables found in data, passed as a named list and requires elements tte, is_event, biomarkers (vector of continuous biomarker variables), and optionally subgroups and strat. groups_lists optionally specifies groupings for subgroups variables.

Usage

extract_survival_biomarkers(
  variables,
  data,
  groups_lists = list(),
  control = control_coxreg(),
  label_all = "All Patients"
)

Arguments

variables

(named list of string)
list of additional analysis variables.

data

(data.frame)
the dataset containing the variables to summarize.

groups_lists

(named list of list)
optionally contains for each subgroups variable a list, which specifies the new group levels via the names and the levels that belong to it in the character vectors that are elements of the list.

control

(list)
a list of parameters as returned by the helper function control_coxreg().

label_all

(string)
label for the total population analysis.

Value

A data.frame with columns biomarker, biomarker_label, n_tot, n_tot_events, median, hr, lcl, ucl, conf_level, pval, pval_label, subgroup, var, var_label, and row_type.

See also

Examples

# Typical analysis of two continuous biomarkers `BMRKR1` and `AGE`,
# in multiple regression models containing one covariate `RACE`,
# as well as one stratification variable `STRATA1`. The subgroups
# are defined by the levels of `BMRKR2`.

library(dplyr)

adtte <- tern_ex_adtte
adtte_labels <- formatters::var_labels(adtte)

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

df <- extract_survival_biomarkers(
  variables = list(
    tte = "AVAL",
    is_event = "is_event",
    biomarkers = c("BMRKR1", "AGE"),
    strata = "STRATA1",
    covariates = "SEX",
    subgroups = "BMRKR2"
  ),
  data = adtte_f
)
df
#>   biomarker              biomarker_label n_tot n_tot_events   median        hr
#> 1    BMRKR1 Continuous Level Biomarker 1   200          141 753.5176 1.0010939
#> 2       AGE                          Age   200          141 753.5176 1.0106406
#> 3    BMRKR1 Continuous Level Biomarker 1    70           52 735.4722 0.9905065
#> 4       AGE                          Age    70           52 735.4722 1.0106279
#> 5    BMRKR1 Continuous Level Biomarker 1    68           42 858.9952 0.9623210
#> 6       AGE                          Age    68           42 858.9952 1.0360765
#> 7    BMRKR1 Continuous Level Biomarker 1    62           47 727.8043 1.0770946
#> 8       AGE                          Age    62           47 727.8043 1.0009890
#>         lcl      ucl conf_level      pval     pval_label     subgroup    var
#> 1 0.9538978 1.050625       0.95 0.9646086 p-value (Wald) All Patients    ALL
#> 2 0.9871004 1.034742       0.95 0.3787395 p-value (Wald) All Patients    ALL
#> 3 0.9142220 1.073156       0.95 0.8155443 p-value (Wald)          LOW BMRKR2
#> 4 0.9621192 1.061582       0.95 0.6735773 p-value (Wald)          LOW BMRKR2
#> 5 0.8708694 1.063376       0.95 0.4509368 p-value (Wald)       MEDIUM BMRKR2
#> 6 0.9727439 1.103532       0.95 0.2707796 p-value (Wald)       MEDIUM BMRKR2
#> 7 0.9756250 1.189118       0.95 0.1412524 p-value (Wald)         HIGH BMRKR2
#> 8 0.9678535 1.035259       0.95 0.9541048 p-value (Wald)         HIGH BMRKR2
#>                      var_label row_type
#> 1                 All Patients  content
#> 2                 All Patients  content
#> 3 Continuous Level Biomarker 2 analysis
#> 4 Continuous Level Biomarker 2 analysis
#> 5 Continuous Level Biomarker 2 analysis
#> 6 Continuous Level Biomarker 2 analysis
#> 7 Continuous Level Biomarker 2 analysis
#> 8 Continuous Level Biomarker 2 analysis

# Here we group the levels of `BMRKR2` manually.
df_grouped <- extract_survival_biomarkers(
  variables = list(
    tte = "AVAL",
    is_event = "is_event",
    biomarkers = c("BMRKR1", "AGE"),
    strata = "STRATA1",
    covariates = "SEX",
    subgroups = "BMRKR2"
  ),
  data = adtte_f,
  groups_lists = list(
    BMRKR2 = list(
      "low" = "LOW",
      "low/medium" = c("LOW", "MEDIUM"),
      "low/medium/high" = c("LOW", "MEDIUM", "HIGH")
    )
  )
)
df_grouped
#>   biomarker              biomarker_label n_tot n_tot_events   median        hr
#> 1    BMRKR1 Continuous Level Biomarker 1   200          141 753.5176 1.0010939
#> 2       AGE                          Age   200          141 753.5176 1.0106406
#> 3    BMRKR1 Continuous Level Biomarker 1    70           52 735.4722 0.9905065
#> 4       AGE                          Age    70           52 735.4722 1.0106279
#> 5    BMRKR1 Continuous Level Biomarker 1   138           94 777.8929 0.9801709
#> 6       AGE                          Age   138           94 777.8929 1.0236283
#> 7    BMRKR1 Continuous Level Biomarker 1   200          141 753.5176 1.0010939
#> 8       AGE                          Age   200          141 753.5176 1.0106406
#>         lcl      ucl conf_level      pval     pval_label        subgroup    var
#> 1 0.9538978 1.050625       0.95 0.9646086 p-value (Wald)    All Patients    ALL
#> 2 0.9871004 1.034742       0.95 0.3787395 p-value (Wald)    All Patients    ALL
#> 3 0.9142220 1.073156       0.95 0.8155443 p-value (Wald)             low BMRKR2
#> 4 0.9621192 1.061582       0.95 0.6735773 p-value (Wald)             low BMRKR2
#> 5 0.9235465 1.040267       0.95 0.5094582 p-value (Wald)      low/medium BMRKR2
#> 6 0.9859367 1.062761       0.95 0.2224475 p-value (Wald)      low/medium BMRKR2
#> 7 0.9538978 1.050625       0.95 0.9646086 p-value (Wald) low/medium/high BMRKR2
#> 8 0.9871004 1.034742       0.95 0.3787395 p-value (Wald) low/medium/high BMRKR2
#>                      var_label row_type
#> 1                 All Patients  content
#> 2                 All Patients  content
#> 3 Continuous Level Biomarker 2 analysis
#> 4 Continuous Level Biomarker 2 analysis
#> 5 Continuous Level Biomarker 2 analysis
#> 6 Continuous Level Biomarker 2 analysis
#> 7 Continuous Level Biomarker 2 analysis
#> 8 Continuous Level Biomarker 2 analysis