-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSnakefile
More file actions
308 lines (267 loc) · 8.17 KB
/
Copy pathSnakefile
File metadata and controls
308 lines (267 loc) · 8.17 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
import os
from snakemake.io import expand, directory, temp
from snakemake.utils import min_version
min_version("9.16")
include: "utils.py"
config = ConfigManager(config)
rule all:
localrule: True
input:
config.pipeline_files,
rule run_cfclone:
input:
c=config.clone_cn_file,
i=config.ctdna_file,
output:
e=directory(config.exec_dir_template),
f=config.fit_template,
params:
c=config.num_chains,
r=config.num_rounds,
rt=config.get_cfclone_run_type_args,
benchmark:
config.get_benchmark_file(config.fit_template)
conda:
"envs/cfclone.yaml"
log:
config.get_log_file(config.fit_template),
threads: config.num_threads
shell:
"(cfclone fit "
"-c {input.c} "
"-i {input.i} "
"-o {output.f} "
"-t {threads} "
"--exec-dir {output.e} "
"--num-chains {params.c} "
"--num-rounds {params.r} "
"--seed {wildcards.seed} "
"{params.rt}) >{log} 2>&1"
rule write_ancestral_prevalances:
input:
i=lambda wildcards: expand(config.fit_template, run_type="full", seed=wildcards.seed),
t=config.clone_tree_file,
output:
o=config.ancestral_prevalence_file,
t=config.clone_prevalence_tree_file,
conda:
"envs/cfclone.yaml"
group:
"post_process"
log:
config.get_log_file(config.ancestral_prevalence_file),
shell:
"(cfclone write-ancestral-prevalences -c {input.t} -i {input.i} -o {output.o} -t {output.t}) >{log} 2>&1"
rule write_dominance_prob:
input:
fit=lambda wildcards: expand(config.fit_template, run_type="full", seed=wildcards.seed),
output:
config.dominance_prob_file,
conda:
"envs/cfclone.yaml"
group:
"post_process"
log:
config.get_log_file(config.dominance_prob_file),
shell:
"(cfclone write-dominance-prob -i {input.fit} -o {output}) >{log} 2>&1"
rule write_pairwise_ranks_file:
input:
fit=lambda wildcards: expand(config.fit_template, run_type="full", seed=wildcards.seed),
output:
config.pairwise_ranks_file,
conda:
"envs/cfclone.yaml"
group:
"post_process"
log:
config.get_log_file(config.pairwise_ranks_file),
shell:
"(cfclone write-pairwise-ranks -i {input.fit} -o {output}) >{log} 2>&1"
rule write_parameter_summaries_file:
input:
fit=lambda wildcards: expand(config.fit_template, run_type="full", seed=wildcards.seed),
output:
config.parameter_summaries_file,
conda:
"envs/cfclone.yaml"
group:
"post_process"
log:
config.get_log_file(config.parameter_summaries_file),
shell:
"(cfclone write-parameter-summaries -i {input.fit} -o {output}) >{log} 2>&1"
rule write_summary_file:
input:
fit=lambda wildcards: expand(config.fit_template, run_type="full", seed=wildcards.seed),
output:
config.summary_file,
conda:
"envs/cfclone.yaml"
group:
"post_process"
log:
config.get_log_file(config.summary_file),
shell:
"(cfclone write-summary -i {input.fit} -o {output}) >{log} 2>&1"
rule write_tumour_content_file:
input:
fit=lambda wildcards: expand(config.fit_template, run_type="full", seed=wildcards.seed),
output:
config.tumour_content_file,
conda:
"envs/cfclone.yaml"
group:
"post_process"
log:
config.get_log_file(config.tumour_content_file),
shell:
"(cfclone write-tumour-content -i {input.fit} -o {output}) >{log} 2>&1"
rule write_evidence:
input:
config.fit_template,
output:
temp(config.run_type_evidence_template),
conda:
"envs/cfclone.yaml"
group:
"post_process"
log:
config.get_log_file(config.run_type_evidence_template),
shell:
"(echo -n {wildcards.run_type}, > {output}; "
"cfclone print-model-evidence -i{input} >> {output}) 2>{log}"
rule merge_evidence:
input:
i=lambda wildcards: expand(config.run_type_evidence_template, run_type=["full", "normal"], seed=wildcards.seed),
script=workflow.source_path("scripts/merge_evidence.py"),
output:
config.evidence_file,
conda:
"envs/python.yaml"
group:
"post_process"
log:
config.get_log_file(config.evidence_file),
shell:
"(python {input.script} -i {input.i} -o {output}) >{log} 2>&1"
rule plot_clone_prevalences:
input:
d=config.ancestral_prevalence_file,
t=config.clone_prevalence_tree_file,
script=workflow.source_path("scripts/plot_clone_prevalences.py"),
output:
config.clone_prevalences_plot,
conda:
"envs/plot.yaml"
group:
"post_process"
log:
config.get_log_file(config.clone_prevalence_tree_file),
shell:
"(python {input.script} -d {input.d} -t {input.t} -o {output}) >{log} 2>&1"
rule plot_fit:
input:
i=config.parameter_summaries_file,
script=workflow.source_path("scripts/plot_fit.py"),
output:
config.fit_plot,
conda:
"envs/plot.yaml"
group:
"post_process"
log:
config.get_log_file(config.fit_plot),
shell:
"(python {input.script} -i {input.i} -o {output}) >{log} 2>&1"
rule plot_pairwsie_ranks:
input:
i=config.pairwise_ranks_file,
t=config.clone_tree_file,
script=workflow.source_path("scripts/plot_pairwise_ranks.py"),
output:
config.pairwise_ranks_plot,
conda:
"envs/plot.yaml"
group:
"post_process"
log:
config.get_log_file(config.pairwise_ranks_plot),
shell:
"(python {input.script} -i {input.i} -t {input.t} -o {output}) >{log} 2>&1"
rule merge_evidence_restarts:
input:
i=expand(config.evidence_file, seed=config.seeds),
script=workflow.source_path("scripts/merge_restart_tables.py"),
output:
config.merged_evidence_file,
params:
seeds=" ".join([str(x) for x in config.seeds]),
conda:
"envs/python.yaml"
group:
"post_process"
log:
config.get_log_file(config.merged_evidence_file),
shell:
"(python {input.script} -i {input.i} -o {output} -s {params.seeds}) >{log} 2>&1"
rule merge_prevalence_restarts:
input:
i=expand(config.ancestral_prevalence_file, seed=config.seeds),
script=workflow.source_path("scripts/merge_restart_tables.py"),
output:
config.merged_prevalence_file,
params:
seeds=" ".join([str(x) for x in config.seeds]),
conda:
"envs/python.yaml"
group:
"post_process"
log:
config.get_log_file(config.merged_prevalence_file),
shell:
"(python {input.script} -i {input.i} -o {output} -s {params.seeds}) >{log} 2>&1"
rule merge_summary_restarts:
input:
i=expand(config.summary_file, seed=config.seeds),
script=workflow.source_path("scripts/merge_restart_tables.py"),
output:
config.merged_summary_file,
params:
seeds=" ".join([str(x) for x in config.seeds]),
conda:
"envs/python.yaml"
group:
"post_process"
log:
config.get_log_file(config.merged_summary_file),
shell:
"(python {input.script} -i {input.i} -o {output} -s {params.seeds}) >{log} 2>&1"
rule merge_tumour_content_restarts:
input:
i=expand(config.tumour_content_file, seed=config.seeds),
script=workflow.source_path("scripts/merge_restart_tables.py"),
output:
config.merged_tumour_content_file,
params:
seeds=" ".join([str(x) for x in config.seeds]),
conda:
"envs/python.yaml"
group:
"post_process"
log:
config.get_log_file(config.merged_tumour_content_file),
shell:
"(python {input.script} -i {input.i} -o {output} -s {params.seeds}) >{log} 2>&1"
rule save_run_configuration:
localrule: True
output:
config.experiment_configuration,
params:
config.config_yaml,
log:
config.log_dir.joinpath("save_run_configuration.log"),
conda:
"envs/python.yaml"
shell:
"(echo \"{params}\" > {output}) 2>{log}"