Skip to content

Commit 96867d9

Browse files
edmundmillerclaude
andcommitted
refactor: Replace local bedtools genomecov module with nf-core version
- Replace local bedtools_genomecov module with nf-core bedtools/genomecov - Add inline scale factor calculation from flagstat in subworkflow - Configure nf-core module with -bga and -pc flags for proper output - Remove scale_factor output emit as it's no longer needed - Maintain same functionality while using official nf-core modules 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent f67b5ad commit 96867d9

File tree

3 files changed

+22
-47
lines changed

3 files changed

+22
-47
lines changed

conf/modules.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,10 @@ process {
459459
if (meta.single_end && params.fragment_size > 0) {
460460
args << "-fs ${params.fragment_size}"
461461
}
462+
// Add paired-end correction for paired-end data
463+
if (!meta.single_end) {
464+
args << "-pc"
465+
}
462466
// Use -bga instead of -bg to include zero-coverage bins
463467
// This results in lower background levels and better IGV visualization
464468
args << "-bga"

modules/local/bedtools_genomecov.nf

Lines changed: 0 additions & 42 deletions
This file was deleted.

subworkflows/local/bam_bedgraph_bigwig_bedtools_ucsc.nf

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Convert BAM to normalised bigWig via bedGraph using BEDTools and UCSC
33
//
44

5-
include { BEDTOOLS_GENOMECOV } from '../../modules/local/bedtools_genomecov'
5+
include { BEDTOOLS_GENOMECOV } from '../../modules/nf-core/bedtools/genomecov/main'
66
include { UCSC_BEDGRAPHTOBIGWIG } from '../../modules/nf-core/ucsc/bedgraphtobigwig/main'
77

88
workflow BAM_BEDGRAPH_BIGWIG_BEDTOOLS_UCSC {
@@ -14,11 +14,26 @@ workflow BAM_BEDGRAPH_BIGWIG_BEDTOOLS_UCSC {
1414

1515
ch_versions = Channel.empty()
1616

17+
//
18+
// Extract scale factor from flagstat and prepare input for bedtools genomecov
19+
//
20+
ch_bam_scale = ch_bam_flagstat
21+
.map { meta, bam, flagstat ->
22+
// Parse flagstat to get mapped reads count
23+
def flagstat_content = flagstat.text
24+
def mapped_reads = (flagstat_content =~ /(\d+) \+ \d+ mapped/)[0][1] as Integer
25+
def scale_factor = 1000000 / mapped_reads
26+
[meta, bam, scale_factor]
27+
}
28+
1729
//
1830
// Create bedGraph coverage track
1931
//
2032
BEDTOOLS_GENOMECOV (
21-
ch_bam_flagstat
33+
ch_bam_scale,
34+
[],
35+
'bedGraph',
36+
true
2237
)
2338
ch_versions = ch_versions.mix(BEDTOOLS_GENOMECOV.out.versions.first())
2439

@@ -32,9 +47,7 @@ workflow BAM_BEDGRAPH_BIGWIG_BEDTOOLS_UCSC {
3247
ch_versions = ch_versions.mix(UCSC_BEDGRAPHTOBIGWIG.out.versions.first())
3348

3449
emit:
35-
bedgraph = BEDTOOLS_GENOMECOV.out.bedgraph // channel: [ val(meta), [ bedgraph ] ]
36-
scale_factor = BEDTOOLS_GENOMECOV.out.scale_factor // channel: [ val(meta), [ txt ] ]
37-
50+
bedgraph = BEDTOOLS_GENOMECOV.out.genomecov // channel: [ val(meta), [ bedgraph ] ]
3851
bigwig = UCSC_BEDGRAPHTOBIGWIG.out.bigwig // channel: [ val(meta), [ bigwig ] ]
3952

4053
versions = ch_versions // channel: [ versions.yml ]

0 commit comments

Comments
 (0)