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
46 changes: 29 additions & 17 deletions subworkflows/nf-core/bam_impute_quilt/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,41 @@ workflow BAM_IMPUTE_QUILT {
main:

// Make final channel with parameters
ch_chunks_counts = ch_chunks
.groupTuple()
.map { metaPC, chr, _start, _end ->
[metaPC, chr.size()]
}

ch_parameters = ch_hap_legend_posfile
.combine(ch_map, by: 0)
.combine(ch_chunks, by: 0)
.combine(ch_chunks_counts, by: 0)

ch_parameters.ifEmpty {
error("ERROR: join operation resulted in an empty channel. Please provide a valid ch_chunks and ch_map channel as input.")
}

ch_bam_params = ch_input
.combine(ch_parameters)
.map { metaI, bam, bai, bampath, bamname, metaPC, hap, legend, posfile, gmap, chr, start, end ->
.map { metaI, bam, bai, bampath, bamname, metaPC, hap, legend, posfile, gmap, chr, start, end, region_size ->
def regionout = "${chr}"
def regionoutPadded = "${chr}"
if (start != [] && end != []) {
def paddedStart = String.format('%010d', start as long)
def paddedEnd = String.format('%010d', end as long)
regionoutPadded = "${chr}:${paddedStart}-${paddedEnd}"
regionout = "${chr}:${start}-${end}"
}
[
metaPC + metaI + ["regionout": regionout],
bam,
bai,
bampath,
bamname,
hap,
legend,
metaPC + metaI + ["regionout": regionout, "regionoutPadded": regionoutPadded, "regionSize": region_size],
bam, bai,
bampath, bamname,
hap, legend,
posfile,
[],
[],
chr,
start,
end,
n_gen,
buffer,
[], [],
chr, start, end,
n_gen, buffer,
gmap,
]
}
Expand All @@ -56,10 +60,18 @@ workflow BAM_IMPUTE_QUILT {
ligate_input = QUILT_QUILT.out.vcf
.join(QUILT_QUILT.out.tbi)
.map { meta, vcf, index ->
def keysToKeep = meta.keySet() - ['regionout']
[meta.subMap(keysToKeep), vcf, index]
def keysToKeep = meta.keySet() - ['regionout', 'regionoutPadded', 'regionSize']
[
groupKey(meta.subMap(keysToKeep), meta.regionSize),
vcf, index,
]
}
.groupTuple()
.map { groupKeyObj, vcf, index ->
// Extract the actual meta from the groupKey
def meta = groupKeyObj.getGroupTarget()
[meta, vcf, index]
}

GLIMPSE2_LIGATE(ligate_input)

Expand Down
4 changes: 3 additions & 1 deletion subworkflows/nf-core/bam_impute_quilt/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
name: "BAM_IMPUTE_QUILT"
description: |
Subworkflow to impute BAM files using QUILT software.
Variants location to impute are obtain through the tsv file given
Variants location to impute are obtain through the tsv file given.
"regionout", "regionoutPadded", "regionSize" keys will be added to the meta map to distinguish
the different files before ligation and therefore should not be used.
keywords:
- BAM
- imputation
Expand Down
8 changes: 4 additions & 4 deletions subworkflows/nf-core/bam_impute_quilt/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
"vcf_index": [
[
{
"id": "allid",
"chr": "chr21"
"chr": "chr21",
"id": "allid"
},
"allid_chr21.ligate.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"allid_chr21.ligate.vcf.gz.csi:md5,d41d8cd98f00b204e9800998ecf8427e"
],
[
{
"id": "allid",
"chr": "chr22"
"chr": "chr22",
"id": "allid"
},
"allid_chr22.ligate.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"allid_chr22.ligate.vcf.gz.csi:md5,d41d8cd98f00b204e9800998ecf8427e"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ process {
withName: QUILT_QUILT {
cpus = 1 // needed for deterministic output
ext.args = { "${params.quilt_args}" }
ext.prefix = { "${meta.id}_${meta.chr}_${meta.regionout}.quilt" }
ext.prefix = { "${meta.id}_${meta.regionoutPadded.replace(':', '-')}.quilt" }
}

withName: GLIMPSE2_LIGATE {
Expand Down
47 changes: 29 additions & 18 deletions subworkflows/nf-core/bam_impute_quilt2/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,42 @@ workflow BAM_IMPUTE_QUILT2 {

main:

// Make final channel with parameters
ch_chunks_counts = ch_chunks
.groupTuple()
.map { metaPC, chr, _start, _end ->
[metaPC, chr.size()]
}

ch_parameters = ch_reference_panel
.combine(ch_map, by: 0)
.combine(ch_chunks, by: 0)
.combine(ch_chunks_counts, by: 0)

ch_parameters.ifEmpty {
error("ERROR: join operation resulted in an empty channel. Please provide a valid ch_chunks and ch_map channel as input.")
}

ch_bam_params = ch_input
.combine(ch_parameters)
.map { meta_input, bam, bai, bampath, bamname, meta_panel, reference_vcf, reference_index, genetic_map, chr, start, end ->
.map { meta_input, bam, bai, bampath, bamname, meta_panel, reference_vcf, reference_index, genetic_map, chr, start, end, region_size ->
def regionout = "${chr}"
def regionoutPadded = "${chr}"
if (start != [] && end != []) {
def paddedStart = String.format('%010d', start as long)
def paddedEnd = String.format('%010d', end as long)
regionoutPadded = "${chr}:${paddedStart}-${paddedEnd}"
regionout = "${chr}:${start}-${end}"
}

[
meta_panel + meta_input + [regionout: regionout],
bam,
bai,
bampath,
bamname,
reference_vcf,
reference_index,
[],
[],
[],
chr,
start,
end,
n_gen,
buffer,
meta_panel + meta_input + ["regionout": regionout, "regionoutPadded": regionoutPadded, "regionSize": region_size],
bam, bai,
bampath, bamname,
reference_vcf, reference_index,
[], [], [],
chr, start, end,
n_gen, buffer,
genetic_map,
]
}
Expand All @@ -56,10 +59,18 @@ workflow BAM_IMPUTE_QUILT2 {
ligate_input = QUILT_QUILT2.out.vcf
.join(QUILT_QUILT2.out.tbi)
.map { meta, vcf, index ->
def keys_to_keep = meta.keySet() - ['regionout']
[meta.subMap(keys_to_keep), vcf, index]
def keysToKeep = meta.keySet() - ['regionout', 'regionoutPadded', 'regionSize']
[
groupKey(meta.subMap(keysToKeep), meta.regionSize),
vcf, index,
]
}
.groupTuple()
.map { groupKeyObj, vcf, index ->
// Extract the actual meta from the groupKey
def meta = groupKeyObj.getGroupTarget()
[meta, vcf, index]
}

GLIMPSE2_LIGATE(ligate_input)

Expand Down
4 changes: 3 additions & 1 deletion subworkflows/nf-core/bam_impute_quilt2/meta.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/subworkflows/yaml-schema.json
name: "bam_impute_quilt2"
description: |
Impute low-coverage BAM or CRAM inputs with QUILT2 and ligate chunked outputs per chromosome. 'regionout' key will be used to store temporarily the region and therefore shouldn't be used in the meta maps.
Impute low-coverage BAM or CRAM inputs with QUILT2 and ligate chunked outputs per chromosome.
"regionout", "regionoutPadded", "regionSize" keys will be added to the meta map to distinguish
the different files before ligation and therefore should not be used.
keywords:
- bam
- cram
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ process {
withName: QUILT_QUILT2 {
cpus = 1
ext.args = { "${params.quilt_args}" }
ext.prefix = { "${meta.id}_${meta.chr}_${meta.regionout}.quilt2" }
ext.prefix = { "${meta.id}_${meta.regionoutPadded.replace(':', '-')}.quilt2" }
}

withName: GLIMPSE2_LIGATE {
Expand Down
40 changes: 27 additions & 13 deletions subworkflows/nf-core/bam_impute_stitch/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,45 @@ workflow BAM_IMPUTE_STITCH {
main:

// Make final channel with parameters
ch_chunks_counts = ch_chunks
.groupTuple()
.map { metaPC, chr, _start, _end ->
[metaPC, chr.size()]
}

ch_parameters = ch_posfile
.combine(ch_map, by: 0)
.combine(ch_chunks, by: 0)
.combine(ch_chunks_counts, by: 0)

ch_parameters.ifEmpty {
error("ERROR: join operation resulted in an empty channel. Please provide a valid ch_chunks and ch_map channel as input.")
}

ch_bam_params = ch_input
.combine(ch_parameters)
.map { metaI, bam, bai, bampath, bamname, metaPC, posfile, gmap, chr, start, end ->
.map { metaI, bam, bai, bampath, bamname, metaPC, posfile, gmap, chr, start, end, region_size ->
if (!chr) {
error("ERROR: chromosome is not provided in ch_chunks.")
}
def regionout = "${chr}"
def regionoutPadded = "${chr}"
if (start != [] && end != []) {
def paddedStart = String.format('%010d', start as long)
def paddedEnd = String.format('%010d', end as long)
regionoutPadded = "${chr}:${paddedStart}-${paddedEnd}"
regionout = "${chr}:${start}-${end}"
}
[
metaPC + metaI + ["regionout": regionout],
bam,
bai,
bampath,
bamname,
metaPC + metaI + ["regionout": regionout, "regionoutPadded": regionoutPadded, "regionSize": region_size],
bam, bai,
bampath, bamname,
posfile,
[],
gmap,
[],
chr,
start,
end,
k_val,
n_gen,
chr, start, end,
k_val, n_gen,
]
}

Expand All @@ -66,10 +72,18 @@ workflow BAM_IMPUTE_STITCH {
failOnDuplicate: true,
)
.map { meta, vcf, index ->
def keysToKeep = meta.keySet() - ['regionout']
[meta.subMap(keysToKeep), vcf, index]
def keysToKeep = meta.keySet() - ['regionout', 'regionoutPadded', 'regionSize']
[
groupKey(meta.subMap(keysToKeep), meta.regionSize),
vcf, index,
]
}
.groupTuple()
.map { groupKeyObj, vcf, index ->
// Extract the actual meta from the groupKey
def meta = groupKeyObj.getGroupTarget()
[meta, vcf, index]
}

GLIMPSE2_LIGATE(ligate_input)

Expand Down
4 changes: 3 additions & 1 deletion subworkflows/nf-core/bam_impute_stitch/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
name: "BAM_IMPUTE_STITCH"
description: |
Subworkflow to impute BAM files using STITCH software.
Variants location to impute are obtain through the legend file given
Variants location to impute are obtain through the legend file given.
"regionout", "regionoutPadded", "regionSize" keys will be added to the meta map to distinguish
the different files before ligation and therefore should not be used.
keywords:
- BAM
- imputation
Expand Down
12 changes: 6 additions & 6 deletions subworkflows/nf-core/bam_impute_stitch/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[
[
{
"id": "allid",
"chr": "chr22"
"chr": "chr22",
"id": "allid"
},
"allid_chr22.ligate.vcf.gz",
"allid_chr22.ligate.vcf.gz.csi",
Expand All @@ -29,16 +29,16 @@
"vcf_index": [
[
{
"id": "allid",
"chr": "chr21"
"chr": "chr21",
"id": "allid"
},
"allid_chr21.ligate.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"allid_chr21.ligate.vcf.gz.csi:md5,d41d8cd98f00b204e9800998ecf8427e"
],
[
{
"id": "allid",
"chr": "chr22"
"chr": "chr22",
"id": "allid"
},
"allid_chr22.ligate.vcf.gz:md5,68b329da9893e34099c7d8ad5cb9c940",
"allid_chr22.ligate.vcf.gz.csi:md5,d41d8cd98f00b204e9800998ecf8427e"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
process {
withName: STITCH {
cpus = 1 // needed for deterministic output
ext.prefix = { "${meta.id}_${meta.chr}_${meta.regionout}.stitch" }
ext.prefix = { "${meta.id}_${meta.regionoutPadded.replace(':', '-')}.stitch" }
}

withName: GLIMPSE2_LIGATE {
Expand Down
Loading
Loading