Repository navigation
Expand file tree
/
Copy pathSnakefile
More file actions
194 lines (167 loc) · 6.96 KB
/
Copy pathSnakefile
File metadata and controls
194 lines (167 loc) · 6.96 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
include: "common.smk"
include: "config/resources.smk"
PARAMS = resolve_popsize_params()
PREFIX, _TOOLS = get_popsize_targets(PARAMS)
VCF, REF_FASTA = get_snparcher_paths(config)
_ALL_TARGETS = [
f"results/popsize/SFS_{PREFIX}.fs",
f"results/popsize/output_stats/{PREFIX}_PCA.{PARAMS['plot_format']}",
f"results/popsize/output_smcpp/{PREFIX}.final.json" if "smcpp" in _TOOLS else [],
f"results/popsize/output_stairwayplot2/{PREFIX}/{PREFIX}.final.summary" if "swp2" in _TOOLS else [],
f"results/popsize/output_dadi/{PREFIX}.InferDM.bestfits" if "dadi" in _TOOLS else [],
f"results/popsize/output_psmc/{PREFIX}.eps" if "psmc" in _TOOLS else [],
f"results/popsize/output_msmc2/{PREFIX}_msmc2.final.txt" if "msmc2" in _TOOLS else [],
f"results/popsize/{PREFIX}_combined_plot.{PARAMS['plot_format']}",
]
rule all:
input:
_ALL_TARGETS
rule done:
input:
_ALL_TARGETS
output:
touch("results/popsize/.done"),
rule decompress_reference:
input:
ref=REF_FASTA,
output:
ref="results/popsize/ref.fa",
shell:
"gzip -dc {input.ref} > {output.ref}"
rule init_module:
input:
vcf=VCF,
output:
config_file=f"results/popsize/{PREFIX}_deminfhelper.yml",
run:
build_deminfhelper_config(
out_dir="results/popsize",
vcf_file=input.vcf,
ref_fasta="results/popsize/ref.fa",
prefix=PREFIX,
output=output.config_file,
params=PARAMS,
)
rule compute_sfs:
input:
config_file=ancient(f"results/popsize/{PREFIX}_deminfhelper.yml"),
output:
sfs_file=f"results/popsize/SFS_{PREFIX}.fs",
conda:
"envs/deminfhelper.yml"
shell:
"python3 workflow/modules/popsize/scripts/deminfhelper.py --sfs --config_file {input.config_file} ;"
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --plot_sfs"
rule stairwayplot2:
input:
config_file=ancient(f"results/popsize/{PREFIX}_deminfhelper.yml"),
sfs_file=f"results/popsize/SFS_{PREFIX}.fs",
output:
stairwayplot2_summary=f"results/popsize/output_stairwayplot2/{PREFIX}/{PREFIX}.final.summary",
conda:
"envs/deminfhelper.yml"
resources:
mem_mb=lambda wildcards, attempt: attempt * resources['swp2']['mem_mb']
threads:
resources['swp2']['threads']
shell:
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --stairwayplot2 ;"
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --plot_stairwayplot2"
rule smcpp:
input:
config_file=ancient(f"results/popsize/{PREFIX}_deminfhelper.yml"),
vcf_index=f"{VCF}.tbi",
output:
smcpp_summary=f"results/popsize/output_smcpp/{PREFIX}.final.json",
conda:
"envs/smcpp.yml"
resources:
mem_mb=lambda wildcards, attempt: attempt * resources['smcpp']['mem_mb']
threads:
resources['smcpp']['threads']
shell:
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --cpus {threads} --smcpp ;"
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --plot_smcpp"
rule dadi:
input:
config_file=ancient(f"results/popsize/{PREFIX}_deminfhelper.yml"),
sfs_file=f"results/popsize/SFS_{PREFIX}.fs",
output:
dadi_summary=f"results/popsize/output_dadi/{PREFIX}.InferDM.bestfits",
conda:
"envs/deminfhelper.yml"
shell:
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --dadi ;"
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --plot_dadi"
rule psmc:
input:
config_file=ancient(f"results/popsize/{PREFIX}_deminfhelper.yml"),
vcf=VCF,
vcf_index=f"{VCF}.tbi",
ref_genome="results/popsize/ref.fa",
output:
psmc_output=f"results/popsize/output_psmc/{PREFIX}_combined.psmc.final",
params:
psmc_kwargs=PARAMS["psmc_kwargs"],
resources:
mem_mb=lambda wildcards, attempt: attempt * resources['psmc']['mem_mb']
threads:
resources['psmc']['threads']
conda:
"envs/deminfhelper.yml"
shell:
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} "
"--psmc_kwargs '{params.psmc_kwargs}' --psmc"
rule psmc_plot:
input:
config_file=ancient(f"results/popsize/{PREFIX}_deminfhelper.yml"),
psmc_output=f"results/popsize/output_psmc/{PREFIX}_combined.psmc.final",
output:
psmc_figure=f"results/popsize/output_psmc/{PREFIX}.eps",
params:
plot_psmc_kwargs=PARAMS["plot_psmc_kwargs"],
conda:
"envs/deminfhelper.yml"
shell:
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} "
"--plot_psmc_kwargs '{params.plot_psmc_kwargs}' --plot_psmc"
rule combined_plot:
input:
config_file=ancient(f"results/popsize/{PREFIX}_deminfhelper.yml"),
dadi=f"results/popsize/output_dadi/{PREFIX}.InferDM.bestfits" if "dadi" in _TOOLS else [],
smcpp=f"results/popsize/output_smcpp/{PREFIX}.final.json" if "smcpp" in _TOOLS else [],
swp2=f"results/popsize/output_stairwayplot2/{PREFIX}/{PREFIX}.final.summary" if "swp2" in _TOOLS else [],
msmc2=f"results/popsize/output_msmc2/{PREFIX}_msmc2.final.txt" if "msmc2" in _TOOLS else [],
psmc=f"results/popsize/output_psmc/{PREFIX}.eps" if "psmc" in _TOOLS else [],
output:
combined_plot=f"results/popsize/{PREFIX}_combined_plot.{PARAMS['plot_format']}",
conda:
"envs/deminfhelper.yml"
shell:
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --combined_plot"
rule msmc2:
input:
config_file=ancient(f"results/popsize/{PREFIX}_deminfhelper.yml"),
vcf=VCF,
output:
msmc2_output=f"results/popsize/output_msmc2/{PREFIX}_msmc2.final.txt",
resources:
mem_mb=lambda wildcards, attempt: attempt * resources['msmc2']['mem_mb']
threads:
resources['msmc2']['threads']
conda:
"envs/deminfhelper.yml"
shell:
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --msmc2 ;"
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --plot_msmc2"
rule statistics:
input:
config_file=ancient(f"results/popsize/{PREFIX}_deminfhelper.yml"),
vcf=VCF,
output:
pca_output=f"results/popsize/output_stats/{PREFIX}_PCA.{PARAMS['plot_format']}",
conda:
"envs/deminfhelper.yml"
shell:
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --pca ;"
"python3 workflow/modules/popsize/scripts/deminfhelper.py --config_file {input.config_file} --gq_distrib"