TimeToEvent
Bases: Reporter
Perform a time to event analysis.
The time_to_event table is first generated, after which, by default, a Kaplan Meier plot is generated. The time_to_event table contains one row per patient and then multiple columns containing
Dates
- the index date for each patient
- the dates of all outcomes or NULL if they did not occur
- the dates of all right censoring events or NULL if they did not occur
- the date of the end of the study, if provided
- the days from index to the dates provided above
- the
Column | Description |
---|---|
date columns |
The EVENT_DATE of every 1. cohort outcome phenotype and 2. the right censoring phenotypes, if provided. The column name for the respective EVENT_DATE is the name of the phenotype. 3. Additionally, the date of the end of study period is present, if provided. |
days_to_event columns |
For each date column, the number of days from index_date to the date column. These columns begin with “DAYS_TO_” and the name of the date column. |
date_first_event columns |
For each outcome phenotype, the date_first_event column is added titled “DATE_FIRST_EVENT_{name of outcome phenotype}”. This is the first date that occurs post index, whether that outcome, a right censoring event, or the end of study period. |
days_to_first_event columns |
For each outcome phenotype, the days_to_first_event column is added titled “DAYS_FIRST_EVENT_{name of outcome phenotype}”. This is the days from index_date to the date_first_event column. |
indicator columns |
For each outcome phenotype, the indicator column is added titled “INDICATOR_{name of outcome phenotype}”. This has a value of 1 if the first event was the outcome phenotype, or a 0 if the first event was a right censoring event or the end of study period. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
right_censor_phenotypes
|
Optional[List[Phenotype]]
|
A list of phenotypes that should be used as right censoring events. Suggested are death and end of followup. |
None
|
end_of_study_period
|
Optional[datetime]
|
A datetime defining the end of study period. |
None
|
Source code in phenex/reporting/time_to_event.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
|
execute(cohort)
Execute the time to event analysis for a provided cohort. This will generate a table with all necessary cohort outcome event dates and right censoring event dates. Following execution, a Kaplan Meier curve will be generated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cohort
|
Cohort
|
The cohort for which the time to event analysis should be performed. |
required |
Source code in phenex/reporting/time_to_event.py
plot_multiple_kaplan_meier(xlim=None, ylim=None, n_cols=3, outcome_indices=None, path_dir=None)
For each outcome, plot a kaplan meier curve.
Source code in phenex/reporting/time_to_event.py
plot_single_kaplan_meier(outcome_index=0, xlim=None, ylim=None, path_dir=None)
For each outcome, plot a kaplan meier curve.