Skip to content

Commit

Permalink
Add found_in tag to call repeat expansions
Browse files Browse the repository at this point in the history
  • Loading branch information
fellen31 committed Oct 30, 2024
1 parent e3098c6 commit 2df51f1
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- "CALL_SVS"
- "ANNOTATE_SVS"
- "RANK_VARIANTS"
- "CALL_REPEAT_EXPANSIONS"
profile:
- "docker"

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#430](https://github.com/genomic-medicine-sweden/nallo/pull/430) - Added a GitHub action to build and publish docs to GitHub Pages
- [#431](https://github.com/genomic-medicine-sweden/nallo/pull/431) - Added files needed to automatically build and publish docs to GitHub Pages
- [#435](https://github.com/genomic-medicine-sweden/nallo/pull/435) - Added nf-test to rank variants
- [#445](https://github.com/genomic-medicine-sweden/nallo/pull/445) - Added FOUND_IN tag and nf-test to rank variants

### `Changed`

Expand Down
2 changes: 1 addition & 1 deletion modules/local/trgt/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ process TRGT {
tuple val(meta), path(bam), path(bai), val(sex)
tuple val(meta2), path(fasta)
tuple val(meta3), path(fai)
path(repeats)
tuple val(meta4), path(repeats)

output:
tuple val(meta), path("${meta.id}.spanning.bam"), emit: bam
Expand Down
48 changes: 35 additions & 13 deletions subworkflows/local/call_repeat_expansions/main.nf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include { ADD_FOUND_IN_TAG } from '../../../modules/local/add_found_in_tag/main'
include { TRGT } from '../../../modules/local/trgt'
include { SAMTOOLS_INDEX as SAMTOOLS_INDEX_TRGT } from '../../../modules/nf-core/samtools/index/main'
include { SAMTOOLS_SORT as SAMTOOLS_SORT_TRGT } from '../../../modules/nf-core/samtools/sort/main'
Expand All @@ -21,32 +22,53 @@ workflow CALL_REPEAT_EXPANSIONS {
.set { ch_trgt_input }

// Run TGRT
TRGT ( ch_trgt_input, ch_fasta, ch_fai, ch_trgt_bed.map { it[1] } )
TRGT (
ch_trgt_input,
ch_fasta,
ch_fai,
ch_trgt_bed
)
ch_versions = ch_versions.mix(TRGT.out.versions)

// Sort and index bam
SAMTOOLS_SORT_TRGT ( TRGT.out.bam, [[],[]] )
SAMTOOLS_INDEX_TRGT(SAMTOOLS_SORT_TRGT.out.bam)
SAMTOOLS_SORT_TRGT (
TRGT.out.bam,
[[],[]]
)
ch_versions = ch_versions.mix(SAMTOOLS_SORT_TRGT.out.versions)

SAMTOOLS_INDEX_TRGT ( SAMTOOLS_SORT_TRGT.out.bam )
ch_versions = ch_versions.mix(SAMTOOLS_INDEX_TRGT.out.versions)

// Add FOUND_IN=TRGT tag
ADD_FOUND_IN_TAG (
TRGT.out.vcf.map { meta, vcf -> [ meta, vcf, [] ] },
"TRGT"
)

// Sort and index bcf
BCFTOOLS_SORT_TRGT(TRGT.out.vcf)
BCFTOOLS_SORT_TRGT ( ADD_FOUND_IN_TAG.out.vcf )
ch_versions = ch_versions.mix(BCFTOOLS_SORT_TRGT.out.versions)

BCFTOOLS_SORT_TRGT.out.vcf
.join( BCFTOOLS_SORT_TRGT.out.tbi )
.map { meta, bcf, csi -> [ [ id : meta.project ], bcf, csi ] }
.groupTuple()
.set{ ch_bcftools_merge_in }

BCFTOOLS_MERGE ( ch_bcftools_merge_in, ch_fasta, ch_fai, [[],[]] )


ch_versions = ch_versions.mix(TRGT.out.versions)
ch_versions = ch_versions.mix(SAMTOOLS_SORT_TRGT.out.versions)
ch_versions = ch_versions.mix(SAMTOOLS_INDEX_TRGT.out.versions)
ch_versions = ch_versions.mix(BCFTOOLS_SORT_TRGT.out.versions)
BCFTOOLS_MERGE (
ch_bcftools_merge_in,
ch_fasta,
ch_fai,
[[],[]]
)
ch_versions = ch_versions.mix(BCFTOOLS_MERGE.out.versions)

emit:
vcf = BCFTOOLS_SORT_TRGT.out.vcf // channel: [ val(meta), path(vcf) ]
versions = ch_versions // channel: [ versions.yml ]
sample_vcf = BCFTOOLS_SORT_TRGT.out.vcf // channel: [ val(meta), path(vcf) ]
project_vcf = BCFTOOLS_MERGE.out.vcf // channel: [ val(meta), path(vcf) ]
sample_bam = SAMTOOLS_SORT_TRGT.out.bam // channel: [ val(meta), path(bam) ]
sample_bai = SAMTOOLS_INDEX_TRGT.out.bai // channel: [ val(meta), path(bai) ]
versions = ch_versions // channel: [ versions.yml ]
}

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

name "Test Workflow CALL_REPEAT_EXPANSIONS"
script "../main.nf"
config "./nextflow.config"
workflow "CALL_REPEAT_EXPANSIONS"

setup {
run("GUNZIP") {
script "../../../../modules/nf-core/gunzip/main.nf"
process {
"""
input[0] = [
[ id:'test' ],
file(params.pipelines_testdata_base_path + 'reference/hg38.test.fa.gz', checkIfExists: true)
]
"""
}

}

run("SAMTOOLS_FAIDX") {
script "../../../../modules/nf-core/samtools/faidx/main.nf"
process {
"""
input[0] = GUNZIP.out.gunzip
input[1] = [[],[]]
"""
}

}
}

test("[bam, bai], fasta, fai, bed") {

when {
workflow {
"""
input[0] = Channel.of([
[ id:'test', single_end:false, project: 'project', sex: 1 ], // meta map
file(params.pipelines_testdata_base_path + 'testdata/HG002_PacBio_Revio.bam', checkIfExists: true),
file(params.pipelines_testdata_base_path + 'testdata/HG002_PacBio_Revio.bam.bai', checkIfExists: true)
])
input[1] = GUNZIP.out.gunzip
input[2] = SAMTOOLS_FAIDX.out.fai
input[3] = Channel.of([
[ id: 'pathogenic_repeats' ],
file(params.pipelines_testdata_base_path + 'reference/pathogenic_repeats.hg38.bed')
])
"""
}
}

then {
assertAll(
{ assert workflow.success },
{ assert workflow.out.sample_bai.get(0).get(1).endsWith(".bai") },
{ assert snapshot(
path(workflow.out.sample_vcf.get(0).get(1)).vcf.variantsMD5,
path(workflow.out.project_vcf.get(0).get(1)).vcf.variantsMD5,
bam(workflow.out.sample_bam.get(0).get(1), stringency: 'silent').getReadsMD5(),
workflow.out.versions,
).match() }
)
}

}

test("[bam, bai], fasta, fai, bed - stub") {

when {
workflow {
"""
input[0] = Channel.of([
[ id:'test', single_end:false, project: 'project', sex: 1 ], // meta map
file(params.pipelines_testdata_base_path + 'testdata/HG002_PacBio_Revio.bam', checkIfExists: true),
file(params.pipelines_testdata_base_path + 'testdata/HG002_PacBio_Revio.bam.bai', checkIfExists: true)
])
input[1] = GUNZIP.out.gunzip
input[2] = SAMTOOLS_FAIDX.out.fai
input[3] = Channel.of([
[ id: 'pathogenic_repeats' ],
file(params.pipelines_testdata_base_path + 'reference/pathogenic_repeats.hg38.bed')
])
"""
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(workflow.out).match() }
)
}

}
}
128 changes: 128 additions & 0 deletions subworkflows/local/call_repeat_expansions/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"[bam, bai], fasta, fai, bed": {
"content": [
"502b7befd528ce70b8269a8e4b9281df",
"1de84bd070a82b37e6fac25d19ae604e",
"65999ab8f2bc7841de8172468bf23ab6",
[
"versions.yml:md5,52272b464e62cb9e5d41622ea76cd070",
"versions.yml:md5,6576546ea5cf2a0cb6438b4c6758fd1e",
"versions.yml:md5,799b136592e7434ff7eb9ddcc70e7e41",
"versions.yml:md5,8a4b29c3089d4b00cfe6c5c39b88d1ab",
"versions.yml:md5,b9424dde80b33e84164cc956a14aa459"
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-29T10:47:08.425030144"
},
"[bam, bai], fasta, fai, bed - stub": {
"content": [
{
"0": [
[
{
"id": "test",
"single_end": false,
"project": "project",
"sex": 1
},
"test.vcf.gz:md5,952aa4f89891b92cea9a140cfd170610"
]
],
"1": [
[
{
"id": "project"
},
"project.vcf.gz:md5,4e18e3c3598c4baeea8e5855c236d199"
]
],
"2": [
[
{
"id": "test",
"single_end": false,
"project": "project",
"sex": 1
},
"test.bam:md5,b30b0cd7b65a7b16622bdb9b0f49d452"
]
],
"3": [
[
{
"id": "test",
"single_end": false,
"project": "project",
"sex": 1
},
"test.bam.bai:md5,718f228c5477b31125949309b4d92448"
]
],
"4": [
"versions.yml:md5,52272b464e62cb9e5d41622ea76cd070",
"versions.yml:md5,6576546ea5cf2a0cb6438b4c6758fd1e",
"versions.yml:md5,799b136592e7434ff7eb9ddcc70e7e41",
"versions.yml:md5,8a4b29c3089d4b00cfe6c5c39b88d1ab",
"versions.yml:md5,b9424dde80b33e84164cc956a14aa459"
],
"project_vcf": [
[
{
"id": "project"
},
"project.vcf.gz:md5,4e18e3c3598c4baeea8e5855c236d199"
]
],
"sample_bai": [
[
{
"id": "test",
"single_end": false,
"project": "project",
"sex": 1
},
"test.bam.bai:md5,718f228c5477b31125949309b4d92448"
]
],
"sample_bam": [
[
{
"id": "test",
"single_end": false,
"project": "project",
"sex": 1
},
"test.bam:md5,b30b0cd7b65a7b16622bdb9b0f49d452"
]
],
"sample_vcf": [
[
{
"id": "test",
"single_end": false,
"project": "project",
"sex": 1
},
"test.vcf.gz:md5,952aa4f89891b92cea9a140cfd170610"
]
],
"versions": [
"versions.yml:md5,52272b464e62cb9e5d41622ea76cd070",
"versions.yml:md5,6576546ea5cf2a0cb6438b4c6758fd1e",
"versions.yml:md5,799b136592e7434ff7eb9ddcc70e7e41",
"versions.yml:md5,8a4b29c3089d4b00cfe6c5c39b88d1ab",
"versions.yml:md5,b9424dde80b33e84164cc956a14aa459"
]
}
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-30T10:48:58.6309599"
}
}
11 changes: 11 additions & 0 deletions subworkflows/local/call_repeat_expansions/tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
process {
withName: 'CALL_REPEAT_EXPANSIONS:BCFTOOLS_MERGE' {
ext.args = '--output-type z --force-single --no-version'
}
withName: 'CALL_REPEAT_EXPANSIONS:BCFTOOLS_SORT_TRGT' {
ext.args = '--output-type z --write-index=tbi'
}
withName: 'CALL_REPEAT_EXPANSIONS:TRGT' {
ext.args = { "--sample-name ${meta.id}" }
}
}
10 changes: 5 additions & 5 deletions tests/samplesheet.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"test profile": {
"content": [
103,
104,
{
"ADD_FOUND_IN_TAG": {
"bcftools": 1.2,
Expand Down Expand Up @@ -530,22 +530,22 @@
],
[
"HG002_Revio_repeat_expansion_stranger.vcf.gz",
"492a5d1a0f1656e1f7fc1b97c922cab4"
"73c6c1d07ff96ef44569b5534aa90174"
],
[
"test.vcf.gz",
"4ab22ba6012b9f579f1831248bb95da"
"1de84bd070a82b37e6fac25d19ae604e"
],
[
"HG002_Revio_sorted.vcf.gz",
"43b909ba9628b92f5062be6c413e560d"
"502b7befd528ce70b8269a8e4b9281df"
]
]
],
"meta": {
"nf-test": "0.9.0",
"nextflow": "24.04.4"
},
"timestamp": "2024-10-30T08:33:56.258093996"
"timestamp": "2024-10-30T10:27:37.120618269"
}
}
Loading

0 comments on commit 2df51f1

Please sign in to comment.