-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSnakefile.openswath
More file actions
214 lines (200 loc) · 10.5 KB
/
Snakefile.openswath
File metadata and controls
214 lines (200 loc) · 10.5 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
# Obtain run_ids from centroided DIA mzXML files in dia_data folder
run_ids, = glob_wildcards("data_dia/{run}.mzXML")
rule all:
input:
"tric_feature_alignment.done"
rule run_target_pqp:
input:
"results/library/{run}_Q1_run_peaks.tsv"
output:
"results/openswath/{run}.pqp"
singularity:
"docker://openswath/develop:latest"
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"OpenSwathAssayGenerator -in {input} -out $cache/$(basename {output}) && "
"mv $cache/$(basename {output}) {output} && "
"rm -rf $cache"
rule irt_filter_pqp:
input:
rules.run_target_pqp.output
params:
bins = 10,
peptides = 5
output:
"results/openswath/irt_{run}.pqp"
singularity:
"docker://grosenberger/easypqp:latest"
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"cp {input} $cache/$(basename {input}) && "
"easypqp reduce --in=$cache/$(basename {input}) --out=$cache/$(basename {output}) --bins={params.bins} --peptides={params.peptides} && "
"mv $cache/$(basename {output}) {output} && "
"rm -rf $cache"
rule irt_nonlinear_filter_pqp:
input:
rules.run_target_pqp.output
params:
bins = 1000,
peptides = 5
output:
"results/openswath/irt_nonlinear_{run}.pqp"
singularity:
"docker://grosenberger/easypqp:latest"
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"cp {input} $cache/$(basename {input}) && "
"easypqp reduce --in=$cache/$(basename {input}) --out=$cache/$(basename {output}) --bins={params.bins} --peptides={params.peptides} && "
"mv $cache/$(basename {output}) {output} && "
"rm -rf $cache"
rule openswath:
input:
pqp="data_library/library.pqp",
irt_linear=rules.irt_filter_pqp.output,
irt_nonlinear=rules.irt_nonlinear_filter_pqp.output,
mzxml="data_dia/{run}.mzXML",
output:
osw="results/openswath/{run}.osw"
params:
run="{run}"
singularity:
"docker://openswath/develop:latest"
threads: 4
resources:
mem_mb=lambda wildcards, attempt: attempt * 8192
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"cp {input.pqp} $cache/$(basename {input.pqp}) && cp {input.irt_linear} $cache/$(basename {input.irt_linear}) && cp {input.irt_nonlinear} $cache/$(basename {input.irt_nonlinear}) && cp {input.mzxml} $cache/$(basename {input.mzxml}) && "
"OpenSwathWorkflow -in $cache/$(basename {input.mzxml}) -tr $cache/$(basename {input.pqp}) -tr_irt $cache/$(basename {input.irt_linear}) -tr_irt_nonlinear $cache/$(basename {input.irt_nonlinear}) -out_osw $cache/$(basename {output.osw}) -threads {threads} -min_upper_edge_dist 1 -mz_extraction_window 30 -mz_extraction_window_unit ppm -mz_extraction_window_ms1 20 -mz_extraction_window_ms1_unit ppm -mz_correction_function regression_delta_ppm -use_ms1_traces -irt_mz_extraction_window 50 -irt_mz_extraction_window_unit ppm -rt_extraction_window 600 -RTNormalization:estimateBestPeptides -RTNormalization:alignmentMethod lowess -RTNormalization:outlierMethod none -Scoring:stop_report_after_feature 5 -Scoring:TransitionGroupPicker:compute_peak_quality false -Scoring:Scores:use_ms1_mi -Scoring:Scores:use_mi_score -threads {threads} -batchSize 1000 -ms1_isotopes 3 -enable_uis_scoring -Scoring:uis_threshold_sn -1 && "
"mv $cache/$(basename {output.osw}) {output.osw} && "
"rm -rf $cache"
rule pyprophet_subsample:
input:
rules.openswath.output.osw
params:
subsample_ratio = lambda wildcards, input: round(1.0/len(set(rules.openswath.output.osw)),3)
output:
"results/pyprophet/runspecific/{run}.osws"
singularity:
"docker://pyprophet/master:latest"
threads: 1
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"cp {input} $cache && "
"pyprophet subsample --subsample_ratio={params.subsample_ratio} --in=$cache/$(basename {input}) --out=$cache/$(basename {output}) && "
"mv $cache/$(basename {output}) {output} && "
"rm -rf $cache"
rule pyprophet_merge:
input:
template = rules.openswath.input.pqp,
osws = expand("results/pyprophet/runspecific/{run}.osws", run=run_ids)
output:
"results/pyprophet/runspecific/subsampled.osw"
singularity:
"docker://pyprophet/master:latest"
threads: 1
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"cp {input} $cache && "
"pyprophet merge --template=$cache/$(basename {input.template}) --out=$cache/$(basename {output}) $cache/*.osws && "
"mv $cache/$(basename {output}) {output} && "
"rm -rf $cache"
rule pyprophet_learn:
input:
rules.pyprophet_merge.output
output:
model = "results/pyprophet/runspecific/model.osw",
ms1ms2_report = "results/pyprophet/runspecific/model_ms1ms2_report.pdf",
#ms1_report = "results/pyprophet/runspecific/model_ms1_report.pdf",
transition_report = "results/pyprophet/runspecific/model_transition_report.pdf",
singularity:
"docker://pyprophet/master:latest"
threads: 4
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"cp {input} $cache/$(basename {output.model}) && "
"pyprophet score --classifier=XGBoost --in $cache/$(basename {output.model}) --level=ms1ms2 --xeval_num_iter=3 --ss_initial_fdr=0.05 --ss_iteration_fdr=0.01 --threads={threads} && "
#"pyprophet score --classifier=XGBoost --in $cache/$(basename {output.model}) --level=ms1 --xeval_num_iter=3 --ss_initial_fdr=0.3 --ss_iteration_fdr=0.1 --threads={threads} && "
"pyprophet score --classifier=XGBoost --in $cache/$(basename {output.model}) --level=transition --ipf_min_transition_sn=-1 --xeval_num_iter=3 --ss_initial_fdr=0.05 --ss_iteration_fdr=0.01 --threads={threads} && "
"mv $cache/$(basename {output.model}) {output.model} && "
"mv $cache/$(basename {output.ms1ms2_report}) {output.ms1ms2_report} && "
#"mv $cache/$(basename {output.ms1_report}) {output.ms1_report} && "
"mv $cache/$(basename {output.transition_report}) {output.transition_report} && "
"rm -rf $cache"
rule pyprophet_apply:
input:
osw = rules.openswath.output.osw,
model = rules.pyprophet_learn.output.model,
output:
osw = "results/pyprophet/runspecific/{run}.osw",
oswr = "results/pyprophet/runspecific/{run}.oswr"
singularity:
"docker://pyprophet/master:latest"
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"cp {input.osw} $cache && "
"pyprophet score --in $cache/$(basename {input.osw}) --out $cache/$(basename {output.osw}) --group_id=feature_id --classifier=XGBoost --apply_weights={input.model} --level=ms1ms2 && "
#"pyprophet score --in $cache/$(basename {input.osw}) --out $cache/$(basename {output.osw}) --group_id=feature_id --classifier=XGBoost --apply_weights={input.model} --level=ms1 && "
"pyprophet score --in $cache/$(basename {output.osw}) --classifier=XGBoost --apply_weights={input.model} --level=transition && "
"pyprophet ipf --no-ipf_ms1_scoring --no-ipf_ms2_scoring --ipf_grouped_fdr --in $cache/$(basename {output.osw}) && "
"pyprophet reduce --in $cache/$(basename {output.osw}) --out $cache/$(basename {output.oswr}) && "
"mv $cache/$(basename {output.osw}) {output.osw} && "
"mv $cache/$(basename {output.oswr}) {output.oswr} && "
"mv $cache/*.pdf results/pyprophet/runspecific/ && "
"rm -rf $cache"
rule pyprophet_global:
input:
template = rules.openswath.input.pqp,
oswr = expand("results/pyprophet/runspecific/{run}.oswr", run=run_ids)
output:
"results/pyprophet/global/model.oswr"
singularity:
"docker://pyprophet/master:latest"
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"cp {input.template} $cache && "
"cp {input.oswr} $cache && "
"pyprophet merge --template $cache/$(basename {input.template}) --out $cache/$(basename {output}) $cache/*.oswr && "
"pyprophet peptide --context=global --in $cache/$(basename {output}) && "
"pyprophet protein --context=global --in $cache/$(basename {output}) && "
"mv $cache/$(basename {output}) {output} && "
"mv $cache/*.pdf results/pyprophet/global/ && "
"rm -rf $cache"
rule pyprophet_backpropagate:
input:
osw = rules.pyprophet_apply.output.osw,
model = rules.pyprophet_global.output
output:
"results/pyprophet/integrated/{run}.osw"
singularity:
"docker://pyprophet/master:latest"
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"cp {input.osw} $cache && "
"cp {input.model} $cache && "
"pyprophet backpropagate --apply_scores $cache/$(basename {input.model}) --in $cache/$(basename {input.osw}) --out $cache/$(basename {output}) && "
"mv $cache/$(basename {output}) {output} && "
"rm -rf $cache"
rule tric_prepare:
input:
rules.pyprophet_backpropagate.output
output:
"results/tric/{run}.tsv"
singularity:
"docker://pyprophet/master:latest"
shell:
"cache=${{TMPDIR-/tmp/}}/$(cat /proc/sys/kernel/random/uuid)/ && mkdir -p $cache && "
"cp {input} $cache && "
"pyprophet export --in $cache/$(basename {input}) --out {output} --format=legacy_merged --max_rs_peakgroup_qvalue=0.05 --ipf_max_peptidoform_pep=1.0 --max_global_peptide_qvalue=1.0 --max_global_protein_qvalue=1.0 && "
"rm -rf $cache"
rule tric_feature_alignment:
input:
expand("results/tric/{run}.tsv", run=run_ids)
output:
long="results/tric/feature_alignment.tsv",
matrix="results/tric/feature_alignment_matrix.tsv",
check=temp(touch("tric_feature_alignment.done"))
singularity:
"docker://grosenberger/msproteomicstools:latest"
shell:
"feature_alignment.py --in {input} --out {output.long} --out_matrix {output.matrix} --method LocalMST --realign_method lowess_cython --max_rt_diff 60 --mst:useRTCorrection True --mst:Stdev_multiplier 3.0 --fdr_cutoff 0.01 --max_fdr_quality 0.05"