generated from opensafely/research-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproject.yaml
323 lines (287 loc) · 14.2 KB
/
project.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
version: '3.0'
expectations:
population_size: 10000
actions:
####################
# Curation
####################
generate_study_population_curation:
run: cohortextractor:latest generate_cohort --study-definition study_definition_curation --output-format=csv.gz --output-dir output/curation --index-date-range "2019-03-01 to 2019-03-01 by month"
outputs:
highly_sensitive:
cohort: output/curation/input_curation_*.csv.gz
generate_dataset_report_curation:
run: >
python:latest python analysis/dataset_report.py
--input-files output/curation/input_curation_*.csv.gz
--output-dir output/curation/
needs: [generate_study_population_curation]
outputs:
moderately_sensitive:
dataset_report: output/curation/input_curation_*.html
# To count exclusions
generate_study_population_exclusions:
run: cohortextractor:latest generate_cohort --study-definition study_definition_exclusions --output-format=csv.gz --output-dir output/curation/exclusions --index-date-range "2022-10-01 to 2022-10-01 by month"
outputs:
highly_sensitive:
cohort: output/curation/exclusions/input_exclusions_*.csv.gz
generate_measures_exclusions:
run: cohortextractor:latest generate_measures --study-definition study_definition_exclusions --output-dir=output/curation/exclusions
needs: [generate_study_population_exclusions]
outputs:
moderately_sensitive:
# Only output the single summary file
measure_csv: output/curation/exclusions/measure_*_rate.csv
join_measures_exclusions:
run: python:latest python analysis/join_and_round.py
--input-files output/curation/exclusions/measure_*rate.csv
--output-dir output/curation/exclusions
--output-name "exclusions.csv"
needs: [generate_measures_exclusions]
outputs:
moderately_sensitive:
# Only output the single summary file
measure_csv: output/curation/exclusions/exclusions.csv
# For comparison with openprescribing
generate_study_population_num_matches_2018_2019:
run: cohortextractor:latest generate_cohort --study-definition study_definition_num_matches --output-format=csv.gz --output-dir output/curation --index-date-range "2018-01-01 to 2019-12-31 by month"
outputs:
highly_sensitive:
cohort: output/curation/input_num_matches_201*.csv.gz
generate_study_population_num_matches_2020_2021:
run: cohortextractor:latest generate_cohort --study-definition study_definition_num_matches --output-format=csv.gz --output-dir output/curation --index-date-range "2020-01-01 to 2021-12-31 by month"
outputs:
highly_sensitive:
cohort: output/curation/input_num_matches_20*.csv.gz
generate_study_population_num_matches_2022_2023:
run: cohortextractor:latest generate_cohort --study-definition study_definition_num_matches --output-format=csv.gz --output-dir output/curation --index-date-range "2022-01-01 to 2023-03-01 by month"
outputs:
highly_sensitive:
cohort: output/curation/input_num_matches_2*.csv.gz
generate_measures_num_matches:
run: cohortextractor:latest generate_measures --study-definition study_definition_num_matches --output-dir=output/curation
needs: [generate_study_population_num_matches_2018_2019, generate_study_population_num_matches_2020_2021, generate_study_population_num_matches_2022_2023]
outputs:
moderately_sensitive:
# Only output the single summary file
measure_csv: output/curation/measure_*_rate.csv
join_measures_num_matches:
run: python:latest python analysis/join_and_round.py
--input-files output/curation/measure_antidepressant_any_all_total_events_rate.csv
--output-dir output/curation/
--output-name "measure_events.csv"
needs: [generate_measures_num_matches]
outputs:
moderately_sensitive:
# Only output the single summary file
measure_csv: output/curation/measure_events.csv
# To compute prevalence
generate_study_population_prevalence:
run: cohortextractor:latest generate_cohort --study-definition study_definition_prevalence --output-format=csv.gz --output-dir output/curation --index-date-range "2021-03-01"
outputs:
highly_sensitive:
cohort: output/curation/input_prevalence_2021-03-01.csv.gz
generate_measures_prevalence:
run: cohortextractor:latest generate_measures --study-definition study_definition_prevalence --output-dir=output/curation
needs: [generate_study_population_prevalence]
outputs:
moderately_sensitive:
measure_csv: output/curation/measure_antidepressant_any_learning_disability_total_prevalence.csv
join_measures_prevalence:
run: python:latest python analysis/join_and_round.py
--input-files output/curation/measure_antidepressant_any_learning_disability_total_prevalence.csv
--output-dir output/curation/
--output-name "measure_prevalence.csv"
needs: [generate_measures_prevalence]
outputs:
moderately_sensitive:
# Only output the single summary file
measure_csv: output/curation/measure_prevalence.csv
####################
# Cohort Generation
####################
# Since this runs on everyone, we can reuse for both studies
generate_study_population_ethnicity:
run: cohortextractor:latest generate_cohort --study-definition study_definition_ethnicity --output-format=csv.gz
outputs:
highly_sensitive:
cohort: output/input_ethnicity.csv.gz
# Generate dataset report ethnicity
generate_dataset_report_ethnicity:
run: >
python:latest python analysis/dataset_report.py
--input-files output/input_*.csv.gz
--output-dir output/
needs: [generate_study_population_ethnicity]
outputs:
moderately_sensitive:
dataset_report: output/input_ethnicity.html
# Generate prescription variables by month
generate_study_population_lda_2018_01:
run: cohortextractor:latest generate_cohort --study-definition study_definition_lda --index-date-range "2018-01-01 to 2018-01-01 by month" --output-format=csv.gz --output-dir output/lda/codelist_update
outputs:
highly_sensitive:
cohort: output/lda/codelist_update/input_lda_2018-01*.csv.gz
generate_study_population_lda_2018:
run: cohortextractor:latest generate_cohort --study-definition study_definition_lda --index-date-range "2018-02-01 to 2018-12-01 by month" --output-format=csv.gz --output-dir output/lda/codelist_update
outputs:
highly_sensitive:
cohort: output/lda/codelist_update/input_lda_2018*.csv.gz
# Generate prescription variables by month
generate_study_population_lda_2019:
run: cohortextractor:latest generate_cohort --study-definition study_definition_lda --index-date-range "2019-01-01 to 2019-12-01 by month" --output-format=csv.gz --output-dir output/lda/codelist_update
outputs:
highly_sensitive:
cohort: output/lda/codelist_update/input_lda_2019*.csv.gz
generate_study_population_lda_2020:
run: cohortextractor:latest generate_cohort --study-definition study_definition_lda --index-date-range "2020-01-01 to 2020-12-01 by month" --output-format=csv.gz --output-dir output/lda/codelist_update
outputs:
highly_sensitive:
cohort: output/lda/codelist_update/input_lda_2020*.csv.gz
generate_study_population_lda_2021:
run: cohortextractor:latest generate_cohort --study-definition study_definition_lda --index-date-range "2021-01-01 to 2021-12-01 by month" --output-format=csv.gz --output-dir output/lda/codelist_update
outputs:
highly_sensitive:
cohort: output/lda/codelist_update/input_lda_2021*.csv.gz
generate_study_population_lda_2022:
run: cohortextractor:latest generate_cohort --study-definition study_definition_lda --index-date-range "2022-01-01 to 2022-12-01 by month" --output-format=csv.gz --output-dir output/lda/codelist_update
outputs:
highly_sensitive:
cohort: output/lda/codelist_update/input_lda_2022*.csv.gz
# Generate dataset report lda
generate_dataset_report_lda:
run: >
python:latest python analysis/dataset_report.py
--input-files output/lda/codelist_update/input_*.csv.gz
--output-dir output/lda/codelist_update
needs: [generate_study_population_lda_2018_01]
outputs:
moderately_sensitive:
dataset_report: output/lda/codelist_update/input_*.html
# Count prescription metrics
test_lda:
run: >
python:latest python analysis/test_lda.py
--input-files output/lda/codelist_update/input_*.csv.gz
--output-dir output/lda/codelist_update
needs: [generate_study_population_lda_2018_01, generate_study_population_lda_2018, generate_study_population_lda_2019, generate_study_population_lda_2020, generate_study_population_lda_2021, generate_study_population_lda_2022]
outputs:
moderately_sensitive:
dataset_report: output/lda/codelist_update/test_*.csv
# Count prescription metrics
test_lda_cohort_sample:
run: >
python:latest python analysis/test_lda_study.py
--input-files output/lda/codelist_update/input_*.csv.gz
--output-dir output/lda/codelist_update
--cohort-size 1000
needs: [generate_study_population_lda_2018_01, generate_study_population_lda_2018, generate_study_population_lda_2019, generate_study_population_lda_2020, generate_study_population_lda_2021, generate_study_population_lda_2022]
outputs:
moderately_sensitive:
dataset_report: output/lda/codelist_update/test_study_period.csv
####################
# Join ethnicity to all generated input files
# Efficiency fix https://github.com/opensafely/research-template
# BUT BEWARE STALE DATA
###################
join_cohorts_lda:
run: >
cohort-joiner:v0.0.56
--lhs output/lda/codelist_update/input_*.csv.gz
--rhs output/input_ethnicity.csv.gz
--output-dir output/lda/codelist_update/joined
needs: [generate_study_population_ethnicity, generate_study_population_lda_2018_01, generate_study_population_lda_2018, generate_study_population_lda_2019, generate_study_population_lda_2020, generate_study_population_lda_2021, generate_study_population_lda_2022]
outputs:
highly_sensitive:
cohort: output/lda/codelist_update/joined/input_*.csv.gz
####################
# Measures
####################
generate_measures_lda:
run: cohortextractor:latest generate_measures --study-definition study_definition_lda --output-dir=output/lda/codelist_update/joined/
needs: [join_cohorts_lda]
outputs:
moderately_sensitive:
# Only output the single summary file
measure_csv: output/lda/codelist_update/joined/measure_*_rate.csv
count_csv: output/lda/codelist_update/joined/measure_*_count.csv
join_measures_lda:
run: python:latest python analysis/join_and_round.py
--input-files output/lda/codelist_update/joined/measure_*.csv
--output-dir output/lda/codelist_update/joined/summary
--output-name "measure_lda.csv"
needs: [generate_measures_lda]
outputs:
moderately_sensitive:
# Only output the single summary file
measure_csv: output/lda/codelist_update/joined/summary/measure_lda.csv
#############################
# Tables and Figures
#############################
# Table 1
generate_table1:
run: >
python:v1 python analysis/table1.py
--input-file output/lda/codelist_update/joined/summary/measure_lda.csv
--output-dir output/lda/codelist_update/joined/summary
--measures-pattern "antidepressant_any_all_breakdown_*"
--measures-pattern "antidepressant_any_autism_breakdown_*"
--measures-pattern "antidepressant_any_learning_disability_breakdown_*"
--include-denominator
--include-rate
--column-names "all" "learning_disability" "autism"
--output-name "table1.html"
--start-date "2022-10-01"
needs: [join_measures_lda]
outputs:
moderately_sensitive:
cohort: output/lda/codelist_update/joined/summary/table1.html
# Table 2
generate_prescription_table:
run: >
python:v1 python analysis/table1.py
--input-file output/lda/codelist_update/joined/summary/measure_lda.csv
--output-dir output/lda/codelist_update/joined/summary
--measures-pattern "antidepressant_any_all_breakdown_prescription_count"
--measures-pattern "antidepressant_any_autism_breakdown_prescription_count"
--measures-pattern "antidepressant_any_learning_disability_breakdown_prescription_count"
--column-names "all" "learning_disability" "autism"
--output-name "prescription.html"
--exclude-missing
--start-date "2022-10-01"
needs: [join_measures_lda]
outputs:
moderately_sensitive:
cohort: output/lda/codelist_update/joined/summary/prescription.html
# Interrupted Time Series Analysis
# NOTE: we use statsmodels.tsa.deterministic.Fourier
# Available statsmodels 12+, so cannot currently run server/ OS python image
#run_itsa:
# run: >
# python:v1 python analysis/its.py
# --input-file output/lda/codelist_update/joined/summary/measure_lda.csv
# --output-dir output/lda/codelist_update/joined/summary
# needs: [join_measures_lda]
# outputs:
# moderately_sensitive:
# pngs: output/lda/codelist_update/joined/summary/*.png
# htmls: output/lda/codelist_update/joined/summary/*.html
# csvs: output/lda/codelist_update/joined/summary/*.csv
# Supplemental Table 1
generate_exclusions_table:
run: >
python:v1 python analysis/table1.py
--input-file output/curation/exclusions/exclusions.csv
--output-dir output/curation/exclusions
--measures-pattern "antidepressant_any*"
--column-names "all" "learning_disability" "autism"
--output-name "exclusions_table.csv"
--start-date "2022-10-01"
--output-type "csv"
--combine
--no-overall
--include-denominator
needs: [join_measures_exclusions]
outputs:
moderately_sensitive:
cohort: output/curation/exclusions/exclusions_table.csv