Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add consistent support of .csi indices as alternative to .bai #328

Merged
merged 5 commits into from
Aug 11, 2023
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Enhancements & fixes

- [[#327](https://github.com/nf-core/atacseq/issues/327)]Consistently support `.csi` indices as alternative to `.bai` to allow SAMTOOLS_INDEX to be used with the `-c` flag

## [[2.1.2](https://github.com/nf-core/atacseq/releases/tag/2.1.2)] - 2022-08-07

### Enhancements & fixes
Expand Down
17 changes: 15 additions & 2 deletions subworkflows/local/bam_filter_bamtools.nf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ workflow BAM_FILTER_BAMTOOLS {
BAMTOOLS_FILTER
.out
.bam
.branch {
.branch {
meta, bam ->
single_end: meta.single_end
return [ meta, bam ]
Expand All @@ -49,11 +49,23 @@ workflow BAM_FILTER_BAMTOOLS {
}
ch_versions = ch_versions.mix(SAMTOOLS_INDEX.out.versions.first())

SAMTOOLS_INDEX.out.bai
.join(SAMTOOLS_INDEX.out.csi, by: [0], remainder: true)
.map {
meta, bai, csi ->
if (bai) {
[ meta, bai ]
} else {
[ meta, csi ]
}
}
.set { ch_index }

//
// Run samtools stats, flagstat and idxstats on SE BAM
//
BAM_STATS_SAMTOOLS (
ch_bam.single_end.join(SAMTOOLS_INDEX.out.bai),
ch_bam.single_end.join(ch_index),
ch_fasta
)
ch_versions = ch_versions.mix(BAM_STATS_SAMTOOLS.out.versions.first())
Expand Down Expand Up @@ -87,6 +99,7 @@ workflow BAM_FILTER_BAMTOOLS {
name_bam = SAMTOOLS_SORT.out.bam // channel: [ val(meta), [ bam ] ]
bam = BAM_SORT_STATS_SAMTOOLS.out.bam.mix(ch_bam.single_end) // channel: [ val(meta), [ bam ] ]
bai = BAM_SORT_STATS_SAMTOOLS.out.bai.mix(SAMTOOLS_INDEX.out.bai) // channel: [ val(meta), [ bai ] ]
csi = BAM_SORT_STATS_SAMTOOLS.out.csi.mix(SAMTOOLS_INDEX.out.csi) // channel: [ val(meta), [ csi ] ]
stats = BAM_SORT_STATS_SAMTOOLS.out.stats.mix(BAM_STATS_SAMTOOLS.out.stats) // channel: [ val(meta), [ stats ] ]
flagstat = BAM_SORT_STATS_SAMTOOLS.out.flagstat.mix(BAM_STATS_SAMTOOLS.out.flagstat) // channel: [ val(meta), [ flagstat ] ]
idxstats = BAM_SORT_STATS_SAMTOOLS.out.idxstats.mix(BAM_STATS_SAMTOOLS.out.idxstats) // channel: [ val(meta), [ idxstats ] ]
Expand Down
39 changes: 31 additions & 8 deletions workflows/atacseq.nf
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ workflow ATACSEQ {
// SUBWORKFLOW: Alignment with BWA & BAM QC
//
ch_genome_bam = Channel.empty()
ch_genome_bam_index = Channel.empty()
ch_samtools_stats = Channel.empty()
ch_samtools_flagstat = Channel.empty()
ch_samtools_idxstats = Channel.empty()
Expand All @@ -176,7 +175,6 @@ workflow ATACSEQ {
}
)
ch_genome_bam = FASTQ_ALIGN_BWA.out.bam
ch_genome_bam_index = FASTQ_ALIGN_BWA.out.bai
ch_samtools_stats = FASTQ_ALIGN_BWA.out.stats
ch_samtools_flagstat = FASTQ_ALIGN_BWA.out.flagstat
ch_samtools_idxstats = FASTQ_ALIGN_BWA.out.idxstats
Expand All @@ -198,7 +196,6 @@ workflow ATACSEQ {
}
)
ch_genome_bam = FASTQ_ALIGN_BOWTIE2.out.bam
ch_genome_bam_index = FASTQ_ALIGN_BOWTIE2.out.bai
ch_samtools_stats = FASTQ_ALIGN_BOWTIE2.out.stats
ch_samtools_flagstat = FASTQ_ALIGN_BOWTIE2.out.flagstat
ch_samtools_idxstats = FASTQ_ALIGN_BOWTIE2.out.idxstats
Expand All @@ -222,7 +219,6 @@ workflow ATACSEQ {
[]
)
ch_genome_bam = FASTQ_ALIGN_CHROMAP.out.bam
ch_genome_bam_index = FASTQ_ALIGN_CHROMAP.out.bai
ch_samtools_stats = FASTQ_ALIGN_CHROMAP.out.stats
ch_samtools_flagstat = FASTQ_ALIGN_CHROMAP.out.flagstat
ch_samtools_idxstats = FASTQ_ALIGN_CHROMAP.out.idxstats
Expand All @@ -244,7 +240,6 @@ workflow ATACSEQ {
params.seq_center ?: ''
)
ch_genome_bam = ALIGN_STAR.out.bam
ch_genome_bam_index = ALIGN_STAR.out.bai
ch_samtools_stats = ALIGN_STAR.out.stats
ch_samtools_flagstat = ALIGN_STAR.out.flagstat
ch_samtools_idxstats = ALIGN_STAR.out.idxstats
Expand Down Expand Up @@ -298,7 +293,17 @@ workflow ATACSEQ {
// SUBWORKFLOW: Filter BAM file
//
MERGED_LIBRARY_FILTER_BAM (
MERGED_LIBRARY_MARKDUPLICATES_PICARD.out.bam.join(MERGED_LIBRARY_MARKDUPLICATES_PICARD.out.bai, by: [0]),
MERGED_LIBRARY_MARKDUPLICATES_PICARD.out.bam
.join(MERGED_LIBRARY_MARKDUPLICATES_PICARD.out.bai, by: [0], remainder: true)
.join(MERGED_LIBRARY_MARKDUPLICATES_PICARD.out.csi, by: [0], remainder: true)
.map {
meta, bam, bai, csi ->
if (bai) {
[ meta, bam, bai ]
} else {
[ meta, bam, csi ]
}
},
PREPARE_GENOME.out.filtered_bed.first(),
PREPARE_GENOME
.out
Expand Down Expand Up @@ -379,7 +384,16 @@ workflow ATACSEQ {
MERGED_LIBRARY_FILTER_BAM
.out
.bam
.join(MERGED_LIBRARY_FILTER_BAM.out.bai, by: [0])
.join(MERGED_LIBRARY_FILTER_BAM.out.bai, by: [0], remainder: true)
.join(MERGED_LIBRARY_FILTER_BAM.out.csi, by: [0], remainder: true)
.map {
meta, bam, bai, csi ->
if (bai) {
[ meta, bam, bai ]
} else {
[ meta, bam, csi ]
}
}
.set { ch_bam_bai }

if (params.with_control) {
Expand Down Expand Up @@ -477,7 +491,16 @@ workflow ATACSEQ {
MERGED_LIBRARY_MARKDUPLICATES_PICARD
.out
.bam
.join(MERGED_LIBRARY_MARKDUPLICATES_PICARD.out.bai, by: [0])
.join(MERGED_LIBRARY_MARKDUPLICATES_PICARD.out.bai, by: [0], remainder: true)
.join(MERGED_LIBRARY_MARKDUPLICATES_PICARD.out.csi, by: [0], remainder: true)
.map {
meta, bam, bai, csi ->
if (bai) {
[ meta, bam, bai ]
} else {
[ meta, bam, csi ]
}
}
.join(MERGED_LIBRARY_CALL_ANNOTATE_PEAKS.out.peaks, by: [0])
.set { ch_bam_peaks }

Expand Down
Loading