14 Generate time-to-event data for macrovascular diabetes complications

In this chapter, we phenotype right-censored time-to-event data for the following macrovascular diabetes compliations:

  • Myocardial Infarction (MI)
  • Unstable Angina (UA)
  • Ischemic Stroke (IS)
  • Hemorrhagic Stroke (HS)
  • Stroke (ST)
  • PCI
  • Composite CVD

To compute time-to-event, we require an index date (time-zero point) and event date of an outcome. In our case, we can define index date to be the first diagnosis date of diabetes or UKB study initiation date. For right-censored data, we define the index date as UKB study initiation date. In later chapters, we create interval-censored data by setting the index date as the first diabetes diagnosis date.

We now introduce a phenotyping procedure for right-censored data. For each complication outcome, we create an initial time-to-event data by combining the first occurrence diabetes event table, the first occurrence outcome event table and demographic table. As we merge these data to produce the initial time-to-event data, the cases and controls occur. The case is defined as a subject who has a complication event before the censoring date (defined in chapter 2). Otherwise, a subject is defined as control.

Next, we refine the initial time-to-event data by applying the following exclusion criteria for cases and controls:

  • case
    • has a complication event after the censoring date
    • has a prior complication event identified before a first evidence of diabetes
    • has an initiation date that is not between the first evidence of diabetes and the date of complication event
  • control
    • has some event represented in a control exclusion event table(s) (all generated in chapter 8; also see the table below)
    • has a first evidence of diabetes after the censoring date
    • has less than 5 years of follow-up time since the first evidence of diabetes before censoring date
    • has a first evidence of diabets 6 months after the study initiation date

The following table shows macrovascular complications and associated control exclusion event table(s):

Macrovascular complication Control exclusion outcome
Myocardial Infarction cardiovascular control exclusion events
Unstable Angina
Ischemic Stroke cerebrovascular control exclusion events
Hemorrhagic Stroke cerebrovascular control exclusion events
Stroke cerebrovascular control exclusion events
PCI non-coronary revascularization procedure control exclusion events
Composite CVD control exclusion events associated with MI, Ischemic stroke, unstable angina and PCI

The event tables for all of the above control exclusion events were created in chapter 8. The phenotyping procedure for time-to-event data is encapsulated in a function phenotype_time_to_event() defined in functions.R.

Load packages and functions.

library(tidyverse)
library(data.table)
source("functions.R")

Load first occurrence DM data.

dm_firstoccur <- readRDS("generated_data/dm_firstoccur.RDS")

Load demographic data.

demog <- readRDS("generated_data/demog_selected.RDS")

MI

Load MI first occurrence data phenotyped from UKB assessment data.

mi_firstoccur_ukb <- readRDS("generated_data/mi_firstoccur_ukb.RDS") %>% select(f.eid,event_dt)

Load cardiovascular event table that will be used to exclude controls.

cardio <- readRDS("generated_data/cardio_control_exclusion_events_ukb.RDS")

Define control exclusion subject IDs.

ctrl_exclusion_ids_cardio <- cardio$f.eid %>% unique

Phenotype time-to-event.

mi_tte <- phenotype_time_to_event(dm_firstoccur, mi_firstoccur_ukb,
                        demog, control_exclusion_ids = ctrl_exclusion_ids_cardio)
saveRDS(mi_tte,"generated_data/mi_tte.RDS")

Unstable angina

Load unstable angina first occurrence data phenotyped from UKB assessment data.

unstable_angina_firstoccur_ukb <- 
  readRDS("generated_data/unstable_angina_firstoccur_ukb.RDS") %>% select(f.eid,event_dt)

Phenotype time-to-event.

unstable_angina_tte <- phenotype_time_to_event(dm_firstoccur,unstable_angina_firstoccur_ukb,demog)
saveRDS(unstable_angina_tte,"generated_data/unstable_angina_tte.RDS")

Ischemic stroke

Load ischemic stroke first occurrence data phenotyped from UKB assessment data.

ischemic_stroke_firstoccur_ukb <- readRDS("generated_data/stroke_infarct_firstoccur_ukb.RDS")

Load cerebrovascular event table that will be used to exclude controls.

cerebro <- readRDS("generated_data/cerebro_control_exclusion_events_ukb.RDS")

Define control exclusion subject IDs.

ctrl_exclusion_ids_cerebro <- cerebro$f.eid %>% unique

Phenotype time-to-event.

ischemic_stroke_tte <- phenotype_time_to_event(dm_firstoccur,ischemic_stroke_firstoccur_ukb,demog,
                                               control_exclusion_ids = ctrl_exclusion_ids_cerebro)
saveRDS(ischemic_stroke_tte,"generated_data/ischemic_stroke_tte.RDS")

Hemorrhagic Stroke

Load hemorrhagic stroke first occurrence data phenotyped from UKB assessment data.

hem_stroke_firstoccur_ukb <- readRDS("generated_data/stroke_hem_firstoccur_ukb.RDS")

Load cerebrovascular event table that will be used to exclude controls.

cerebro <- readRDS("generated_data/cerebro_control_exclusion_events_ukb.RDS")

Define control exclusion subject IDs.

ctrl_exclusion_ids_cerebro <- cerebro$f.eid %>% unique

Phenotype time-to-event.

hem_stroke_tte <- phenotype_time_to_event(dm_firstoccur,hem_stroke_firstoccur_ukb,demog,
                                          control_exclusion_ids = ctrl_exclusion_ids_cerebro)
saveRDS(hem_stroke_tte,"generated_data/hem_stroke_tte.RDS")

Stroke

Load stroke first occurrence data phenotyped from UKB assessment data.

stroke_firstoccur_ukb <- readRDS("generated_data/stroke_firstoccur_ukb.RDS")

Load cerebrovascular event table that will be used to exclude controls.

cerebro <- readRDS("generated_data/cerebro_control_exclusion_events_ukb.RDS")

Define control exclusion subject IDs.

ctrl_exclusion_ids_cerebro <- cerebro$f.eid %>% unique

Phenotype time-to-event.

stroke_tte <- phenotype_time_to_event(dm_firstoccur,stroke_firstoccur_ukb,demog,
                                      control_exclusion_ids = ctrl_exclusion_ids_cerebro)
saveRDS(stroke_tte,"generated_data/stroke_tte.RDS")

PCI

Load PCI first occurrence data phenotyped from UKB assessment data.

pci_firstoccur_ukb <- readRDS("generated_data/pci_firstoccur_ukb.RDS")

Load non-coronary revascularization event table that will be used to exclude controls.

other_revas <- readRDS("generated_data/other_revas_control_exclusion_events_ukb.RDS")

Define control exclusion subject IDs.

ctrl_exclusion_ids_other_revas <- other_revas$f.eid %>% unique

Phenotype time-to-event.

pci_tte <- phenotype_time_to_event(dm_firstoccur,pci_firstoccur_ukb,demog,
                                   control_exclusion_ids = ctrl_exclusion_ids_other_revas)
saveRDS(pci_tte,"generated_data/pci_tte.RDS")

Composite CVD (MI, Unstable Angina, Ischemic Stroke, PCI or CVD death)

Load composite CVD first occurrence data phenotyped from UKB assessment data.

cvd_firstoccur_ukb <- readRDS("generated_data/cvd_firstoccur_ukb.RDS")

Create control exclusion table for CVD. They are combination of cardio, cerebro and other revasculrization events that were used to exclude controls when phenotyping MI, unstable angina, ischemic sstroke and PCI time-to-event data.

composite_cvd_control_exclusion_events <- list(cardio,cerebro,other_revas) %>% bind_rows()

Define control exclusion subject IDs.

ctrl_exclusion_ids_cvd <- composite_cvd_control_exclusion_events$f.eid %>% unique

Phenotype time-to-event.

cvd_tte <- phenotype_time_to_event(dm_firstoccur,cvd_firstoccur_ukb,demog,
                                   control_exclusion_ids = ctrl_exclusion_ids_cvd)
saveRDS(cvd_tte,"generated_data/cvd_tte.RDS")