-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdvc.yaml
More file actions
425 lines (405 loc) · 13.7 KB
/
Copy pathdvc.yaml
File metadata and controls
425 lines (405 loc) · 13.7 KB
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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
stages:
lyproxify:
foreach:
- folder: 2021-clb-oropharynx
args: "--num-header-rows 1"
- folder: 2023-clb-multisite
args: "--num-header-rows 3 --drop-rows 439"
- folder: 2023-isb-multisite
args: "--num-header-rows 1"
- folder: 2025-ksa-oral-cavity
args: "--num-header-rows 1"
do:
desc:
Parse the `raw.csv` data using the `lyscripts` Python package and the
`mapping.py` module to bring the original data into a format that the online
interface LyProX understands.
cmd: >
uvx --with-requirements ${item.folder}/requirements.in
lyscripts data lyproxify
--input-file ${item.folder}/raw.csv
--output-file ${item.folder}/_lyproxified.csv
--mapping-file ${item.folder}/mapping.py
${item.args}
deps:
- ${item.folder}/raw.csv
- ${item.folder}/mapping.py
outs:
- ${item.folder}/_lyproxified.csv:
cache: false
fix-2023-clb-location:
cmd: >
uv run scripts/fix_location.py
2023-clb-multisite/_lyproxified.csv
2023-clb-multisite/_fixed_location.csv
deps:
- scripts/fix_location.py
- 2023-clb-multisite/_lyproxified.csv
outs:
- 2023-clb-multisite/_fixed_location.csv
fix-2025-usz-add-institution:
desc:
In the 2025-USZ-Hypopharynx-Larynx dataset are patients where the tumor side
was reported as "ambiguous". This stage replaces that with "central".
And the auto-parsed 2025-USZ-Hypopharynx-Larynx dataset has
no id and no institution info. With some basic `sed` and `nl` commands,
all this can be fixed.
cmd:
sed 's/ambiguous,,/central,True,/g' 2025-usz-hypopharynx-larynx/parsed.csv |
sed 's/^,/University Hospital Zurich,/' |
sed 's/^patient,/patient,patient,/' |
sed 's/^core,/core,core,/' |
sed 's/^id,/id,institution,/' |
sed '4,$s/^/,/g' > 2025-usz-hypopharynx-larynx/_with_institution.csv
deps:
- 2025-usz-hypopharynx-larynx/parsed.csv
outs:
- 2025-usz-hypopharynx-larynx/_with_institution.csv:
cache: false
fix-2025-usz-involvement-info:
desc:
Some patients in the 2025-USZ-Hypopharynx-Larynx dataset have no involvement info
at all, but are N0. For those, this stage will add a `diagnostic_consensus` that
is all negative. It also fixes some missing pCT dates.
cmd: >
uv run scripts/fix_diagnoses.py
2025-usz-hypopharynx-larynx/_with_institution.csv
2025-usz-hypopharynx-larynx/_fixed_involvement.csv
--delta-days 30
deps:
- 2025-usz-hypopharynx-larynx/_with_institution.csv
outs:
- 2025-usz-hypopharynx-larynx/_fixed_involvement.csv:
cache: false
fix-2025-hvh-formatting:
desc: |
In the Vall d'Hebron dataset, dates are formatted as `dd/mm/YYYY`, which I will
change to `YYYY-mm-dd`.
Also, it contains the column `dataset`, which I will convert to `institution`
and replace all entries with the name of the hospital.
Next, the `hpv_status` column contains spaces instead of nothing when the
information is missing. This causes pandas to interpret all entries of that
column as strings instead of booleans.
Then, the A,B,C behind the N-stage is removed, as this cannot be parsed by LyProX
at the moment.
Furthermore, the 111th patient has `N VI` in the (MRI, ipsi, VII) column. I
assumed this should be FALSE. All this is fixed with a series of sed commands.
Also, there are some occurences of `"C05,1"` instead of `C05.1`, which I will
replace.
Finally, it lowercases "(FE)MALE" and "OROPHARYNX"
cmd: >
sed 's/\([0-9]\{2\}\)\/\([0-9]\{2\}\)\/\([0-9]\{4\}\)/\3-\2-\1/g' 2025-hvh-oropharynx/raw.csv |
sed 's/,dataset,/,institution,/g' |
sed "s/,2023_HVH_OROPHARYNX,/,Vall d'Hebron Barcelona Hospital,/g" |
sed 's/,\s,/,,/g' |
sed 's/,\([0-3]\)[A-C]*,/,\1,/g' |
sed 's/,N\sVI,/,FALSE,/g' |
sed 's/"C05,1"/C05.1/g' |
sed 's/\(FEMALE\)/\L&/g' |
sed 's/\(MALE\)/\L&/g' |
sed 's/\(OROPHARYNX\)/\L&/g' |
sed -E '2s/(#|1|info)/core/g' > 2025-hvh-oropharynx/_fixed.csv
deps:
- 2025-hvh-oropharynx/raw.csv
- scripts/drop_cols.py
outs:
- 2025-hvh-oropharynx/_fixed.csv
drop-2025-hvh-cols:
desc: |
Drop some columns that are still present in the raw CSV, but are actually empty.
cmd: >
uv run scripts/drop_cols.py
--input-csv 2025-hvh-oropharynx/_fixed.csv
--output-csv 2025-hvh-oropharynx/_reduced.csv
--cols "diagnostic_consensus,FNA,pCT"
deps:
- scripts/drop_cols.py
- 2025-hvh-oropharynx/_fixed.csv
outs:
- 2025-hvh-oropharynx/_reduced.csv:
cache: false
description-and-docs:
foreach:
- 2021-clb-oropharynx
- 2023-clb-multisite
- 2023-isb-multisite
- 2025-ksa-oral-cavity
do:
desc:
Generate the description of the `data.csv` columns from the `COLUMN_MAP` inside
the `mapping.py` file, as well as the documentation of all the functions used
in the `mapping.py` module. Insert these documentations into the
`README.md.jinja` and create the `README.md` from it.
deps:
- scripts/render.py
- ${item}/README.md.jinja
- ${item}/mapping.py
- ${item}/data.csv
outs:
- ${item}/README.md:
cache: false
cmd: >
uv run scripts/render.py
-m ${item}/mapping.py
-d ${item}/data.csv
-t ${item}/README.md.jinja
-o ${item}/README.md
lyproxify-2025-umcg:
foreach:
- radiotherapy
- surgery
do:
cmd: >
uvx --with-requirements 2025-umcg-hypopharynx-larynx/requirements.in
lyscripts data lyproxify
--input-file 2025-umcg-hypopharynx-larynx/raw_${item}.csv
--output-file 2025-umcg-hypopharynx-larynx/_${item}.csv
--mapping-file 2025-umcg-hypopharynx-larynx/mapping_${item}.py
deps:
- 2025-umcg-hypopharynx-larynx/raw_${item}.csv
- 2025-umcg-hypopharynx-larynx/mapping_${item}.py
outs:
- 2025-umcg-hypopharynx-larynx/_${item}.csv
join-2025-umcg-surgery-and-radiotherapy:
cmd: >
uvx --from "lyscripts @ git+https://github.com/lycosystem/lyscripts@74551fed623356bc26f59e5cad9a532e5756da2e"
lyscripts data join
--inputs '{"source": "2025-umcg-hypopharynx-larynx/_surgery.csv"}'
--inputs '{"source": "2025-umcg-hypopharynx-larynx/_radiotherapy.csv"}'
--output-file 2025-umcg-hypopharynx-larynx/_joined.csv
deps:
- 2025-umcg-hypopharynx-larynx/_surgery.csv
- 2025-umcg-hypopharynx-larynx/_radiotherapy.csv
outs:
- 2025-umcg-hypopharynx-larynx/_joined.csv:
cache: false
render-2025-umcg-docs:
desc:
The README.md generated from the `mapping_surgery.py` is a superset of that from
`mapping_radiotherapy.py`. Therefore, we will just render the former and replace
references to the `*_surgery.*` files.
cmd: >
uv run scripts/render.py
--mapping 2025-umcg-hypopharynx-larynx/mapping_surgery.py
--template 2025-umcg-hypopharynx-larynx/README.md.jinja
--data 2025-umcg-hypopharynx-larynx/data.csv
--output /dev/stdout
| sed 's/_surgery\./_*\./g'
> 2025-umcg-hypopharynx-larynx/README.md
deps:
- scripts/render.py
- 2025-umcg-hypopharynx-larynx/mapping_surgery.py
- 2025-umcg-hypopharynx-larynx/README.md.jinja
- 2025-umcg-hypopharynx-larynx/data.csv
outs:
- 2025-umcg-hypopharynx-larynx/README.md:
cache: false
plot-t-category:
foreach:
- 2021-usz-oropharynx
- 2021-clb-oropharynx
- 2023-clb-multisite
- 2023-isb-multisite
- 2025-hvh-oropharynx
- 2025-ksa-oral-cavity
- 2025-usz-hypopharynx-larynx
- 2025-umcg-hypopharynx-larynx
- 2025-ukf-hypopharynx
do:
cmd: >
uv run scripts/t_category.py ${item}/data.csv
deps:
- scripts/t_category.py
- ${item}/data.csv
outs:
- ${item}/figures/t_category.png:
cache: false
plot-age-and-sex:
foreach:
- 2021-usz-oropharynx
- 2021-clb-oropharynx
- 2023-clb-multisite
- 2023-isb-multisite
- 2025-hvh-oropharynx
- 2025-umcg-hypopharynx-larynx
- 2025-usz-hypopharynx-larynx
- 2025-ukf-hypopharynx
- 2025-ksa-oral-cavity
do:
cmd: >
uv run scripts/age_and_sex.py ${item}/data.csv
deps:
- scripts/age_and_sex.py
- ${item}/data.csv
outs:
- ${item}/figures/age_and_sex.png:
cache: false
plot-subsite:
foreach:
- 2021-usz-oropharynx
- 2021-clb-oropharynx
- 2023-clb-multisite
- 2023-isb-multisite
- 2025-hvh-oropharynx
- 2025-ksa-oral-cavity
do:
cmd: >
uv run scripts/subsite.py --data ${item}/data.csv
deps:
- scripts/subsite.py
- ${item}/data.csv
outs:
- ${item}/figures/subsite.png:
cache: false
bar-plot:
foreach:
- 2021-clb-oropharynx
- 2023-clb-multisite
- 2023-isb-multisite
do:
deps:
- scripts/bar_plot.py
- ${item}/data.csv
cmd:
uv run scripts/bar_plot.py ${item}/data.csv
factors-diff:
matrix:
first: [2021-usz-oropharynx]
second: [2025-hvh-oropharynx]
cmd: >
uv run scripts/factors_diff.py
--first-dataset ${item.first}
--second-dataset ${item.second}
--commit ee15c4cabdd160a10783fcf85ffe1cbfeb5c4826
--repo lycosystem/lydata.private
deps:
- ${item.first}/data.csv
- ${item.second}/data.csv
- scripts/factors_diff.py
plot-2025-ukf-conflicts:
cmd: >
uv run scripts/conflicts.py
--input-file 2025-ukf-hypopharynx/data.csv
--figure-dir 2025-ukf-hypopharynx/figures
deps:
- scripts/conflicts.py
- 2025-ukf-hypopharynx/data.csv
outs:
- 2025-ukf-hypopharynx/figures/conflicts.png
- 2025-ukf-hypopharynx/figures/total_conflicts.png
format-2025-ukf-data:
desc: Update UKF 2nd-lvl table headers to "core".
cmd: >
sed -E '2s/(#|1|info)/core/g' 2025-ukf-hypopharynx/raw.csv > 2025-ukf-hypopharynx/_formatted.csv
deps:
- 2025-ukf-hypopharynx/raw.csv
outs:
- 2025-ukf-hypopharynx/_formatted.csv:
cache: false
assign-unique-ids:
foreach:
- dir: 2021-clb-oropharynx
file: _lyproxified.csv
- dir: 2021-usz-oropharynx
file: no_ids.csv
- dir: 2023-clb-multisite
file: _fixed_location.csv
- dir: 2023-isb-multisite
file: _lyproxified.csv
- dir: 2025-hvh-oropharynx
file: _reduced.csv
- dir: 2025-ukf-hypopharynx
file: _formatted.csv
- dir: 2025-umcg-hypopharynx-larynx
file: _joined.csv
- dir: 2025-usz-hypopharynx-larynx
file: _fixed_involvement.csv
- dir: 2025-ksa-oral-cavity
file: _lyproxified.csv
do:
desc:
For easier referencing of individual patients, we introduce unique patient IDs.
They consist of the year the dataset was released, the abbreviation of the
institution that extracted the data and the number of the patient within that
institution.
cmd: >
uv run scripts/assign_ids.py
${item.dir}
--input-csv ${item.file}
--output-csv _to_cast.csv
deps:
- scripts/assign_ids.py
- ${item.dir}/${item.file}
outs:
- ${item.dir}/_to_cast.csv:
cache: false
cast-dtypes:
foreach:
- 2021-clb-oropharynx
- 2021-usz-oropharynx
- 2023-clb-multisite
- 2023-isb-multisite
- 2025-hvh-oropharynx
- 2025-ukf-hypopharynx
- 2025-umcg-hypopharynx-larynx
- 2025-usz-hypopharynx-larynx
- 2025-ksa-oral-cavity
do:
desc:
We use a pydantic schema in the lydata-package and a pandas utility to cast the
dtypes of the loaded dataframes appropriately and store the result again as CSV
files. The result should be cleaner (e.g. integers don't look like floats...).
cmd: >
uv run scripts/cast.py ${item}/_to_cast.csv ${item}/data.csv
deps:
- scripts/cast.py
- ${item}/_to_cast.csv
outs:
- ${item}/data.csv:
cache: false
validate:
foreach:
- 2021-clb-oropharynx
- 2021-usz-oropharynx
- 2023-clb-multisite
- 2023-isb-multisite
- 2025-hvh-oropharynx
- 2025-ukf-hypopharynx
- 2025-umcg-hypopharynx-larynx
- 2025-usz-hypopharynx-larynx
- 2025-ksa-oral-cavity
do:
desc:
We use a pydantic schema in the lydata-package and a pandas utility to cast the
dtypes of the loaded dataframes appropriately and store the result again as CSV
files. The result should be cleaner (e.g. integers don't look like floats...).
cmd: >
uv run scripts/validate.py ${item}/data.csv
deps:
- scripts/validate.py
- ${item}/data.csv
always_changed: true
area-plots:
foreach:
- dir: 2025-usz-hypopharynx-larynx
patch_xy: "10 30"
text_xy: "15 60"
- dir: 2025-umcg-hypopharynx-larynx
patch_xy: "70 60"
text_xy: "30 50"
- dir: 2025-ukf-hypopharynx
patch_xy: "20 40"
text_xy: "25 70"
do:
cmd: >
uv run scripts/area_plot.py
${item.dir}/data.csv ${item.dir}/figures/subsite_and_t.png
--patch-xy ${item.patch_xy}
--text-xy ${item.text_xy}
deps:
- scripts/area_plot.py
- scripts/shared.py
- ${item.dir}/data.csv
outs:
- ${item.dir}/figures/subsite_and_t.png:
cache: false