Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#248](https://github.com/nf-core/phaseimpute/pull/248) - Add chromosomes concatenation to `BAM_GL_BCFTOOLS`
- [#259](https://github.com/nf-core/phaseimpute/pull/259) - Add `publish_all` arguments to all workflow level nf-test.
- [#272](https://github.com/nf-core/phaseimpute/pull/272) - Add genetic map detection and convertion for all phasing and imputation tools. Update usage.
- [#](https://github.com/nf-core/phaseimpute/pull/) - Add `chunk_version` parameter to control which Glimpse version to use to chunk.

### `Changed`

Expand Down
1 change: 1 addition & 0 deletions conf/test_full.config
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ params {
normalize = true
compute_freq = false
phase = false
chunk_version = "V2"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update usage.md to document these new changes, please? Thank you :)


// Validation optional args
min_val_gl = 0
Expand Down
5 changes: 3 additions & 2 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ workflow NFCORE_PHASEIMPUTE {
rename_chr // parameter: rename chromosome prefix
max_chr_names // parameter: max number of chr to show in message
params_simulate // map: parameters use for simulation step [depth: float, genotype: path]
params_panelprep // map: parameters use for panelprep step [normalize: boolean, remove_samples: string, compute_freq: boolean, phase: boolean, chunk_model: string ]
params_panelprep // map: parameters use for panelprep step [normalize: boolean, remove_samples: string, compute_freq: boolean, phase: boolean, chunk_model: string, chunk_version: string ]
params_impute // map: parameters use for imputation step [batch_size: integer, k_val: integer, n_gen: integer, buffer: integer]
params_validate // map: parameters use for validation step [bins: string, min_val_gl: float, min_val_dp: integer]
params_multiqc // map: parameters use for multiqc report [config: path, logo: path, methods_description: string]
Expand Down Expand Up @@ -166,7 +166,8 @@ workflow {
remove_samples: params.remove_samples,
compute_freq : params.compute_freq,
phase : params.phase,
chunk_model : params.chunk_model
chunk_model : params.chunk_model,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chunk model won't apply to both v1 and v2, right? Should we have a warning if you provide a v2 model and request a v1 version?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a test case can be added to cover for this scenario as well

chunk_version : params.chunk_version
]

def params_impute = [
Expand Down
1 change: 1 addition & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ params {
compute_freq = false
remove_samples = null
chunk_model = 'sequential'
chunk_version = 'V1'

// ChrCheck parameters
rename_chr = false
Expand Down
7 changes: 7 additions & 0 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@
"enum": ["recursive", "sequential"],
"default": "sequential",
"hidden": true
},
"chunk_version": {
"type": "string",
"description": "Glimpse version to use for chunking",
"enum": ["V1", "V2"],
"default": "V1",
"hidden": true
}
}
},
Expand Down
56 changes: 17 additions & 39 deletions subworkflows/local/vcf_chunk_glimpse/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,30 @@ workflow VCF_CHUNK_GLIMPSE {
take:
ch_reference // channel (mandatory): [ [panel_id, chr], vcf, csi ]
ch_map // channel (optional) : [ [panel_id, chr], map ]
chunk_model // channel : model
chunk_model // value : model
chunk_version // value : glimpse version to use

main:

// Add chromosome to channel
ch_vcf_csi_chr = ch_reference
.map{metaPC, vcf, csi -> [metaPC, vcf, csi, metaPC.chr]}

// Make chunks with Glimpse1
GLIMPSE_CHUNK(ch_vcf_csi_chr)

// Rearrange chunks into channel for QUILT
ch_chunks_quilt = GLIMPSE_CHUNK.out.chunk_chr
.splitText()
.map { metaPC, line ->
def fields = line.split("\t")
def startEnd = fields[2].split(':')[1].split('-')
[metaPC, metaPC.chr, startEnd[0], startEnd[1]]
}

// Rearrange chunks into channel for GLIMPSE1 and GLIMPSE2
ch_chunks_glimpse1 = GLIMPSE_CHUNK.out.chunk_chr
.splitCsv(
header: ['ID', 'Chr', 'RegionIn', 'RegionOut', 'Size1', 'Size2'],
sep: "\t", skip: 0
)
.map { metaPC, it -> [metaPC, it["RegionIn"], it["RegionOut"]]}

ch_input_glimpse2 = ch_vcf_csi_chr
.combine(ch_map, by:0)

GLIMPSE2_CHUNK(ch_input_glimpse2, chunk_model)

// Rearrange channels
ch_chunks_glimpse2 = GLIMPSE2_CHUNK.out.chunk_chr
.splitCsv(
header: [
'ID', 'Chr', 'RegionBuf', 'RegionCnk', 'WindowCm',
'WindowMb', 'NbTotVariants', 'NbComVariants'
], sep: "\t", skip: 0
)
.map { metaPC, it -> [metaPC, it["RegionBuf"], it["RegionCnk"]]}
if (chunk_version == "V1") {
// Make chunks with Glimpse1
GLIMPSE_CHUNK(ch_vcf_csi_chr)

ch_chunks = GLIMPSE_CHUNK.out.chunk_chr
} else if (chunk_version == "V2") {
ch_input_glimpse2 = ch_vcf_csi_chr
.combine(ch_map, by:0)

GLIMPSE2_CHUNK(ch_input_glimpse2, chunk_model)
ch_chunks = GLIMPSE2_CHUNK.out.chunk_chr
} else {
error ("Parameter chunk_version should be V1 or V2, found: ${chunk_version}.")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not needed since it should fail before this if a different one is provided. It should fail and error due to the schema which only allows enums.

}

emit:
chunks = GLIMPSE_CHUNK.out.chunk_chr // channel: [ [panel_id, chr], txt ]
chunks_quilt = ch_chunks_quilt // channel: [ [panel_id, chr], chr, start, end ]
chunks_glimpse1 = ch_chunks_glimpse1 // channel: [ [panel_id, chr], chr, region1, region2 ]
chunks_glimpse2 = ch_chunks_glimpse2 // channel: [ [panel_id, chr], chr, region1, region2 ]
chunks = ch_chunks // channel: [ [panel_id, chr], txt ]
}
6 changes: 6 additions & 0 deletions subworkflows/local/vcf_chunk_glimpse/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ input:
- recursive
- sequential
- uniform-number-variants
- chunk_version:
description: Glimpse version to chunk
type: string
enum:
- V1
- V2
output:
- chunks:
description: Channel with chunks files
Expand Down
65 changes: 57 additions & 8 deletions subworkflows/local/vcf_chunk_glimpse/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ nextflow_workflow {
tag "glimpse2"
tag "glimpse2/chunk"

test("Chunks with Map") {
test("Chunks with Map - V1") {
when {
workflow {
"""
Expand All @@ -36,14 +36,15 @@ nextflow_workflow {
input[1] = channel.of(
[
[panel_id: "1000GP", chr: "chr22"],
file(params.pipelines_testdata_base_path + "hum_data/reference_genome/GRCh38_chr22.glimpse.map", checkIfExist:true)
file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr22.glimpse.map", checkIfExist:true)
],
[
[panel_id: "1000GP", chr: "chr21"],
file(params.pipelines_testdata_base_path + "hum_data/reference_genome/GRCh38_chr21.glimpse.map", checkIfExist:true)
file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr21.glimpse.map", checkIfExist:true)
]
)
input[2] = "recursive"
input[3] = "V1"
"""
}
}
Expand All @@ -52,7 +53,7 @@ nextflow_workflow {
assertAll(
{ assert workflow.success },
{ assert snapshot(
workflow.out,
workflow.out.chunks,
workflow.out.chunks.collect{
path(it[1]).readLines()
}
Expand All @@ -62,7 +63,53 @@ nextflow_workflow {
}
}

test("Chunks without Map") {
test("Chunks with Map - V2") {
when {
workflow {
"""
input[0] = channel.of(
[
[panel_id: "1000GP", chr: "chr22"],
file(params.pipelines_testdata_base_path + "hum_data/panel/chr22/1000GP.chr22.s.norel.vcf.gz", checkIfExist:true),
file(params.pipelines_testdata_base_path + "hum_data/panel/chr22/1000GP.chr22.s.norel.vcf.gz.csi", checkIfExist:true),
],
[
[panel_id: "1000GP", chr: "chr21"],
file(params.pipelines_testdata_base_path + "hum_data/panel/chr21/1000GP.chr21.s.norel.vcf.gz", checkIfExist:true),
file(params.pipelines_testdata_base_path + "hum_data/panel/chr21/1000GP.chr21.s.norel.vcf.gz.csi", checkIfExist:true),
]
)
input[1] = channel.of(
[
[panel_id: "1000GP", chr: "chr22"],
file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr22.glimpse.map", checkIfExist:true)
],
[
[panel_id: "1000GP", chr: "chr21"],
file(params.modules_testdata_base_path + "genomics/homo_sapiens/genome/genetic_map/genome.GRCh38.chr21.glimpse.map", checkIfExist:true)
]
)
input[2] = "recursive"
input[3] = "V2"
"""
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(
workflow.out.chunks,
workflow.out.chunks.collect{
path(it[1]).readLines()
}
).match()
}
)
}
}

test("Chunks without Map - V1") {
when {
workflow {
"""
Expand All @@ -83,6 +130,7 @@ nextflow_workflow {
[[panel_id: "1000GP", chr: "chr21"], []]
)
input[2] = "recursive"
input[3] = "V1"
"""
}
}
Expand All @@ -91,7 +139,7 @@ nextflow_workflow {
assertAll(
{ assert workflow.success },
{ assert snapshot(
workflow.out,
workflow.out.chunks,
workflow.out.chunks.collect{
path(it[1]).readLines()
}
Expand All @@ -101,7 +149,7 @@ nextflow_workflow {
}
}

test("Chunks with sequential model") {
test("Chunks with sequential model - V2") {
when {
workflow {
"""
Expand All @@ -122,6 +170,7 @@ nextflow_workflow {
[[panel_id: "1000GP", chr: "chr21"], []]
)
input[2] = "sequential"
input[3] = "V2"
"""
}
}
Expand All @@ -130,7 +179,7 @@ nextflow_workflow {
assertAll(
{ assert workflow.success },
{ assert snapshot(
workflow.out,
workflow.out.chunks,
workflow.out.chunks.collect{
path(it[1]).readLines()
}
Expand Down
Loading
Loading