Skip to content

Commit

Permalink
Ngscheckmate (nf-core#3094)
Browse files Browse the repository at this point in the history
* Fix version string spurious text in singularity tests

* Add NGSCheckMate subworkflow

* Remember to save files

* Fix bracket

* Update meta

* Update meta/channel name

* Update NCM

* Update ncm test

* Add the config file

* Remove tests on bcftools files as failing conda

* Update subworkflows/nf-core/bam_ngscheckmate/main.nf

Co-authored-by: Maxime U Garcia <[email protected]>

* Update subworkflows/nf-core/bam_ngscheckmate/main.nf

Co-authored-by: Maxime U Garcia <[email protected]>

* Update subworkflows/nf-core/bam_ngscheckmate/main.nf

---------

Co-authored-by: SPearce <[email protected]>
Co-authored-by: Maxime U Garcia <[email protected]>
Co-authored-by: Maxime U Garcia <[email protected]>
  • Loading branch information
4 people authored Mar 30, 2023
1 parent aa90540 commit 3cfd245
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 24 deletions.
2 changes: 1 addition & 1 deletion modules/nf-core/ngscheckmate/ncm/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ process NGSCHECKMATE_NCM {
path "*_corr_matrix.txt", emit: corr_matrix
path "*_matched.txt" , emit: matched
path "*_all.txt" , emit: all
path "*.vcf" , emit: vcfs, optional: true
path "*.vcf" , emit: vcf, optional: true
path "versions.yml" , emit: versions

when:
Expand Down
4 changes: 2 additions & 2 deletions modules/nf-core/ngscheckmate/ncm/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ output:
description: A txt file containing all the sample comparisons, whether they match or not
pattern: "*all.txt"

- vcfs:
- vcf:
type: file
description: If ran in bam mode, vcf files for each sample giving the SNP calls
description: If ran in bam mode, vcf files for each sample giving the SNP calls used
pattern: "*.vcf"

authors:
Expand Down
39 changes: 39 additions & 0 deletions subworkflows/nf-core/bam_ngscheckmate/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
include { BCFTOOLS_MPILEUP } from '../../../modules/nf-core/bcftools/mpileup/main'
include { NGSCHECKMATE_NCM } from '../../../modules/nf-core/ngscheckmate/ncm/main.nf'

workflow BAM_NGSCHECKMATE {

take:
ch_bam // channel: [ val(meta), bam ]
ch_bed // channel: [ bed ]
ch_fasta // channel: [ fasta ]

main:

ch_versions = Channel.empty()

ch_bam_bed = ch_bam.combine(ch_bed)

BCFTOOLS_MPILEUP (ch_bam_bed, ch_fasta.collect(), false)
ch_versions = ch_versions.mix(BCFTOOLS_MPILEUP.out.versions)

BCFTOOLS_MPILEUP
.out
.vcf
.map{meta, vcf -> vcf}
.collect()
.set {ch_flat_vcfs}

NGSCHECKMATE_NCM (ch_flat_vcfs, ch_bed, ch_fasta)
ch_versions = ch_versions.mix(NGSCHECKMATE_NCM.out.versions)

emit:
pdf = NGSCHECKMATE_NCM.out.pdf // channel: [ pdf ]
corr_matrix = NGSCHECKMATE_NCM.out.corr_matrix // channel: [ corr_matrix ]
matched = NGSCHECKMATE_NCM.out.matched // channel: [ matched ]
all = NGSCHECKMATE_NCM.out.all // channel: [ all ]
vcf = BCFTOOLS_MPILEUP.out.vcf // channel: [ meta, vcf ]
versions = ch_versions // channel: [ versions.yml ]

}

55 changes: 55 additions & 0 deletions subworkflows/nf-core/bam_ngscheckmate/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: "bam_ngscheckmate"
description: Take a set of bam files and run NGSCheckMate to determine whether samples match with each other, using a set of SNPs.
keywords:
- ngscheckmate
- qc
modules:
- bcftools/mpileup
- ngscheckmate/ncm
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test' ]
- bam:
type: file
description: BAM files for each sample
pattern: "*.{bam}"
- snp_bed:
type: file
description: BED file containing the SNPs to analyse. NGSCheckMate provides some default ones for hg19/hg38.
pattern: "*.{bed}"

- fasta:
type: file
description: fasta file for the genome
pattern: "*.{fasta}"

output:
- pdf:
type: file
description: A pdf containing a dendrogram showing how the samples match up
pattern: "*.{pdf}"
- corr_matrix:
type: file
description: A text file containing the correlation matrix between each sample
pattern: "*corr_matrix.txt"
- matched:
type: file
description: A txt file containing only the samples that match with each other
pattern: "*matched.txt"
- all:
type: file
description: A txt file containing all the sample comparisons, whether they match or not
pattern: "*all.txt"
- vcf:
type: file
description: vcf files for each sample giving the SNP calls
pattern: "*.vcf"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@SPPearce"
4 changes: 4 additions & 0 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3216,6 +3216,10 @@ subworkflows/bam_markduplicates_picard:
- subworkflows/nf-core/bam_markduplicates_picard/**
- tests/subworkflows/nf-core/bam_markduplicates_picard/**

subworkflows/bam_ngscheckmate:
- subworkflows/nf-core/bam_ngscheckmate/**
- tests/subworkflows/nf-core/bam_ngscheckmate/**

subworkflows/bam_qc_picard:
- subworkflows/nf-core/bam_qc_picard/**
- tests/subworkflows/nf-core/bam_qc_picard/**
Expand Down
32 changes: 17 additions & 15 deletions tests/modules/nf-core/ngscheckmate/ncm/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include { NGSCHECKMATE_NCM as NGSCHECKMATE_NCM_VCF} from '../../../../../modules
include { BEDTOOLS_MAKEWINDOWS } from '../../../../../modules/nf-core/bedtools/makewindows/main.nf'

include { BCFTOOLS_MPILEUP } from '../../../../../modules/nf-core/bcftools/mpileup/main.nf'
include { BCFTOOLS_MPILEUP as BCFTOOLS_MPILEUP2 } from '../../../../../modules/nf-core/bcftools/mpileup/main.nf'
include { BCFTOOLS_MPILEUP as BCFTOOLS_MPILEUP_TWO } from '../../../../../modules/nf-core/bcftools/mpileup/main.nf'

workflow test_ngscheckmate_ncm_bam {
input = [ file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam'], checkIfExists: true),
Expand All @@ -21,8 +21,8 @@ workflow test_ngscheckmate_ncm_bam {
inputBed = [ [ id:'test'],
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)]

BEDTOOLS_MAKEWINDOWS(inputBed, true).
tab.
BEDTOOLS_MAKEWINDOWS(inputBed).
bed.
map{it[1]}.
view().
set{snp_channel}
Expand All @@ -31,28 +31,30 @@ workflow test_ngscheckmate_ncm_bam {
}

workflow test_ngscheckmate_ncm_vcf {
input1 = [ [ id:'test1' ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ]
]

input2 = [ [ id:'test2' ], // meta map
[ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ]
]

fasta = [ file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) ]

inputBed = [ [ id:'test'],
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)]
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)]

input1 = [ [ id:'test1' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)
]

input2 = [ [ id:'test2' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)
]

BCFTOOLS_MPILEUP ( input1, fasta, false )
BCFTOOLS_MPILEUP2 ( input2, fasta, false )
BCFTOOLS_MPILEUP_TWO ( input2, fasta, false )

BCFTOOLS_MPILEUP2.out.vcf.
BCFTOOLS_MPILEUP_TWO.out.vcf.
combine( BCFTOOLS_MPILEUP.out.vcf ).
map { [ it[1], it[3] ] }.
set { vcf_channel }

BEDTOOLS_MAKEWINDOWS( inputBed, true ).tab.
BEDTOOLS_MAKEWINDOWS( inputBed).bed.
map { it[1] }.
view().
set { snp_channel }
Expand Down
5 changes: 3 additions & 2 deletions tests/modules/nf-core/ngscheckmate/ncm/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ process {

withName: BEDTOOLS_MAKEWINDOWS {
ext.args = '-w 1'
ext.prefix = 'test_split'
}

withName: BCFTOOLS_MPILEUP {
ext.args2 = '--no-version --ploidy 1 --multiallelic-caller'
ext.args3 = '--no-version'
}

withName: BCFTOOLS_MPILEUP2 {
withName: BCFTOOLS_MPILEUP_TWO {
ext.args2 = '--no-version --ploidy 1 --multiallelic-caller'
ext.args3 = '--no-version'
}
Expand All @@ -24,4 +25,4 @@ process {
ext.args = '-B'
}

}
}
23 changes: 19 additions & 4 deletions tests/modules/nf-core/ngscheckmate/ncm/test.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
- name: ngscheckmate ncm test_ngscheckmate_ncm_bam
command: nextflow run ./tests/modules/nf-core/ngscheckmate/ncm -entry test_ngscheckmate_ncm_bam -c ./tests/config/nextflow.config
command: nextflow run ./tests/modules/nf-core/ngscheckmate/ncm -entry test_ngscheckmate_ncm_bam -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/ngscheckmate/ncm/nextflow.config
tags:
- ngscheckmate/ncm
- ngscheckmate
files:
- path: output/bedtools/test_split.bed
md5sum: 5058157987313b598f1c260e6965d6f7
- path: output/bedtools/versions.yml
- path: output/ngscheckmate/output.pdf
- path: output/ngscheckmate/output_all.txt
md5sum: f71a712c3f6ecf64dd526365212f1b7c
- path: output/ngscheckmate/output_corr_matrix.txt
md5sum: 6777377aa9ae3d57f841b12896318db0
- path: output/ngscheckmate/output_matched.txt
md5sum: f71a712c3f6ecf64dd526365212f1b7c
- path: output/ngscheckmate/test.paired_end.methylated.sorted.vcf
- path: output/ngscheckmate/test.paired_end.sorted.vcf
- path: output/ngscheckmate/versions.yml
md5sum: fbb2bebd65b4f4e1e93c6bf5c08a6829

- name: ngscheckmate ncm test_ngscheckmate_ncm_vcf
command: nextflow run ./tests/modules/nf-core/ngscheckmate/ncm -entry test_ngscheckmate_ncm_vcf -c ./tests/config/nextflow.config
command: nextflow run ./tests/modules/nf-core/ngscheckmate/ncm -entry test_ngscheckmate_ncm_vcf -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/ngscheckmate/ncm/nextflow.config
tags:
- ngscheckmate/ncm
- ngscheckmate
files:
- path: output/bcftools/test1.bcftools_stats.txt
- path: output/bcftools/test1.vcf.gz
- path: output/bcftools/test1.vcf.gz.tbi
- path: output/bcftools/test2.bcftools_stats.txt
- path: output/bcftools/test2.vcf.gz
- path: output/bcftools/test2.vcf.gz.tbi
- path: output/bcftools/versions.yml
- path: output/bedtools/test_split.bed
md5sum: 5058157987313b598f1c260e6965d6f7
- path: output/bedtools/versions.yml
- path: output/ngscheckmate/output.pdf
- path: output/ngscheckmate/output_all.txt
md5sum: fd74956dcac279b6f58e82ea73e344f8
- path: output/ngscheckmate/output_corr_matrix.txt
md5sum: 0c86bdad2721c470fe6be119f291c8e5
- path: output/ngscheckmate/output_matched.txt
md5sum: fd74956dcac279b6f58e82ea73e344f8
- path: output/ngscheckmate/versions.yml
md5sum: f06910b83dde194a47870c553cefe193
33 changes: 33 additions & 0 deletions tests/subworkflows/nf-core/bam_ngscheckmate/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env nextflow

nextflow.enable.dsl = 2

include { BAM_NGSCHECKMATE } from '../../../../subworkflows/nf-core/bam_ngscheckmate/main.nf'
include { BEDTOOLS_MAKEWINDOWS } from '../../../../modules/nf-core/bedtools/makewindows/main.nf'

workflow test_bam_ngscheckmate {

inputBed = [ [ id:'test_bed'],
file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)]

BEDTOOLS_MAKEWINDOWS(Channel.of(inputBed))
snp_bed = BEDTOOLS_MAKEWINDOWS.out.bed

input = [[
[ id:'test1' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true)
],[
[ id:'test2' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_methylated_sorted_bam'], checkIfExists: true)
]
]

fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)

ch_input = Channel.fromList(input)
ch_snp_bed = BEDTOOLS_MAKEWINDOWS.out.bed.map{it[1]}
ch_fasta = Channel.of(fasta)

BAM_NGSCHECKMATE( ch_input, ch_snp_bed , ch_fasta)

}
19 changes: 19 additions & 0 deletions tests/subworkflows/nf-core/bam_ngscheckmate/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

withName: BEDTOOLS_MAKEWINDOWS {
ext.args = '-w 1'
ext.prefix = 'test_split'
}

withName: ".*BAM_NGSCHECKMATE:BCFTOOLS_MPILEUP" {
ext.args2 = '--no-version --ploidy 1 -c'
ext.args3 = '--no-version'
}

withName: ".*BAM_NGSCHECKMATE:NGSCHECKMATE_NCM" {
ext.args = '-V'
}

}
25 changes: 25 additions & 0 deletions tests/subworkflows/nf-core/bam_ngscheckmate/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- name: bam_ngscheckmate test_bam_ngscheckmate
command: nextflow run ./tests/subworkflows/nf-core/bam_ngscheckmate -entry test_bam_ngscheckmate -c ./tests/config/nextflow.config
tags:
- bcftools
- bcftools/mpileup
- ngscheckmate
- ngscheckmate/ncm
- subworkflows
- subworkflows/bam_ngscheckmate
files:
- path: output/bcftools/test1.bcftools_stats.txt
- path: output/bcftools/test1.vcf.gz
- path: output/bcftools/test1.vcf.gz.tbi
- path: output/bcftools/test2.bcftools_stats.txt
- path: output/bcftools/test2.vcf.gz
- path: output/bcftools/test2.vcf.gz.tbi
- path: output/bedtools/test_split.bed
md5sum: 5058157987313b598f1c260e6965d6f7
- path: output/ngscheckmate/output.pdf
- path: output/ngscheckmate/output_all.txt
md5sum: efdecd402fb7f1425d96624a73ba33b2
- path: output/ngscheckmate/output_corr_matrix.txt
md5sum: 8b8acb28a3a2bc7c450a15eed397d8d8
- path: output/ngscheckmate/output_matched.txt
md5sum: efdecd402fb7f1425d96624a73ba33b2

0 comments on commit 3cfd245

Please sign in to comment.