-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpipeline.nf
264 lines (202 loc) · 6.63 KB
/
pipeline.nf
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
#!/usr/bin/env nextflow
/*
* The following pipeline parameters specify the refence genomes
* and fastq files and can be provided as command line options
*/
params.input = "input.csv"
params.outdir = "results"
params.ref = "/tools/GRCh38_full_analysis_set_plus_decoy_hla.fa"
params.threads = 30
params.mem = 50
workflow {
files = Channel.fromPath(params.input).splitCsv()
ALIGN_PB(files)
ALIGN_ONT(files)
PBSV(ALIGN_PB.out.bam, ALIGN_PB.out.sample, ALIGN_PB.out.index)
Sniffles(ALIGN_ONT.out.bam, ALIGN_ONT.out.sample, ALIGN_ONT.out.index)
CuteSV(ALIGN_ONT.out.bam, ALIGN_ONT.out.sample, ALIGN_ONT.out.index)
Svim(ALIGN_ONT.out.bam, ALIGN_ONT.out.sample, ALIGN_ONT.out.index)
Dysgu(ALIGN_ONT.out.bam, ALIGN_ONT.out.sample, ALIGN_ONT.out.index)
Nanovar(ALIGN_ONT.out.bam, ALIGN_ONT.out.sample, ALIGN_ONT.out.index)
ConsensuSV_ONT(ALIGN_ONT.out.sample, PBSV.out.vcf_filtered, Sniffles.out.vcf_filtered, CuteSV.out.vcf_filtered, Svim.out.vcf_filtered, Dysgu.out.vcf_filtered, Nanovar.out.vcf_filtered, ALIGN_ONT.out.bam, ALIGN_ONT.out.index)
}
process ALIGN_PB {
tag "Create align for Pac Bio Callers"
publishDir "${params.outdir}/aligment/${fastq.simpleName}"
input:
path fastq
output:
path 'output_pb.bam', emit: bam
path 'output_pb.bam.bai', emit: index
val fastq.simpleName, emit: sample
script:
"""
pbmm2 align ${params.ref} $fastq output_pb.bam --sort --preset CCS --sample sample1 --rg '@RG\tID:movie1'
"""
}
process ALIGN_ONT {
tag "Create align for Oxord Nanopore Technology Callers"
publishDir "${params.outdir}/aligment/${fastq.simpleName}"
input:
path fastq
output:
path 'output_ont.bam', emit: bam
path 'output_ont.bam.bai', emit: index
val fastq.simpleName, emit: sample
script:
"""
minimap2 -t ${params.threads} -ax map-ont --MD ${params.ref} $fastq > file.sam
samtools view -@ ${params.threads} -S -b file.sam > file.bam
samtools sort -@ ${params.threads} file.bam -o file.sorted.bam
samtools view -@ ${params.threads} -b -F 4 file.sorted.bam > output_ont.bam
samtools index -@ ${params.threads} output_ont.bam
rm file.sam file.bam file.sorted.bam
"""
}
process PBSV {
tag "Calling PBSV"
publishDir "${params.outdir}/vcfs/${sample}"
input:
path bam
val sample
path bai
output:
path "pbsv.vcf", emit: vcf
path "pbsv_filtered.vcf", emit: vcf_filtered
script:
"""
pbsv discover $bam pbsv.svsig.gz
tabix -c '#' -s 3 -b 4 -e 4 pbsv.svsig.gz
pbsv call -j ${params.threads} ${params.ref} pbsv.svsig.gz pbsv.vcf
bcftools view -i 'INFO/IMPRECISE=0' pbsv.vcf > pbsv_filtered.vcf
"""
}
process Sniffles {
tag "Calling Sniffles"
publishDir "${params.outdir}/vcfs/${sample}"
input:
path bam
val sample
path bai
output:
path "sniffles.vcf", emit: vcf
path "sniffles_filtered.vcf", emit: vcf_filtered
script:
"""
sniffles -t ${params.threads} -i $bam -v sniffles.vcf --minsvlen 50
bcftools view -i 'INFO/IMPRECISE=0' sniffles.vcf > sniffles_filtered.vcf
"""
}
process CuteSV {
tag "Calling CuteSV"
publishDir "${params.outdir}/vcfs/${sample}"
input:
path bam
val sample
path bai
output:
path "cuteSV.vcf", emit: vcf
path "cuteSV_filtered.vcf", emit: vcf_filtered
script:
"""
cuteSV -t ${params.threads} -l 50 -s 5 $bam ${params.ref} cuteSV.vcf .
bcftools view -i 'INFO/RE>10' cuteSV.vcf > cuteSV_filtered.vcf
"""
}
process Svim {
tag "Calling Svim"
publishDir "${params.outdir}/vcfs/${sample}"
input:
path bam
val sample
path bai
output:
path "svim.vcf", emit: vcf
path "svim_filtered.vcf", emit: vcf_filtered
script:
"""
svim alignment . $bam ${params.ref}
bcftools sort variants.vcf > svim.vcf
bcftools view -i 'QUAL>=10' svim.vcf > svim_filtered.vcf
"""
}
process Dysgu {
tag "Calling Dysgu"
publishDir "${params.outdir}/vcfs/${sample}"
input:
path bam
val sample
path bai
output:
path "dysgu.vcf", emit: vcf
path "dysgu_filtered.vcf", emit: vcf_filtered
script:
"""
dysgu call --mode nanopore ${params.ref} temp $bam > dysgu.vcf
bcftools view -i 'FORMAT/PROB>0.5' dysgu.vcf > dysgu_filtered.vcf
"""
}
process Nanovar {
tag "Calling Nanovar"
conda "/tools/anaconda/envs/workspace"
publishDir "${params.outdir}/vcfs/${sample}"
input:
path bam
val sample
path bai
output:
path "nanovar.vcf", emit: vcf
path "nanovar_filtered.vcf", emit: vcf_filtered
script:
"""
nanovar -t ${params.threads} -x ont $bam -l 50 ${params.ref} . --mdb /tools/ncbi-blast-2.3.0+/bin/makeblastdb --wmk /tools//ncbi-blast-2.3.0+/bin/windowmasker --hsb /tools/queries/hs-blastn-src/v0.0.5/hs-blastn
mv output_ont.nanovar.pass.vcf nanovar.vcf
bcftools view -i 'INFO/NN>0.5 & INFO/SVLEN!="."' nanovar.vcf > nanovar_filtered.vcf
"""
}
process ConsensuSV_ONT {
tag "Truvari variants merging and collapsing"
conda "/tools/anaconda/envs/workspace"
publishDir "${params.outdir}/vcfs/${sample}"
input:
val sample
path pbsv_vcf
path sniffles_vcf
path cutesv_vcf
path svim_vcf
path dysgu_vcf
path nanovar_vcf
path bam
path index
output:
path 'consensuSV-ONT_DEL.vcf'
path 'consensuSV-ONT_INS.vcf'
script:
"""
bgzip -c $nanovar_vcf > ${nanovar_vcf}.gz
tabix -p vcf ${nanovar_vcf}.gz
bgzip -c $dysgu_vcf > ${dysgu_vcf}.gz
tabix -p vcf ${dysgu_vcf}.gz
bgzip -c $svim_vcf > ${svim_vcf}.gz
tabix -p vcf ${svim_vcf}.gz
bgzip -c $cutesv_vcf > ${cutesv_vcf}.gz
tabix -p vcf ${cutesv_vcf}.gz
bgzip -c $sniffles_vcf > ${sniffles_vcf}.gz
tabix -p vcf ${sniffles_vcf}.gz
bgzip -c $pbsv_vcf > ${pbsv_vcf}.gz
tabix -p vcf ${pbsv_vcf}.gz
bcftools merge -m none ${nanovar_vcf}.gz ${pbsv_vcf}.gz ${sniffles_vcf}.gz ${cutesv_vcf}.gz ${svim_vcf}.gz ${dysgu_vcf}.gz --force-samples > ${sample}_merged.vcf
bgzip -c ${sample}_merged.vcf > ${sample}_merged.vcf.gz
tabix -p vcf ${sample}_merged.vcf.gz
bcftools view -i 'INFO/SVTYPE="DEL"' ${sample}_merged.vcf > ${sample}_merged_DEL.vcf
bcftools view -i 'INFO/SVTYPE="INS" | INFO/SVTYPE="DUP"' ${sample}_merged.vcf >${sample}_merged_INS.vcf
bgzip -c ${sample}_merged_DEL.vcf > ${sample}_merged_DEL.vcf.gz
tabix -p vcf ${sample}_merged_DEL.vcf.gz
bgzip -c ${sample}_merged_INS.vcf > ${sample}_merged_INS.vcf.gz
tabix -p vcf ${sample}_merged_INS.vcf.gz
truvari collapse -p=0 -i ${sample}_merged_DEL.vcf.gz -o ${sample}_truvari_merged_DEL.vcf -c ${sample}_truvari_collapsed_DEL.vcf
truvari collapse -p=0 -i ${sample}_merged_INS.vcf.gz -o ${sample}_truvari_merged_INS.vcf -c ${sample}_truvari_collapsed_INS.vcf
python /tools/ConsensusSV-ONT-pipeline/consensusv_ont.py -i ${sample}_truvari_merged_DEL.vcf -b $bam -t DEL -s $sample -o consensuSV-ONT_DEL.vcf
python /tools/ConsensusSV-ONT-pipeline/consensusv_ont.py -i ${sample}_truvari_merged_INS.vcf -b $bam -t INS -s $sample -o consensuSV-ONT_INS.vcf
"""
}