Skip to content

Commit 8c34dae

Browse files
committed
Fix mapAD multiref mapping
1 parent 35367bd commit 8c34dae

5 files changed

Lines changed: 46 additions & 20 deletions

File tree

conf/modules.config

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,30 @@ process {
586586
]
587587
}
588588

589+
withName: ".*FASTQ_ALIGN_MAPAD:BAM_SORT_STATS_SAMTOOLS:SAMTOOLS_SORT" {
590+
tag = { "${meta.reference}:${meta.genomic_region}|${meta.sample_id}_${meta.library_id}" }
591+
ext.prefix = { "${meta.sample_id}_${meta.library_id}_${meta.reference}_${meta.genomic_region}_mapAD" }
592+
publishDir = [
593+
enabled: false
594+
]
595+
}
596+
597+
withName: ".*FASTQ_ALIGN_MAPAD:BAM_SORT_STATS_SAMTOOLS:SAMTOOLS_INDEX" {
598+
tag = { "${meta.reference}:${meta.genomic_region}|${meta.sample_id}_${meta.library_id}" }
599+
ext.prefix = { "${meta.sample_id}_${meta.library_id}_${meta.reference}_${meta.genomic_region}_mapAD" }
600+
publishDir = [
601+
enabled: false
602+
]
603+
}
604+
605+
withName: ".*FASTQ_ALIGN_MAPAD:BAM_SORT_STATS_SAMTOOLS:SAMTOOLS_STATS" {
606+
tag = { "${meta.reference}:${meta.genomic_region}|${meta.sample_id}_${meta.library_id}" }
607+
ext.prefix = { "${meta.sample_id}_${meta.library_id}_${meta.reference}_${meta.genomic_region}_mapAD" }
608+
publishDir = [
609+
enabled: false
610+
]
611+
}
612+
589613
withName: SAMTOOLS_SORT_DEDUPPED {
590614
tag = { "${meta.reference}|${meta.sample_id}_${meta.library_id}" }
591615
ext.prefix = { "${meta.sample_id}_${meta.library_id}_${meta.reference}_dedupped" }

nextflow.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ params {
123123
mapping_bowtie2_trim3 = 0
124124
mapping_bowtie2_maxins = 500
125125
mapping_mapad_p = 0.03
126-
mapping_mapad_lib = 'single_stranded'
127126
mapping_mapad_f = 0.5
128127
mapping_mapad_t = 0.5
129128
mapping_mapad_d = 0.02

nextflow_schema.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -611,14 +611,6 @@
611611
"help_text": "Configures the `mapad map -p` parameter, defining how many mismatches are allowed in a read. Default is set following recommendations from [Heide et al. 2024](https://localhost) who tested when aligning to human reference genomes. \n\n> Modifies mapAD parameter: `-p`",
612612
"fa_icon": "fas fa-sort-numeric-down"
613613
},
614-
"mapping_mapad_lib": {
615-
"type": "string",
616-
"default": "single_stranded",
617-
"description": "Specify mapAD's library-preparation parameter, which adapts its aDNA-specific mismatch scoring correspondingly.",
618-
"help_text": "Configures whether mapAD's aDNA-scoring model is set to double- or single-stranded library preparation mode. In single-stranded mode, we expect elevated C->T error rates at both ends of the reads, whereas in double-stranded mode we expect increased C->T error rates at the 5‘ end, but elevated G->A error rates at the 3’ end. Default is set to `single_stranded`.\n\n> Modifies mapAD parameter: `-l/--library`",
619-
"fa_icon": "fas fa-exchange-alt",
620-
"enum": ["single_stranded", "double_stranded"]
621-
},
622614
"mapping_mapad_f": {
623615
"type": "number",
624616
"default": 0.5,

subworkflows/local/map.nf

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ include { SAMTOOLS_FLAGSTAT as SAMTOOLS_FLAGSTAT_MAPPED } from '../../modules/nf
1717
workflow MAP {
1818
take:
1919
reads // [ [meta], [read1, reads2] ] or [ [meta], [read1] ]
20-
index // [ [meta], [ index ] ]
20+
index // [ [meta], [ index ], [ fasta ] ]
2121

2222
main:
2323
ch_versions = Channel.empty()
@@ -41,7 +41,7 @@ workflow MAP {
4141
.groupTuple()
4242

4343
ch_input_for_mapping = sharded_reads
44-
.combine(index)
44+
.combine(index.map{ meta, index, fasta -> [ meta, index ] })
4545
.multiMap {
4646
meta, reads, meta2, index ->
4747
new_meta = meta.clone()
@@ -52,7 +52,7 @@ workflow MAP {
5252

5353
} else {
5454
ch_input_for_mapping = reads
55-
.combine(index)
55+
.combine(index.map{ meta, index, fasta -> [ meta, index ] })
5656
.multiMap {
5757
meta, reads, meta2, index ->
5858
new_meta = meta.clone()
@@ -63,7 +63,7 @@ workflow MAP {
6363
}
6464

6565
if ( params.mapping_tool == 'bwaaln' ) {
66-
ch_index_for_mapping = index
66+
ch_index_for_mapping = index.map{ meta, index, fasta -> [ meta, index ] }
6767
ch_reads_for_mapping = reads
6868

6969
FASTQ_ALIGN_BWAALN ( ch_reads_for_mapping, ch_index_for_mapping )
@@ -80,7 +80,7 @@ workflow MAP {
8080

8181
} else if ( params.mapping_tool == 'bwamem' ) {
8282
ch_input_for_mapping = reads
83-
.combine( index )
83+
.combine( index.map{ meta, index, fasta -> [ meta, index ] } )
8484
.multiMap {
8585
meta, reads, meta2, index ->
8686
new_meta = meta + [ reference: meta2.id ]
@@ -98,7 +98,7 @@ workflow MAP {
9898

9999
} else if ( params.mapping_tool == 'bowtie2' ) {
100100
ch_input_for_mapping = reads
101-
.combine( index )
101+
.combine( index.map{ meta, index, fasta -> [ meta, index ] } )
102102
.multiMap {
103103
meta, reads, meta2, index ->
104104
new_meta = meta + [ reference: meta2.id ]
@@ -115,12 +115,23 @@ workflow MAP {
115115
ch_mapped_lane_bai = params.fasta_largeref ? SAMTOOLS_INDEX_BT2.out.csi : SAMTOOLS_INDEX_BT2.out.bai
116116

117117
} else if ( params.mapping_tool == 'mapad' ) {
118+
ch_input_for_mapping = reads
119+
.combine( index )
120+
.multiMap {
121+
meta, reads, meta2, index, fasta ->
122+
new_meta = meta + [ reference: meta2.id ]
123+
reads: [ new_meta, reads ]
124+
index: [ meta2, index ]
125+
fasta: [ meta2, fasta ]
126+
strandedness: meta.strandedness!="single"
127+
}
128+
118129
FASTQ_ALIGN_MAPAD (
119-
reads,
120-
index,
121-
params.fasta,
130+
ch_input_for_mapping.reads,
131+
ch_input_for_mapping.index,
132+
ch_input_for_mapping.fasta,
122133
params.mapping_mapad_p,
123-
params.mapping_mapad_lib=="double_stranded" ? true : false,
134+
ch_input_for_mapping.strandedness,
124135
params.mapping_mapad_f,
125136
params.mapping_mapad_t,
126137
params.mapping_mapad_d,

workflows/eager.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ workflow EAGER {
182182
ch_reference_for_mapping = REFERENCE_INDEXING.out.reference
183183
.map{
184184
meta, fasta, fai, dict, index, circular_target ->
185-
[ meta, index ]
185+
[ meta, index, fasta ]
186186
}
187187

188188
MAP ( ch_reads_for_mapping, ch_reference_for_mapping )

0 commit comments

Comments
 (0)