diff --git a/CHANGELOG.md b/CHANGELOG.md index 128e9b7b1..c9f97421d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,10 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### `Added` * [#80](https://github.com/nf-core/eager/pull/80) - BWA Index file handling * [#77](https://github.com/nf-core/eager/pull/77) - Lots of documentation updates by [@jfy133](https://github.com/jfy133) +* [#81](https://github.com/nf-core/eager/pull/81) - Renaming of certain BAM options ### `Fixed` * [#84](https://github.com/nf-core/eager/pull/85) - Fix for [Samtools index issues](https://github.com/nf-core/eager/issues/84) + ## [2.0.2] - 2018-11-03 ### `Changed` diff --git a/conf/binac.config b/conf/binac.config index c35e58c92..68ba98f1e 100644 --- a/conf/binac.config +++ b/conf/binac.config @@ -10,7 +10,7 @@ singularity { } process { - beforeScript = 'module load devel/singularity/2.4.1' + beforeScript = 'module load devel/singularity/2.6.0' executor = 'pbs' queue = 'short' } diff --git a/docs/usage.md b/docs/usage.md index 5bb1979dd..d9d38376b 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -383,17 +383,25 @@ Turn this on to utilize BWA Mem instead of `bwa aln` for alignment. Can be quite Users can configure to keep/discard/extract certain groups of reads efficiently in the nf-core/eager pipeline. -### `--bam_keep_mapped_only` +### `--bam_retain_unmapped` -This can be used to only keep mapped reads for downstream analysis. By default turned off, all reads are kept in the BAM file. Unmapped reads are stored both in BAM and FastQ format e.g. for different downstream processing. +Specify this to keep also unmapped reads in the BAM file. This is the default setting, only mapping quality filters are applied to all reads. -### `--bam_keep_all` +### `--bam_separate_unmapped` -Turned on by default, keeps all reads that were mapped in the dataset. +Separates the mapped and unmapepd reads, keeps only mapped reads in the BAM file for downstream analysis. -### `--bam_filter_reads` +### `--bam_unmapped_to_fastq` -Specify this, if you want to filter reads for downstream analysis. +Converted unmapped reads in BAM format to compressed FastQ format. + +### `--bam_discard_unmapped` + +Discards unmapped reads in either FastQ or BAM format, depending on the choice of the `--bam_unmapped_rm_type`. + +### `--bam_unmapped_rm_type` + +Defines which unmapped read format to discard, options available are `bam` or `fastq.gz`. By default, `fastq.gz` format will be kept and `bam` will be removed. ### `--bam_mapping_quality_threshold` diff --git a/environment.yml b/environment.yml index 014fa9364..50a776826 100644 --- a/environment.yml +++ b/environment.yml @@ -22,6 +22,7 @@ dependencies: - bioconda::pmdtools=0.60 - conda-forge::r-rmarkdown=1.10 - conda-forge::libiconv=1.15 + - conda-forge::pigz=2.3.4 - bioconda::sequencetools=1.2.2 - bioconda::preseq=2.0.3 - bioconda::fastp=0.19.4 diff --git a/main.nf b/main.nf index fbf516106..02b572325 100644 --- a/main.nf +++ b/main.nf @@ -76,9 +76,12 @@ def helpMessage() { --bwamem Turn on BWA Mem instead of CM/BWA aln for mapping BAM Filtering - --bam_keep_mapped_only Only consider mapped reads for downstream analysis. Unmapped reads are extracted to separate output. - --bam_filter_reads Keep all reads in BAM file for downstream analysis - --bam_mapping_quality_threshold Minimum mapping quality for reads filter + --bam_retain_unmapped Retains all unmapped reads in the BAM file (default) + --bam_separate_unmapped Separates mapped and unmapped reads, keep mapped BAM for downstream analysis. + --bam_unmapped_to_fastq Converts unmapped reads in BAM format to fastq.gz format. + --bam_discard_unmapped Discards unmapped reads in either FASTQ or BAM format, depending on choice in --bam_unmapped_rm_type + --bam_unmapped_rm_type Defines which unmapped read format to discard, options are "bam" or "fastq.gz". + --bam_mapping_quality_threshold Minimum mapping quality for reads filter, default 0. DeDuplication --dedupper Deduplication method to use @@ -173,11 +176,15 @@ params.circularfilter = false params.bwamem = false //BAM Filtering steps (default = keep mapped and unmapped in BAM file) -params.bam_keep_mapped_only = false -params.bam_keep_all = true -params.bam_filter_reads = false +params.bam_retain_unmapped = true +params.bam_separate_unmapped = false +params.bam_discard_unmapped = false +params.bam_unmapped_to_fastq = false +params.bam_unmapped_rm_type = 'bam' + params.bam_mapping_quality_threshold = 0 + //DamageProfiler settings params.damageprofiler_length = 100 params.damageprofiler_threshold = 15 @@ -715,22 +722,25 @@ process samtools_filter { file "*.unmapped.bam" optional true file "*.bai" - when: "${params.bam_filter_reads}" - script: prefix="$bam" - ~/(\.bam)?/ + rm_type = "${params.bam_unmapped_rm_type}" == 'bam' ? 'bam' : 'fastq.gz' + rm_unmapped = "${params.bam_discard_unmapped}" ? "rm *.unmapped.${rm_type}" : '' + fq_convert = "${params.bam_unmapped_to_fastq}" ? "samtools fastq -tn ${prefix}.unmapped.bam | pigz -p ${task.cpus} > ${prefix}.unmapped.fq.gz" : '' + - if("${params.bam_keep_mapped_only}"){ - """ - samtools view -h $bam | tee >(samtools view - -@ ${task.cpus} -f4 -q ${params.bam_mapping_quality_threshold} -o ${prefix}.unmapped.bam) >(samtools view - -@ ${task.cpus} -F4 -q ${params.bam_mapping_quality_threshold} -o ${prefix}.filtered.bam) - samtools fastq -tn "${prefix}.unmapped.bam" | gzip > "${prefix}.unmapped.fq.gz" - samtools index ${prefix}.filtered.bam - """ + if("${params.bam_separate_unmapped}"){ + """ + samtools view -h $bam | tee >(samtools view - -@ ${task.cpus} -f4 -q ${params.bam_mapping_quality_threshold} -o ${prefix}.unmapped.bam) >(samtools view - -@ ${task.cpus} -F4 -q ${params.bam_mapping_quality_threshold} -o ${prefix}.filtered.bam) + samtools index ${prefix}.filtered.bam + $fq_convert + $rm_unmapped + """ } else { - """ - samtools view -h $bam | tee >(samtools view - -@ ${task.cpus} -f4 -q ${params.bam_mapping_quality_threshold} -o ${prefix}.unmapped.bam) >(samtools view - -@ ${task.cpus} -q ${params.bam_mapping_quality_threshold} -o ${prefix}.filtered.bam) - samtools index ${prefix}.filtered.bam - """ + """ + samtools view -h $bam -@ ${task.cpus} -q ${params.bam_mapping_quality_threshold} -o ${prefix}.filtered.bam) + samtools index ${prefix}.filtered.bam + """ } }