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

Fix bam filtering #1080

Merged
merged 4 commits into from
Jul 25, 2024
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: 1 addition & 1 deletion conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ process {
}

withName: ".*BAM_SPLIT_BY_REGION:SAMTOOLS_INDEX" {
// The BAM_SPLIT_BY_REGION SWF only works with bais, so `params.fasta_largeref` should not be passed to it.
tag = { "${meta.reference}:${meta.genomic_region}|${meta.sample_id}_${meta.library_id}" }
ext.args = { params.fasta_largeref ? "-c" : "" }
ext.prefix = { "${meta.sample_id}_${meta.library_id}_${meta.reference}_${meta.genomic_region}_dedupped" }
publishDir = [
enabled: false
Expand Down
8 changes: 5 additions & 3 deletions subworkflows/local/bamfiltering.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ include { CAT_FASTQ as CAT_FASTQ_MAPPED } from '../../modules/
workflow FILTER_BAM {

take:
bam // [ [meta], [bam], [bai] ]
bam // [ [meta], [bam], [bai/csi] ]

main:
ch_versions = Channel.empty()
Expand All @@ -37,9 +37,10 @@ workflow FILTER_BAM {
ch_versions = ch_versions.mix( FILTER_BAM_FRAGMENT_LENGTH.out.versions.first() )

SAMTOOLS_LENGTH_FILTER_INDEX ( FILTER_BAM_FRAGMENT_LENGTH.out.bam )
ch_length_filtered_index = params.fasta_largeref ? SAMTOOLS_LENGTH_FILTER_INDEX.out.csi : SAMTOOLS_LENGTH_FILTER_INDEX.out.bai
ch_versions = ch_versions.mix( SAMTOOLS_LENGTH_FILTER_INDEX.out.versions.first() )

ch_bam_for_qualityfilter = FILTER_BAM_FRAGMENT_LENGTH.out.bam.join( SAMTOOLS_LENGTH_FILTER_INDEX.out.bai )
ch_bam_for_qualityfilter = FILTER_BAM_FRAGMENT_LENGTH.out.bam.join( ch_length_filtered_index )

} else {
ch_bam_for_qualityfilter = bam
Expand All @@ -52,9 +53,10 @@ workflow FILTER_BAM {
ch_versions = ch_versions.mix( SAMTOOLS_VIEW_BAM_FILTERING.out.versions.first() )

SAMTOOLS_FILTER_INDEX ( SAMTOOLS_VIEW_BAM_FILTERING.out.bam )
ch_filtered_bam_index = params.fasta_largeref ? SAMTOOLS_FILTER_INDEX.out.csi : SAMTOOLS_FILTER_INDEX.out.bai
ch_versions = ch_versions.mix( SAMTOOLS_FILTER_INDEX.out.versions.first() )

ch_bam_for_genomics = SAMTOOLS_VIEW_BAM_FILTERING.out.bam.join( SAMTOOLS_FILTER_INDEX.out.bai )
ch_bam_for_genomics = SAMTOOLS_VIEW_BAM_FILTERING.out.bam.join( ch_filtered_bam_index )

// Only run if we actually remove mapped reads
if ( params.bamfiltering_mappingquality != 0 || params.bamfiltering_minreadlength != 0 ) {
Expand Down
5 changes: 1 addition & 4 deletions workflows/eager.nf
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,7 @@ workflow EAGER {
//
// MODULE: flagstats of user supplied input BAMs
//
ch_bam_bai_input = ch_samplesheet_bams
.join(SAMTOOLS_INDEX_BAM_INPUT.out.bai)

SAMTOOLS_FLAGSTATS_BAM_INPUT ( ch_bam_bai_input )
SAMTOOLS_FLAGSTATS_BAM_INPUT ( ch_bams_from_input )
ch_versions = ch_versions.mix( SAMTOOLS_FLAGSTATS_BAM_INPUT.out.versions )
ch_flagstat_input_bam = SAMTOOLS_FLAGSTATS_BAM_INPUT.out.flagstat // For endorspy

Expand Down