Skip to content

Commit d91226f

Browse files
authored
Merge pull request #81 from nf-core/rename_bam_flags
Adjustments for #76 , rename certain options to be more explicit
2 parents 011668d + a05b426 commit d91226f

4 files changed

Lines changed: 45 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
### `Added`
1010
* [#80](https://github.com/nf-core/eager/pull/80) - BWA Index file handling
1111
* [#77](https://github.com/nf-core/eager/pull/77) - Lots of documentation updates by [@jfy133](https://github.com/jfy133)
12+
* [#81](https://github.com/nf-core/eager/pull/81) - Renaming of certain BAM options
1213

1314
### `Fixed`
1415
* [#84](https://github.com/nf-core/eager/pull/85) - Fix for [Samtools index issues](https://github.com/nf-core/eager/issues/84)
1516

17+
1618
## [2.0.2] - 2018-11-03
1719

1820
### `Changed`

conf/binac.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ singularity {
1010
}
1111

1212
process {
13-
beforeScript = 'module load devel/singularity/2.4.1'
13+
beforeScript = 'module load devel/singularity/2.6.0'
1414
executor = 'pbs'
1515
queue = 'short'
1616
}

docs/usage.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,25 @@ Turn this on to utilize BWA Mem instead of `bwa aln` for alignment. Can be quite
383383

384384
Users can configure to keep/discard/extract certain groups of reads efficiently in the nf-core/eager pipeline.
385385

386-
### `--bam_keep_mapped_only`
386+
### `--bam_retain_unmapped`
387387

388-
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.
388+
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.
389389

390-
### `--bam_keep_all`
390+
### `--bam_separate_unmapped`
391391

392-
Turned on by default, keeps all reads that were mapped in the dataset.
392+
Separates the mapped and unmapepd reads, keeps only mapped reads in the BAM file for downstream analysis.
393393

394-
### `--bam_filter_reads`
394+
### `--bam_unmapped_to_fastq`
395395

396-
Specify this, if you want to filter reads for downstream analysis.
396+
Converted unmapped reads in BAM format to compressed FastQ format.
397+
398+
### `--bam_discard_unmapped`
399+
400+
Discards unmapped reads in either FastQ or BAM format, depending on the choice of the `--bam_unmapped_rm_type`.
401+
402+
### `--bam_unmapped_rm_type`
403+
404+
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.
397405

398406
### `--bam_mapping_quality_threshold`
399407

main.nf

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ def helpMessage() {
7676
--bwamem Turn on BWA Mem instead of CM/BWA aln for mapping
7777
7878
BAM Filtering
79-
--bam_keep_mapped_only Only consider mapped reads for downstream analysis. Unmapped reads are extracted to separate output.
80-
--bam_filter_reads Keep all reads in BAM file for downstream analysis
81-
--bam_mapping_quality_threshold Minimum mapping quality for reads filter
79+
--bam_retain_unmapped Retains all unmapped reads in the BAM file (default)
80+
--bam_separate_unmapped Separates mapped and unmapped reads, keep mapped BAM for downstream analysis.
81+
--bam_unmapped_to_fastq Converts unmapped reads in BAM format to fastq.gz format.
82+
--bam_discard_unmapped Discards unmapped reads in either FASTQ or BAM format, depending on choice in --bam_unmapped_rm_type
83+
--bam_unmapped_rm_type Defines which unmapped read format to discard, options are "bam" or "fastq.gz".
84+
--bam_mapping_quality_threshold Minimum mapping quality for reads filter, default 0.
8285
8386
DeDuplication
8487
--dedupper Deduplication method to use
@@ -173,11 +176,15 @@ params.circularfilter = false
173176
params.bwamem = false
174177

175178
//BAM Filtering steps (default = keep mapped and unmapped in BAM file)
176-
params.bam_keep_mapped_only = false
177-
params.bam_keep_all = true
178-
params.bam_filter_reads = false
179+
params.bam_retain_unmapped = true
180+
params.bam_separate_unmapped = false
181+
params.bam_discard_unmapped = false
182+
params.bam_unmapped_to_fastq = false
183+
params.bam_unmapped_rm_type = 'bam'
184+
179185
params.bam_mapping_quality_threshold = 0
180186

187+
181188
//DamageProfiler settings
182189
params.damageprofiler_length = 100
183190
params.damageprofiler_threshold = 15
@@ -715,22 +722,25 @@ process samtools_filter {
715722
file "*.unmapped.bam" optional true
716723
file "*.bai"
717724

718-
when: "${params.bam_filter_reads}"
719-
720725
script:
721726
prefix="$bam" - ~/(\.bam)?/
727+
rm_type = "${params.bam_unmapped_rm_type}" == 'bam' ? 'bam' : 'fastq.gz'
728+
rm_unmapped = "${params.bam_discard_unmapped}" ? "rm *.unmapped.${rm_type}" : ''
729+
fq_convert = "${params.bam_unmapped_to_fastq}" ? "samtools fastq -tn ${prefix}.unmapped.bam | pigz -p ${task.cpus} > ${prefix}.unmapped.fq.gz" : ''
730+
722731

723-
if("${params.bam_keep_mapped_only}"){
724-
"""
725-
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)
726-
samtools fastq -tn "${prefix}.unmapped.bam" | gzip > "${prefix}.unmapped.fq.gz"
727-
samtools index ${prefix}.filtered.bam
728-
"""
732+
if("${params.bam_separate_unmapped}"){
733+
"""
734+
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)
735+
samtools index ${prefix}.filtered.bam
736+
$fq_convert
737+
$rm_unmapped
738+
"""
729739
} else {
730-
"""
731-
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)
732-
samtools index ${prefix}.filtered.bam
733-
"""
740+
"""
741+
samtools view -h $bam -@ ${task.cpus} -q ${params.bam_mapping_quality_threshold} -o ${prefix}.filtered.bam)
742+
samtools index ${prefix}.filtered.bam
743+
"""
734744
}
735745
}
736746

0 commit comments

Comments
 (0)