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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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), [ bai ] ]
bjlang marked this conversation as resolved.
Show resolved Hide resolved
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
45 changes: 42 additions & 3 deletions workflows/atacseq.nf
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,29 @@ workflow ATACSEQ {
//
// SUBWORKFLOW: Filter BAM file
//
// ch_bam_bai = PICARD_MARKDUPLICATES.out.bam
bjlang marked this conversation as resolved.
Show resolved Hide resolved
// .join(SAMTOOLS_INDEX.out.bai, by: [0], remainder: true)
// .join(SAMTOOLS_INDEX.out.csi, by: [0], remainder: true)
// .map {
// meta, bam, bai, csi ->
// if (bai) {
// [ meta, bam, bai ]
// } else {
// [ meta, bam, csi ]
// }
// }
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 +400,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 +507,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