Skip to content

Commit 58de67f

Browse files
authored
Replace --annotations_filter with --filter (#109)
* move the filter outside of the annotations * no longer use permissive overlaps in vcfanno * fix tests * update changelog and docs * fix linting * make toml channel a value channel * Update CHANGELOG.md
1 parent 81d4118 commit 58de67f

10 files changed

Lines changed: 47 additions & 122 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
6. Removed the old output publishing code and used the new workflow output definitions instead
2222
7. Bumped the minimal nextflow version to 24.10.0
2323
8. VCFanno will now run when `--vcfanno_toml` has been given and `--annotate` has not been given. You still need to supply `--annotate` to get the full annotation, but this can be used check for common variants without having to perform full annotation.
24-
9. Removed the `--delly_sv_types` parameter.
24+
9. Changed the `--annotations_filter` parameter to a `--filter` parameter. This parameter takes an argument of `bcftools filter` to filter the resulting VCFs.
25+
10. Removed the `--delly_sv_types` parameter.
2526

2627
### `Fixed`
2728

conf/modules.config

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,18 @@ process {
251251

252252
withName: "^.*VCF_ANNOTATE_VCFANNO:VCFANNO\$" {
253253
ext.prefix = {"${meta.id}.${meta.variant_type}.vcfanno"}
254-
ext.args = "-permissive-overlap -ends"
254+
ext.args = "-ends"
255255
}
256256

257-
withName: "^.*VCF_ANNOTATE_VCFANNO:BCFTOOLS_FILTER\$" {
257+
/*
258+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259+
SV AND CNV FILTERING
260+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
261+
*/
262+
263+
withName: "^.*STRUCTURAL:BCFTOOLS_FILTER\$" {
258264
ext.prefix = {"${meta.id}.${meta.variant_type}.filtered"}
259-
ext.args = "${params.annotations_filter} --output-type z --write-index=tbi"
265+
ext.args = "${params.filter} --output-type z --write-index=tbi"
260266
}
261267

262268
/*

docs/parameters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Options specific to the execution of this pipeline
8080
| `cnv_callers_support` | The minimum amount of CNV callers that should detect a variant. All variants that have a lower amount of callers supporting it, will be removed. (Only used when more than one caller is given) | `integer` | 1 | | |
8181
| `annotate` | Run the annotation with Ensembl VEP and AnnotSV (and optionally VCFanno). | `boolean` | | | |
8282
| `concat_output` | Also output a concatenated VCF with all variant types analysed included. | `boolean` | | | |
83-
| `annotations_filter` | The filter arguments to use after annotating. <details><summary>Help</summary><small>A common use case for this is to filter out common variants. You can supply a VCF file with common variants to VCFanno and filter out the matching variants using this parameter</small></details> | `string` | | | |
83+
| `filter` | The filter options to perform on SV and CNV VCF files as postprocessing <details><summary>Help</summary><small>A common use case for this is to filter out common variants. You can supply a VCF file with common variants to VCFanno and filter out the matching variants using this parameter</small></details> | `string` | | | |
8484

8585
## Delly parameters
8686

main.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ workflow {
111111
params.species,
112112
params.vep_assembly,
113113
params.vep_cache_version,
114-
params.annotations_filter,
114+
params.filter,
115115
params.outdir
116116
)
117117
//

nextflow.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ params {
2020
cnv_callers_support = 1
2121
annotate = false
2222
concat_output = false
23-
annotations_filter = null
23+
filter = null
2424
bedpe = false
2525

2626
// Delly parameters

nextflow_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,9 @@
331331
"type": "boolean",
332332
"description": "Also output a concatenated VCF with all variant types analysed included."
333333
},
334-
"annotations_filter": {
334+
"filter": {
335335
"type": "string",
336-
"description": "The filter arguments to use after annotating.",
336+
"description": "The filter options to perform on SV and CNV VCF files as postprocessing",
337337
"help_text": "A common use case for this is to filter out common variants. You can supply a VCF file with common variants to VCFanno and filter out the matching variants using this parameter"
338338
},
339339
"bedpe": {

subworkflows/local/vcf_annotate_vcfanno/main.nf

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ workflow VCF_ANNOTATE_VCFANNO {
1111
ch_sample_specific_resources // channel: [optional] [ val(meta), path(vcf), path(tbi) ] Files containing resources that are sample-specific
1212
ch_vcfanno_lua // channel: [optional] [ path(lua) ] => The lua script to influence VCFanno
1313
val_vcfanno_resources // list: [optional] [ path(file1, file2, file3...) ] => The extra VCFanno files
14-
filter // string: [optional] => A filter pattern to use after annotating
1514
vcfanno_toml // file: [optional] => A vcfanno TOML config
1615
default_vcfanno_tomls // list: [mandatory] => A list of default vcfanno configs to be concatenated with the input TOML
1716
annotate // boolean: [mandatory] => Whether or not to run the full annotation or only the specified annotations
@@ -31,7 +30,7 @@ workflow VCF_ANNOTATE_VCFANNO {
3130
}
3231
ch_vcfanno_input = ch_vcfs.join(ch_collected_specific_resources, failOnMismatch:true, failOnDuplicate:true)
3332
} else {
34-
ch_vcfanno_toml = Channel.fromPath(vcfanno_toml)
33+
ch_vcfanno_toml = Channel.fromPath(vcfanno_toml).collect()
3534
ch_vcfanno_input = ch_vcfs.map { meta, vcf, tbi ->
3635
[ meta, vcf, tbi, [] ]
3736
}
@@ -45,19 +44,7 @@ workflow VCF_ANNOTATE_VCFANNO {
4544
)
4645
ch_versions = ch_versions.mix(VCFANNO.out.versions)
4746

48-
def ch_vcfanno_output = VCFANNO.out.vcf.join(VCFANNO.out.tbi, failOnDuplicate:true, failOnMismatch:true)
49-
50-
def ch_annotated_vcfs = Channel.empty()
51-
if(filter) {
52-
BCFTOOLS_FILTER(
53-
ch_vcfanno_output
54-
)
55-
ch_versions = ch_versions.mix(BCFTOOLS_FILTER.out.versions.first())
56-
57-
ch_annotated_vcfs = BCFTOOLS_FILTER.out.vcf.join(BCFTOOLS_FILTER.out.tbi, failOnDuplicate:true, failOnMismatch:true)
58-
} else {
59-
ch_annotated_vcfs = ch_vcfanno_output
60-
}
47+
def ch_annotated_vcfs = VCFANNO.out.vcf.join(VCFANNO.out.tbi, failOnDuplicate:true, failOnMismatch:true)
6148

6249
emit:
6350
vcfs = ch_annotated_vcfs // channel: [ val(meta), path(vcf), path(tbi) ]

tests/subworkflows/local/vcf_annotate_vcfanno/main.nf.test

Lines changed: 8 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,9 @@ nextflow_workflow {
1010

1111
options "-stub"
1212

13-
test("homo_sapiens - no_filter, annotate") {
13+
test("homo_sapiens - annotate") {
1414

1515
when {
16-
params {
17-
annotations_filter = null
18-
}
19-
workflow {
20-
"""
21-
def meta = [id:"test", sample:"test", sex:"male", family: "test1", family_count:1, hpo:[], variant_type:'sv']
22-
input[0] = Channel.of([
23-
meta,
24-
file(params.sv_vcf1, checkIfExists:true),
25-
file(params.sv_tbi1, checkIfExists:true)
26-
])
27-
input[1] = Channel.of([
28-
meta,
29-
[],
30-
[]
31-
])
32-
input[2] = []
33-
input[3] = []
34-
input[4] = params.annotations_filter
35-
input[5] = []
36-
input[6] = files("\${params.vcfanno_tomls}/*.toml", checkIfExists:true)
37-
input[7] = true
38-
"""
39-
}
40-
}
41-
42-
then {
43-
assertAll(
44-
{ assert workflow.success },
45-
{ assert snapshot(
46-
workflow.out.collectEntries { key, value ->
47-
if(key.matches("^\\d+\$") || key.matches('versions')) {
48-
return null
49-
}
50-
return [ key, value ]
51-
}.findAll { it != null }
52-
).match() }
53-
)
54-
}
55-
56-
}
57-
58-
test("homo_sapiens - filter, no_annotate") {
59-
60-
when {
61-
params {
62-
annotations_filter = "-i FILTER='PASS'"
63-
}
6416
workflow {
6517
"""
6618
def meta = [id:"test", sample:"test", sex:"male", family: "test1", family_count:1, hpo:[], variant_type:'sv']
@@ -76,10 +28,9 @@ nextflow_workflow {
7628
])
7729
input[2] = []
7830
input[3] = []
79-
input[4] = params.annotations_filter
80-
input[5] = files("\${params.vcfanno_tomls}/*.toml", checkIfExists:true)[0]
81-
input[6] = files("\${params.vcfanno_tomls}/*.toml", checkIfExists:true)
82-
input[7] = false
31+
input[4] = []
32+
input[5] = files("\${params.vcfanno_tomls}/*.toml", checkIfExists:true)
33+
input[6] = true
8334
"""
8435
}
8536
}
@@ -100,12 +51,9 @@ nextflow_workflow {
10051

10152
}
10253

103-
test("homo_sapiens - filter, annotate") {
54+
test("homo_sapiens - no_annotate") {
10455

10556
when {
106-
params {
107-
annotations_filter = null
108-
}
10957
workflow {
11058
"""
11159
def meta = [id:"test", sample:"test", sex:"male", family: "test1", family_count:1, hpo:[], variant_type:'sv']
@@ -121,10 +69,9 @@ nextflow_workflow {
12169
])
12270
input[2] = []
12371
input[3] = []
124-
input[4] = params.annotations_filter
125-
input[5] = []
126-
input[6] = files("\${params.vcfanno_tomls}/*.toml", checkIfExists:true)
127-
input[7] = true
72+
input[4] = files("\${params.vcfanno_tomls}/*.toml", checkIfExists:true)[0]
73+
input[5] = files("\${params.vcfanno_tomls}/*.toml", checkIfExists:true)
74+
input[6] = false
12875
"""
12976
}
13077
}

tests/subworkflows/local/vcf_annotate_vcfanno/main.nf.test.snap

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,5 @@
11
{
2-
"homo_sapiens - filter, no_annotate": {
3-
"content": [
4-
{
5-
"vcfs": [
6-
[
7-
{
8-
"id": "test",
9-
"sample": "test",
10-
"sex": "male",
11-
"family": "test1",
12-
"family_count": 1,
13-
"hpo": [
14-
15-
],
16-
"variant_type": "sv"
17-
},
18-
"test.sv.filtered.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
19-
"test.sv.filtered.vcf.gz.tbi:md5,d41d8cd98f00b204e9800998ecf8427e"
20-
]
21-
]
22-
}
23-
],
24-
"meta": {
25-
"nf-test": "0.9.1",
26-
"nextflow": "24.10.4"
27-
},
28-
"timestamp": "2025-02-10T16:55:00.763124808"
29-
},
30-
"homo_sapiens - filter, annotate": {
2+
"homo_sapiens - no_annotate": {
313
"content": [
324
{
335
"vcfs": [
@@ -53,9 +25,9 @@
5325
"nf-test": "0.9.1",
5426
"nextflow": "24.10.4"
5527
},
56-
"timestamp": "2025-02-10T16:55:09.970621986"
28+
"timestamp": "2025-02-12T14:07:01.425728203"
5729
},
58-
"homo_sapiens - no_filter, annotate": {
30+
"homo_sapiens - annotate": {
5931
"content": [
6032
{
6133
"vcfs": [
@@ -81,6 +53,6 @@
8153
"nf-test": "0.9.1",
8254
"nextflow": "24.10.4"
8355
},
84-
"timestamp": "2025-02-10T16:54:50.521405941"
56+
"timestamp": "2025-02-12T14:06:51.583328891"
8557
}
8658
}

workflows/structural.nf

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ include { ANNOTSV_INSTALLANNOTATIONS } from '../modules/nf-core/annotsv/i
4343
include { UNTAR as UNTAR_ANNOTSV } from '../modules/nf-core/untar/main'
4444
include { UNTAR as UNTAR_BWA } from '../modules/nf-core/untar/main'
4545
include { NGSBITS_SAMPLEGENDER } from '../modules/nf-core/ngsbits/samplegender/main'
46+
include { BCFTOOLS_FILTER } from '../modules/nf-core/bcftools/filter/main'
4647
include { SVTOOLS_VCFTOBEDPE } from '../modules/nf-core/svtools/vcftobedpe/main'
4748
include { MULTIQC } from '../modules/nf-core/multiqc/main'
4849

@@ -95,7 +96,7 @@ workflow STRUCTURAL {
9596
species // The species to be used by VEP
9697
vep_assembly // The genome assembly to be downloaded for VEP
9798
vep_cache_version // The version of the VEP cache to use
98-
annotations_filter // The filter pattern to use after annotation
99+
filter // The filter pattern to use after annotation
99100
outdir // The output directory of the pipeline
100101

101102
main:
@@ -409,22 +410,33 @@ workflow STRUCTURAL {
409410
ch_annotation_output = ch_annotation_input
410411
}
411412

412-
def ch_outputs = Channel.empty()
413+
def ch_vcfanno_output = Channel.empty()
413414
if(annotate || vcfanno_toml) {
414415
VCF_ANNOTATE_VCFANNO(
415416
ch_annotation_output,
416417
ch_annotsv_vcfs,
417418
ch_vcfanno_lua,
418419
val_vcfanno_resources,
419-
annotations_filter,
420420
val_vcfanno_toml,
421421
val_default_vcfanno_tomls,
422422
annotate
423423
)
424424
ch_versions = ch_versions.mix(VCF_ANNOTATE_VCFANNO.out.versions)
425-
ch_outputs = ch_outputs.mix(VCF_ANNOTATE_VCFANNO.out.vcfs)
425+
ch_vcfanno_output = VCF_ANNOTATE_VCFANNO.out.vcfs
426+
} else {
427+
ch_vcfanno_output = ch_annotation_input
428+
}
429+
430+
def ch_outputs = Channel.empty()
431+
if(filter) {
432+
BCFTOOLS_FILTER(
433+
ch_vcfanno_output
434+
)
435+
def ch_filter_output = BCFTOOLS_FILTER.out.vcf.join(BCFTOOLS_FILTER.out.tbi, failOnMismatch:true, failOnDuplicate:true)
436+
ch_outputs = ch_outputs.mix(ch_filter_output)
437+
ch_versions = ch_versions.mix(BCFTOOLS_FILTER.out.versions)
426438
} else {
427-
ch_outputs = ch_outputs.mix(ch_annotation_input)
439+
ch_outputs = ch_outputs.mix(ch_vcfanno_output)
428440
}
429441

430442
//

0 commit comments

Comments
 (0)