Skip to content

Commit

Permalink
Merge pull request #568 from alanmmobbs93/qc_subworkflow_test
Browse files Browse the repository at this point in the history
QC subworkflow test
  • Loading branch information
alanmmobbs93 authored Dec 4, 2024
2 parents 489161e + c8247c8 commit fa2c71d
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add nf-test to nf-core module: `PICARD_COLLECTRNASEQMETRICS` and update module [#551](https://github.com/nf-core/rnafusion/pull/551)
- Add `--skip_vcf` boolean parameter to skip vcf file generation [#554](https://github.com/nf-core/rnafusion/pull/554)
- Add nf-test to local module: `FUSIONREPORT_DOWNLOAD` [#560](https://github.com/nf-core/rnafusion/pull/560)
- Add nf-test to local subworkflow: `QC_SUBWORKFLOW` [#568](https://github.com/nf-core/rnafusion/pull/568)

### Changed

Expand Down
43 changes: 0 additions & 43 deletions subworkflows/local/qc_workflow.nf

This file was deleted.

40 changes: 40 additions & 0 deletions subworkflows/local/qc_workflow/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Extract descriptive values from BAMs
//

include { PICARD_COLLECTRNASEQMETRICS } from '../../../modules/nf-core/picard/collectrnaseqmetrics'
include { GATK4_MARKDUPLICATES } from '../../../modules/nf-core/gatk4/markduplicates'
include { PICARD_COLLECTINSERTSIZEMETRICS } from '../../../modules/nf-core/picard/collectinsertsizemetrics'

workflow QC_WORKFLOW {
take:
ch_bam_sorted // channel [ meta, bam ]
ch_chrgtf // channel [ meta, gtf ]
ch_refflat // channel [ meta, refflat ]
ch_fasta // channel [ meta, fasta ]
ch_fai // channel [ meta, fai ]
ch_rrna_interval // channel [ meta, interval ]

main:
ch_versions = Channel.empty()

PICARD_COLLECTRNASEQMETRICS(ch_bam_sorted, ch_refflat.map{ meta, refflat -> [ refflat ] }, ch_fasta.map{ meta, fasta -> [ fasta ] }, ch_rrna_interval.map{ meta, intervals -> [ intervals ] }.ifEmpty([]) ) // Some chromosome or annotation may not have rRNA genes
ch_versions = ch_versions.mix(PICARD_COLLECTRNASEQMETRICS.out.versions)
ch_rnaseq_metrics = PICARD_COLLECTRNASEQMETRICS.out.metrics

GATK4_MARKDUPLICATES(ch_bam_sorted, ch_fasta.map { meta, fasta -> [ fasta ]}, ch_fai.map { meta, fasta_fai -> [ fasta_fai ]})
ch_versions = ch_versions.mix(GATK4_MARKDUPLICATES.out.versions)
ch_duplicate_metrics = GATK4_MARKDUPLICATES.out.metrics

PICARD_COLLECTINSERTSIZEMETRICS(ch_bam_sorted)
ch_versions = ch_versions.mix(PICARD_COLLECTINSERTSIZEMETRICS.out.versions)
ch_insertsize_metrics = PICARD_COLLECTINSERTSIZEMETRICS.out.metrics

emit:
versions = ch_versions // channel [ path ]
rnaseq_metrics = ch_rnaseq_metrics // channel [ meta, path ]
duplicate_metrics = ch_duplicate_metrics // channel [ meta, path ]
insertsize_metrics = ch_insertsize_metrics // channel [ meta, path ]

}

127 changes: 127 additions & 0 deletions subworkflows/local/qc_workflow/test/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
nextflow_workflow {

name "Test Subworkflow QC_WORKFLOW"
script "../main.nf"
config "./nextflow.config"
workflow "QC_WORKFLOW"
tag "qc"
tag "subworkflow"

test("QC_WORKFLOW - Homo sapiens chr22") {

// Generate refflat file
setup {

// Create refflat reference
run("UCSC_GTFTOGENEPRED") {
script "../../../../modules/nf-core/ucsc/gtftogenepred/main.nf"
process {
"""
input[0] =
Channel.fromPath(
"https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/modules/data/genomics/homo_sapiens/genome/genome.gtf",
checkIfExists: true
)
.map{ [ [id:it.Name], it ] }
"""
}
}

// Filter GTF to extract rRNA genes
run("RRNATRANSCRIPTS") {
script "../../../../modules/nf-core/rrnatranscripts/main.nf"
process {
"""
input[0] = Channel.fromPath("https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/modules/data/genomics/homo_sapiens/genome/genome.gtf", checkIfExists: true)
"""
}
}

// Convert rRNA GTF to BED
run("BEDOPS_CONVERT2BED") {
script "../../../../modules/nf-core/bedops/convert2bed/main.nf"
process {
"""
input[0] = RRNATRANSCRIPTS.out.rrna_gtf.map{ it -> [ [id:it.Name], it ] }
"""
}
}

// Convert rRNA BED to interval list (the necessary file)
run("GATK4_BEDTOINTERVALLIST") {
script "../../../../modules/nf-core/gatk4/bedtointervallist/main.nf"
process {
"""
input[0] = BEDOPS_CONVERT2BED.out.bed
input[1] = Channel.of(
[
[id: 'chr22_dic'],
file("https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/modules/data/genomics/homo_sapiens/genome/genome.dic", checkIfExist: true)
]
)
"""
}
}

}

when {
// Params to activate modules ext.when condition
params {
skip_qc = false
fusioninspector_only = false
starfusion = true
all = true
}

workflow {
"""
// ch_bam_sorted
input[0] = Channel.of(
[
[id: "chr22_bam"],
file("https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/modules/data/genomics/homo_sapiens/illumina/bam/test.paired_end.sorted.bam", checkIfExists: true)
])
// ch_chrgtf
input[1] = Channel.of(
[
[ id: "chr22_gtf" ],
file("https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/modules/data/genomics/homo_sapiens/genome/genome.gtf", checkIfExists: true)
])
// ch_refflat
input[2] = UCSC_GTFTOGENEPRED.out.refflat
// ch_fasta
input[3] = Channel.of(
[
[ id: "test_ref" ],
file("https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/modules/data/genomics/homo_sapiens/genome/genome.fasta", checkIfExist: true)
] )
// ch_fai
input[4] = Channel.of(
[
[ id: "test_ref" ],
file("https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/modules/data/genomics/homo_sapiens/genome/genome.fasta.fai", checkIfExist: true)
] )
// ch rRNA interval list
input[5] = GATK4_BEDTOINTERVALLIST.out.interval_list
"""
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(file( workflow.out.versions[0] )).match('versions' ) },
{ assert snapshot(file( workflow.out.rnaseq_metrics[0][1] ).readLines()[4..-1]).md5().match('rnaseq_metrics' ) },
{ assert snapshot(file( workflow.out.duplicate_metrics[0][1] ).readLines()[4..-1]).md5().match('duplicate_metrics' ) },
{ assert snapshot(file( workflow.out.insertsize_metrics[0][1] ).readLines()[4..-1]).md5().match('insertsize_metrics') }
)
}
}

}
36 changes: 36 additions & 0 deletions subworkflows/local/qc_workflow/test/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"duplicate_metrics": {
"content": "651d8a4702f9f9871e94afbce3e50e34",
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-04T19:29:09.711230835"
},
"versions": {
"content": [
"versions.yml:md5,3f13b395c67e317f74194b3b6c89f139"
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-04T19:29:09.686297468"
},
"rnaseq_metrics": {
"content": "84a348c3735ed2f6c47f346eeed661f4",
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-04T19:29:09.704632753"
},
"insertsize_metrics": {
"content": "160db81b19843c4d46fe74ac61f9f013",
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.10.2"
},
"timestamp": "2024-12-04T19:29:09.717929716"
}
}
10 changes: 10 additions & 0 deletions subworkflows/local/qc_workflow/test/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
process {
withName: PICARD_COLLECTRNASEQMETRICS {
ext.args = "--STRAND_SPECIFICITY SECOND_READ_TRANSCRIPTION_STRAND"
}

withName: GATK4_BEDTOINTERVALLIST {
ext.args = "--KEEP_LENGTH_ZERO_INTERVALS true"
}

}
1 change: 0 additions & 1 deletion workflows/rnafusion.nf
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ workflow RNAFUSION {

//QC
QC_WORKFLOW (
ch_reads_all,
STARFUSION_WORKFLOW.out.ch_bam_sorted,
ch_chrgtf,
ch_refflat,
Expand Down

0 comments on commit fa2c71d

Please sign in to comment.