Competing risk survival

Set up

Let’s first load the packages required.

library(CDMConnector)
library(CohortSurvival)
library(dplyr)
library(ggplot2)

We’ll create a cdm reference to use our example MGUS2 survival dataset. In practice you would use the CDMConnector package to connect to your data mapped to the OMOP CDM.

cdm <- CohortSurvival::mockMGUS2cdm()

We will proceed as we did with the single event survival, but this time we will also use a competing risk cohort of progression of the disease.

We would typically need to define study cohorts ourselves, but in the case of our example data we already have these cohorts available. You can see for our diagnosis cohort we also have a number of additional features recorded for individuals which we’ll use for stratification.

cdm$mgus_diagnosis %>% 
  glimpse()
#> Rows: ??
#> Columns: 10
#> Database: DuckDB v0.9.2 [eburn@Windows 10 x64:R 4.2.1/:memory:]
#> $ cohort_definition_id <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ subject_id           <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15…
#> $ cohort_start_date    <date> 1981-01-01, 1968-01-01, 1980-01-01, 1977-01-01, …
#> $ cohort_end_date      <date> 1981-01-01, 1968-01-01, 1980-01-01, 1977-01-01, …
#> $ age                  <dbl> 88, 78, 94, 68, 90, 90, 89, 87, 86, 79, 86, 89, 8…
#> $ sex                  <fct> F, F, M, M, F, M, F, F, F, F, M, F, M, F, M, F, F…
#> $ hgb                  <dbl> 13.1, 11.5, 10.5, 15.2, 10.7, 12.9, 10.5, 12.3, 1…
#> $ creat                <dbl> 1.30, 1.20, 1.50, 1.20, 0.80, 1.00, 0.90, 1.20, 0…
#> $ mspike               <dbl> 0.5, 2.0, 2.6, 1.2, 1.0, 0.5, 1.3, 1.6, 2.4, 2.3,…
#> $ age_group            <chr> ">=70", ">=70", ">=70", "<70", ">=70", ">=70", ">…

cdm$death_cohort %>% 
  glimpse()
#> Rows: ??
#> Columns: 4
#> Database: DuckDB v0.9.2 [eburn@Windows 10 x64:R 4.2.1/:memory:]
#> $ cohort_definition_id <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ subject_id           <dbl> 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 1…
#> $ cohort_start_date    <date> 1981-01-31, 1968-01-26, 1980-02-16, 1977-04-03, …
#> $ cohort_end_date      <date> 1981-01-31, 1968-01-26, 1980-02-16, 1977-04-03, …

cdm$progression %>%
  glimpse()
#> Rows: ??
#> Columns: 4
#> Database: DuckDB v0.9.2 [eburn@Windows 10 x64:R 4.2.1/:memory:]
#> $ cohort_definition_id <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ subject_id           <dbl> 56, 81, 83, 111, 124, 127, 147, 163, 165, 167, 18…
#> $ cohort_start_date    <date> 1978-01-30, 1985-01-15, 1974-08-17, 1993-01-14, …
#> $ cohort_end_date      <date> 1978-01-30, 1985-01-15, 1974-08-17, 1993-01-14, …

Estimating survival with competing risk

The package allows to estimate survival of both an outcome and competing risk outcome. We can then stratify, see information on events, summarise the estimates and check the contributing participants in the same way we did for the single event survival analysis.

MGUS_death_prog <- estimateCompetingRiskSurvival(cdm,
  targetCohortTable = "mgus_diagnosis",
  outcomeCohortTable = "progression",
  competingOutcomeCohortTable = "death_cohort"
) 

MGUS_death_prog %>% 
  asSurvivalResult() %>% 
  glimpse()
#> Rows: 2,550
#> Columns: 14
#> $ result_id         <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
#> $ cdm_name          <chr> "mock", "mock", "mock", "mock", "mock", "mock", "moc…
#> $ result_type       <chr> "survival_estimate", "survival_estimate", "survival_…
#> $ cohort            <chr> "mgus_diagnosis", "mgus_diagnosis", "mgus_diagnosis"…
#> $ outcome           <chr> "progression", "progression", "progression", "progre…
#> $ competing_outcome <chr> "death_cohort", "death_cohort", "death_cohort", "dea…
#> $ strata_name       <chr> "overall", "overall", "overall", "overall", "overall…
#> $ strata_level      <chr> "overall", "overall", "overall", "overall", "overall…
#> $ variable_name     <chr> "cumulative_failure_probability", "cumulative_failur…
#> $ variable_level    <chr> "progression", "progression", "progression", "progre…
#> $ estimate_name     <chr> "estimate", "estimate_95CI_lower", "estimate_95CI_up…
#> $ estimate_value    <dbl> 0.0000, 0.0000, 0.0000, 0.0000, NA, NA, 0.0014, 0.00…
#> $ time              <dbl> 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5…
#> $ analysis_type     <chr> "competing_risk", "competing_risk", "competing_risk"…

As we can see above our results have been outputted in long format. We can plot these results like so.

plotSurvival(MGUS_death_prog, cumulativeFailure = TRUE,
             colour = "variable_level")

Our returned results also have attributes containing information that summarises survival.

tableSurvival(MGUS_death_prog, times = c(100,200,300,400)) 
#> # A tibble: 2 × 11
#>   cdm_name cohort         variable_level analysis_type outcome competing_outcome
#>   <chr>    <chr>          <chr>          <chr>         <chr>   <chr>            
#> 1 mock     mgus_diagnosis progression    competing_ri… progre… death_cohort     
#> 2 mock     mgus_diagnosis death_cohort   competing_ri… progre… death_cohort     
#> # ℹ 5 more variables: number_records <dbl>, `100 days survival estimate` <chr>,
#> #   `200 days survival estimate` <chr>, `300 days survival estimate` <chr>,
#> #   `400 days survival estimate` <chr>

With stratification

To estimate survival for particular strata of interest we need these features to have been added to the target cohort table. Once we have them defined, and as seen above we already have a number of example characteristics added to our diagnosis cohort, we can add stratifications like so.

MGUS_death_prog <-  estimateCompetingRiskSurvival(cdm,
  targetCohortTable = "mgus_diagnosis",
  outcomeCohortTable = "progression",
  competingOutcomeCohortTable = "death_cohort",
  strata = list(c("sex"))
)

As we can see as well as results for each strata, we’ll always also have overall results returned. We can filter the output table to plot only the results for the different strata levels. We can also ask for the cumulative failure probability to be plotted instead of the survival probability.

plotSurvival(MGUS_death_prog %>% 
               dplyr::filter(strata_name != "Overall"), 
             facet = "strata_level",
             colour = "variable_level",
             cumulativeFailure = TRUE)

And we also now have summary statistics for each of the strata as well as overall.

tableSurvival(MGUS_death_prog, times = c(50,150,365))
#> # A tibble: 6 × 11
#>   cdm_name cohort   variable_level analysis_type outcome competing_outcome sex  
#>   <chr>    <chr>    <chr>          <chr>         <chr>   <chr>             <chr>
#> 1 mock     mgus_di… progression    competing_ri… progre… death_cohort      over…
#> 2 mock     mgus_di… death_cohort   competing_ri… progre… death_cohort      over…
#> 3 mock     mgus_di… progression    competing_ri… progre… death_cohort      F    
#> 4 mock     mgus_di… progression    competing_ri… progre… death_cohort      M    
#> 5 mock     mgus_di… death_cohort   competing_ri… progre… death_cohort      F    
#> 6 mock     mgus_di… death_cohort   competing_ri… progre… death_cohort      M    
#> # ℹ 4 more variables: number_records <dbl>, `50 days survival estimate` <chr>,
#> #   `150 days survival estimate` <chr>, `365 days survival estimate` <chr>

Summarising participants

If we set returnParticipants as TRUE then we will also be able to access the individuals that contributed to the analysis.

MGUS_death_prog <- estimateCompetingRiskSurvival(cdm,
  targetCohortTable = "mgus_diagnosis",
  outcomeCohortTable = "progression",
  competingOutcomeCohortTable = "death_cohort",
  returnParticipants = TRUE
) 
survivalParticipants(MGUS_death_prog)
#> # A tibble: 1,384 × 7
#>    cohort_definition_id subject_id cohort_start_date cohort_end_date exposure_id
#>                   <int>      <dbl> <date>            <date>                <int>
#>  1                    1         56 1978-01-01        1978-01-01                1
#>  2                    1        124 1974-01-01        1974-01-01                1
#>  3                    1        127 1978-01-01        1978-01-01                1
#>  4                    1        147 1975-01-01        1975-01-01                1
#>  5                    1        163 1966-01-01        1966-01-01                1
#>  6                    1        167 1968-01-01        1968-01-01                1
#>  7                    1        186 1989-01-01        1989-01-01                1
#>  8                    1        195 1981-01-01        1981-01-01                1
#>  9                    1        206 1986-01-01        1986-01-01                1
#> 10                    1        229 1981-01-01        1981-01-01                1
#> # ℹ 1,374 more rows
#> # ℹ 2 more variables: outcome_id <int>, competing_outcome_id <int>

Disconnect from the cdm database connection

cdm_disconnect(cdm)