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.
<- readRDS("generated_data/dm_firstoccur.RDS") dm_firstoccur
Load demographic data.
<- readRDS("generated_data/demog_selected.RDS") demog
MI
Load MI first occurrence data phenotyped from UKB assessment data.
<- readRDS("generated_data/mi_firstoccur_ukb.RDS") %>% select(f.eid,event_dt) mi_firstoccur_ukb
Load cardiovascular event table that will be used to exclude controls.
<- readRDS("generated_data/cardio_control_exclusion_events_ukb.RDS") cardio
Define control exclusion subject IDs.
<- cardio$f.eid %>% unique ctrl_exclusion_ids_cardio
Phenotype time-to-event.
<- phenotype_time_to_event(dm_firstoccur, mi_firstoccur_ukb,
mi_tte control_exclusion_ids = ctrl_exclusion_ids_cardio) demog,
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.
<- phenotype_time_to_event(dm_firstoccur,unstable_angina_firstoccur_ukb,demog) unstable_angina_tte
saveRDS(unstable_angina_tte,"generated_data/unstable_angina_tte.RDS")
Ischemic stroke
Load ischemic stroke first occurrence data phenotyped from UKB assessment data.
<- readRDS("generated_data/stroke_infarct_firstoccur_ukb.RDS") ischemic_stroke_firstoccur_ukb
Load cerebrovascular event table that will be used to exclude controls.
<- readRDS("generated_data/cerebro_control_exclusion_events_ukb.RDS") cerebro
Define control exclusion subject IDs.
<- cerebro$f.eid %>% unique ctrl_exclusion_ids_cerebro
Phenotype time-to-event.
<- phenotype_time_to_event(dm_firstoccur,ischemic_stroke_firstoccur_ukb,demog,
ischemic_stroke_tte 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.
<- readRDS("generated_data/stroke_hem_firstoccur_ukb.RDS") hem_stroke_firstoccur_ukb
Load cerebrovascular event table that will be used to exclude controls.
<- readRDS("generated_data/cerebro_control_exclusion_events_ukb.RDS") cerebro
Define control exclusion subject IDs.
<- cerebro$f.eid %>% unique ctrl_exclusion_ids_cerebro
Phenotype time-to-event.
<- phenotype_time_to_event(dm_firstoccur,hem_stroke_firstoccur_ukb,demog,
hem_stroke_tte 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.
<- readRDS("generated_data/stroke_firstoccur_ukb.RDS") stroke_firstoccur_ukb
Load cerebrovascular event table that will be used to exclude controls.
<- readRDS("generated_data/cerebro_control_exclusion_events_ukb.RDS") cerebro
Define control exclusion subject IDs.
<- cerebro$f.eid %>% unique ctrl_exclusion_ids_cerebro
Phenotype time-to-event.
<- phenotype_time_to_event(dm_firstoccur,stroke_firstoccur_ukb,demog,
stroke_tte 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.
<- readRDS("generated_data/pci_firstoccur_ukb.RDS") pci_firstoccur_ukb
Load non-coronary revascularization event table that will be used to exclude controls.
<- readRDS("generated_data/other_revas_control_exclusion_events_ukb.RDS") other_revas
Define control exclusion subject IDs.
<- other_revas$f.eid %>% unique ctrl_exclusion_ids_other_revas
Phenotype time-to-event.
<- phenotype_time_to_event(dm_firstoccur,pci_firstoccur_ukb,demog,
pci_tte 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.
<- readRDS("generated_data/cvd_firstoccur_ukb.RDS") cvd_firstoccur_ukb
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.
<- list(cardio,cerebro,other_revas) %>% bind_rows() composite_cvd_control_exclusion_events
Define control exclusion subject IDs.
<- composite_cvd_control_exclusion_events$f.eid %>% unique ctrl_exclusion_ids_cvd
Phenotype time-to-event.
<- phenotype_time_to_event(dm_firstoccur,cvd_firstoccur_ukb,demog,
cvd_tte control_exclusion_ids = ctrl_exclusion_ids_cvd)
saveRDS(cvd_tte,"generated_data/cvd_tte.RDS")