Skip to content

Commit ecf2a77

Browse files
authored
Add BCFtools - plotvcfstats module (nf-core#10100)
* Add BCFtools - plotvcfstats module * Update versions and meta handling for bcftools-plotvcfstats * Update versions in nf-test for bcftools_plotvcfstats * Add file_exist and stable_content to fit Conda environment for bcftools-plotvcfstats * BCFtools plotvcfstats - create symlink of PDF output * BCFtools plotvcfstat - update bcftools version * BCFtool plotvcfstats - update snapshot * BCFtools plotvcfstats - Singularity container format to https
1 parent c75d052 commit ecf2a77

5 files changed

Lines changed: 314 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
3+
channels:
4+
- conda-forge
5+
- bioconda
6+
dependencies:
7+
- bioconda::bcftools=1.23
8+
- bioconda::htslib=1.23
9+
- conda-forge::matplotlib=3.10.8
10+
- conda-forge::tectonic=0.15.0
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
process BCFTOOLS_PLOTVCFSTATS {
2+
tag "$meta.id"
3+
label 'process_single'
4+
5+
conda "${moduleDir}/environment.yml"
6+
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container
7+
? 'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/a1/a1a870916ebd80179b1432d79ca55108ed975a2694bd862803cb086f75087e17/data'
8+
: 'community.wave.seqera.io/library/bcftools_matplotlib_tectonic:b409553c39e037f0' }"
9+
10+
input:
11+
tuple val(meta), path(stats)
12+
13+
output:
14+
tuple val(meta), path("*plots*"), emit: plot_dir
15+
tuple val(meta), path("*.pdf") , emit: plot_pdf
16+
tuple val("${task.process}"), val('bcftools'), eval("bcftools --version | sed '1!d; s/^.*bcftools //'"), topic: versions, emit: versions_bcftools
17+
18+
when:
19+
task.ext.when == null || task.ext.when
20+
21+
script:
22+
def args = task.ext.args ?: ''
23+
def prefix = task.ext.prefix ?: "${meta.id}"
24+
25+
// plot-vcfstats requires an output directory, so create one with the prefix
26+
// The PDF output is also copied to the results directory with a standard name
27+
// HOME is set to a writable location to avoid matplotlib to fail when creating cache files
28+
29+
"""
30+
mkdir -p ${prefix}_plots
31+
mkdir nxf_home
32+
export HOME=\$PWD/nxf_home
33+
34+
plot-vcfstats \\
35+
-p ${prefix}_plots \\
36+
$args \\
37+
$stats
38+
39+
ln -s ${prefix}_plots/*.pdf ${prefix}.plot-vcfstats.pdf
40+
"""
41+
42+
stub:
43+
def prefix = task.ext.prefix ?: "${meta.id}"
44+
45+
"""
46+
mkdir ${prefix}_plots
47+
touch ${prefix}.plot-vcfstats.pdf
48+
"""
49+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: bcftools_plotvcfstats
2+
description: Plots the output of bcftools stats
3+
keywords:
4+
- visualization
5+
- stats
6+
- VCF
7+
tools:
8+
- plot:
9+
description: |
10+
Script for processing output of bcftools stats, plots graphs and creates a PDF presentation.
11+
homepage: http://samtools.github.io/bcftools/bcftools.html
12+
documentation: http://www.htslib.org/doc/bcftools.html
13+
doi: 10.1093/bioinformatics/btp352
14+
licence:
15+
- "MIT"
16+
identifier: biotools:bcftools
17+
input:
18+
- - meta:
19+
type: map
20+
description: |
21+
Groovy Map containing sample information
22+
e.g. [ id:'sample1' ]
23+
- stats:
24+
type: file
25+
description: Text file from BCFtools stats output
26+
pattern: "*_stats.txt"
27+
ontologies:
28+
- edam: "http://edamontology.org/format_2330"
29+
output:
30+
plot_dir:
31+
- - meta:
32+
type: map
33+
description: |
34+
Groovy Map containing sample information
35+
e.g. [ id:'sample1' ]
36+
- "*plots*":
37+
type: directory
38+
description: Output directory containing plots, raw data, and log files
39+
pattern: "*plots*"
40+
ontologies: []
41+
plot_pdf:
42+
- - meta:
43+
type: map
44+
description: |
45+
Groovy Map containing sample information
46+
e.g. [ id:'sample1' ]
47+
- "*.pdf":
48+
type: file
49+
description: (Link to the original) summary output in PDF
50+
pattern: "*.pdf"
51+
ontologies:
52+
- edam: "http://edamontology.org/format_3508"
53+
versions_bcftools:
54+
- - ${task.process}:
55+
type: string
56+
description: The name of the process
57+
- bcftools:
58+
type: string
59+
description: The name of the tool
60+
- bcftools --version | sed '1!d; s/^.*bcftools //':
61+
type: eval
62+
description: The expression to obtain the version of the tool
63+
topics:
64+
versions:
65+
- - ${task.process}:
66+
type: string
67+
description: The name of the process
68+
- bcftools:
69+
type: string
70+
description: The name of the tool
71+
- bcftools --version | sed '1!d; s/^.*bcftools //':
72+
type: eval
73+
description: The expression to obtain the version of the tool
74+
authors:
75+
- "@yz533cb"
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
nextflow_process {
2+
3+
name "Test Process BCFTOOLS_PLOTVCFSTATS"
4+
script "../main.nf"
5+
process "BCFTOOLS_PLOTVCFSTATS"
6+
7+
tag "modules"
8+
tag "modules_nfcore"
9+
tag "bcftools"
10+
tag "bcftools/plotvcfstats"
11+
tag "bcftools/stats"
12+
13+
setup {
14+
15+
run("BCFTOOLS_STATS") {
16+
script "../../stats/main.nf"
17+
process {
18+
"""
19+
input[0] = [
20+
[ id: "test" ], // meta map
21+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test.vcf.gz', checkIfExists: true), []]
22+
input[1] = [[:],[]]
23+
input[2] = [[:],[]]
24+
input[3] = [[:],[]]
25+
input[4] = [[:],[]]
26+
input[5] = [[:],[]]
27+
"""
28+
}
29+
}
30+
}
31+
32+
33+
test("sarscov2 - bcftools") {
34+
35+
when {
36+
process {
37+
"""
38+
input[0] = BCFTOOLS_STATS.out.stats
39+
"""
40+
}
41+
}
42+
43+
then {
44+
def stable_name = getAllFilesFromDir(process.out.plot_dir.get(0).get(1), relative: true, includeDir: true, ignore: [ '*.{aux,tex,log,pdf}' ])
45+
def stable_data_output = getAllFilesFromDir(process.out.plot_dir.get(0).get(1), ignore: [ '*.{aux,tex,log,pdf,png}' ] )
46+
assertAll(
47+
{ assert process.success },
48+
{ assert snapshot(
49+
stable_name,
50+
stable_data_output,
51+
process.out.findAll { key, val -> key.startsWith("versions")}
52+
).match() }
53+
)
54+
}
55+
56+
}
57+
58+
test("sarscov2 - bcftools - stub") {
59+
60+
options "-stub"
61+
62+
when {
63+
process {
64+
"""
65+
input[0] = BCFTOOLS_STATS.out.stats
66+
"""
67+
}
68+
}
69+
70+
then {
71+
assertAll(
72+
{ assert process.success },
73+
{ assert snapshot(process.out).match() }
74+
)
75+
}
76+
}
77+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"sarscov2 - bcftools - stub": {
3+
"content": [
4+
{
5+
"0": [
6+
[
7+
{
8+
"id": "test"
9+
},
10+
[
11+
12+
]
13+
]
14+
],
15+
"1": [
16+
[
17+
{
18+
"id": "test"
19+
},
20+
"test.plot-vcfstats.pdf:md5,d41d8cd98f00b204e9800998ecf8427e"
21+
]
22+
],
23+
"2": [
24+
[
25+
"BCFTOOLS_PLOTVCFSTATS",
26+
"bcftools",
27+
"1.23"
28+
]
29+
],
30+
"plot_dir": [
31+
[
32+
{
33+
"id": "test"
34+
},
35+
[
36+
37+
]
38+
]
39+
],
40+
"plot_pdf": [
41+
[
42+
{
43+
"id": "test"
44+
},
45+
"test.plot-vcfstats.pdf:md5,d41d8cd98f00b204e9800998ecf8427e"
46+
]
47+
],
48+
"versions_bcftools": [
49+
[
50+
"BCFTOOLS_PLOTVCFSTATS",
51+
"bcftools",
52+
"1.23"
53+
]
54+
]
55+
}
56+
],
57+
"timestamp": "2026-02-22T21:03:13.414399",
58+
"meta": {
59+
"nf-test": "0.9.4",
60+
"nextflow": "25.10.3"
61+
}
62+
},
63+
"sarscov2 - bcftools": {
64+
"content": [
65+
[
66+
"",
67+
"counts_by_af.indels.dat",
68+
"counts_by_af.snps.dat",
69+
"depth.0.dat",
70+
"depth.0.png",
71+
"indels.0.dat",
72+
"indels.0.png",
73+
"plot.py",
74+
"substitutions.0.png",
75+
"tstv_by_af.0.dat",
76+
"tstv_by_qual.0.dat"
77+
],
78+
[
79+
"counts_by_af.indels.dat:md5,82fae810b86c20ff99616c58ff3b3596",
80+
"counts_by_af.snps.dat:md5,2d67d9037c0201912501da281e345719",
81+
"depth.0.dat:md5,376f5fa0e18ad1bed94392f35a279622",
82+
"indels.0.dat:md5,e7e57c9a2709bfd3a32e8800d18c8eac",
83+
"plot.py:md5,d0a4a29a28aa5801d5b24f7327f156f7",
84+
"tstv_by_af.0.dat:md5,a0720408cad0e871e95c121b1b660caf",
85+
"tstv_by_qual.0.dat:md5,297e400d8c9e94b1c035719c4a015081"
86+
],
87+
{
88+
"versions_bcftools": [
89+
[
90+
"BCFTOOLS_PLOTVCFSTATS",
91+
"bcftools",
92+
"1.23"
93+
]
94+
]
95+
}
96+
],
97+
"timestamp": "2026-02-22T21:03:01.301575",
98+
"meta": {
99+
"nf-test": "0.9.4",
100+
"nextflow": "25.10.3"
101+
}
102+
}
103+
}

0 commit comments

Comments
 (0)