nf-core / nf-core/eager

DSL2 remove or change bamfiltering_genomicbamfilterflag

Open
#1,130 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug DSL2
Dominant language
Nextflow
Stars
215
Forks
91
Avg merge
5m
Merged PRs (30d)
1

Description

We have both the bamfiltering_genomicbamfilterflag and the bamfiltering_retainunmappedgenomicbam flags.

If I remember right, the idea at the beginning was to make the flag generic and restrain from named flags (e.g. set to 5 to remove unpaired reads and unmapped as desired).

However, we now have the situation that the bamfiltering_genomicbamfilterflag is conditioned on the bamfiltering_retainunmappedgenomicbam.

(in modules.conf)
withName: SAMTOOLS_VIEW_BAM_FILTERING {
        tag = { "${meta.reference}|${meta.sample_id}_${meta.library_id}" }
        ext.args = [
            "-q ${params.bamfiltering_mappingquality}",
            params.bamfiltering_retainunmappedgenomicbam ? '' : "-F ${params.bamfiltering_genomicbamfilterflag}",
        ].join(' ').trim()
        ext.prefix = { "${meta.sample_id}_${meta.library_id}_${meta.reference}_filtered" }
        publishDir = [
            [
                // data
                path: { "${params.outdir}/read_filtering/filtered_bams/data/" },
                mode: params.publish_dir_mode,
                pattern: '*.bam',
                enabled: params.bamfiltering_savefilteredbams
            ]
        ]
    }

Problem

The bamfilter workflow will not behave as expected!

  • If the filter flag is 1 (filter unpaired) but retain_unmapped is set, filtering will just not happen
  • If the filter flag is 1 and retain_unmapped is not set, filtering will happen, but unmapped will still be retained.
Solutions
  1. Drop the filter-flag option (if its only used for mapped/unmapped)
  2. Update the filterflag based on the retain_unmapped flag (add 4 to if retain_unmapped is false) and only filter by flag
  3. make them independent (filter -F4 if not retain_unmapped and additionally -F filterflag) to allow for filtering weird flags like vendor-failed (etc.)

I think independent filtering would work best :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules.conf at the SAMTOOLS_VIEW_BAM_FILTERING configuration and trace how bamfiltering_genomicbamfilterflag and bamfiltering_retainunmappedgenomicbam become samtools arguments. Compare the current behavior with the three proposed solutions, focusing on the preferred independent filtering approach. Done means the two filtering choices work independently, including filtering additional flags such as vendor-failed reads.

Written by the indexing model from the issue text.

Assessment

Domain
bioinformatics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.