Skip to content

Commit

Permalink
Update Genrich module input tuple and argument (nf-core#3720)
Browse files Browse the repository at this point in the history
* Added treat & control lists inputs and SE modifier

* Added treat & control lists inputs and SE modifier

* Genrich: Added multiple reps and SE modifier

* Genrich: Added multiple reps and SE modifier 2

* Genrich: simplified layout definition

* Removing value channels

* Line up commas

* Align commas

* Increase test -p to avoid empty file

---------

Co-authored-by: Simon Pearce <[email protected]>
Co-authored-by: Friederike Hanssen <[email protected]>
  • Loading branch information
3 people authored Oct 18, 2023
1 parent e18a2de commit 53cb517
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 82 deletions.
57 changes: 23 additions & 34 deletions modules/nf-core/genrich/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,43 @@ process GENRICH {
'biocontainers/genrich:0.6.1--h5bf99c6_1' }"

input:
tuple val(meta), path(treatment_bam)
path control_bam
tuple val(meta), path(treatment_bam), path(control_bam)
path blacklist_bed
val save_pvalues
val save_pileup
val save_bed
val save_duplicates

output:
tuple val(meta), path("*narrowPeak") , emit: peaks
tuple val(meta), path("*pvalues.bedGraph"), optional:true, emit: bedgraph_pvalues
tuple val(meta), path("*pileup.bedGraph") , optional:true, emit: bedgraph_pileup
tuple val(meta), path("*intervals.bed") , optional:true, emit: bed_intervals
tuple val(meta), path("*duplicates.txt") , optional:true, emit: duplicates
path "versions.yml" , emit: versions
tuple val(meta), path("*.narrowPeak") , emit: peak
path "versions.yml" , emit: versions

tuple val(meta), path("*.pvalues.bedGraph"), optional:true, emit: bedgraph_pvalues
tuple val(meta), path("*.pileup.bedGraph") , optional:true, emit: bedgraph_pileup
tuple val(meta), path("*.intervals.bed") , optional:true, emit: bed_intervals
tuple val(meta), path("*.duplicates.txt") , optional:true, emit: duplicates

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def control = control_bam ? "-c $control_bam" : ''
def blacklist = blacklist_bed ? "-E $blacklist_bed" : ""
def pvalues = save_pvalues ? "-f ${prefix}.pvalues.bedGraph" : ""
def pileup = save_pileup ? "-k ${prefix}.pileup.bedGraph" : ""
def bed = save_bed ? "-b ${prefix}.intervals.bed" : ""
def duplicates = ""
if (save_duplicates) {
if (args.contains('-r')) {
duplicates = "-R ${prefix}.duplicates.txt"
} else {
log.info '[Genrich] Duplicates can only be saved if they are filtered, defaulting to -r option (Remove PCR duplicates).'
duplicates = "-r -R ${prefix}.duplicates.txt"
}
def args = task.ext.args ?: ""
def prefix = task.ext.prefix ?: "${meta.id}"
def treatment = treatment_bam ? "-t ${treatment_bam.join(',')}" : ""
def control = control_bam ? "-c ${control_bam.join(',')}" : ""
def blacklist = blacklist_bed ? "-E $blacklist_bed" : ""

if (meta.single_end && (!args.contains("-y") && !args.contains("-w"))) {
log.info '[Genrich] Single-end data can only be analyzed if unpaired alignments are kept (-y or -w <int>), defaulting to -y option.'
args = "-y ${args}"
}
if (args.contains("-R") && !args.contains("-r")) {
log.info '[Genrich] Duplicates can only be saved if they are filtered out, defaulting to -r option (Remove PCR duplicates).'
args = "-r ${args}"
}
"""
Genrich \\
-t $treatment_bam \\
$args \\
$treatment \\
$control \\
$blacklist \\
-o ${prefix}.narrowPeak \\
$pvalues \\
$pileup \\
$bed \\
$duplicates \\
$control
-o ${prefix}.narrowPeak
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
5 changes: 3 additions & 2 deletions modules/nf-core/genrich/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ input:
e.g. [ id:'test', single_end:false ]
- treatment_bam:
type: file
description: Coordinate sorted BAM/SAM file from treatment sample
description: Coordinate sorted BAM/SAM file from treatment sample or list of BAM/SAM files from biological replicates
pattern: "*.{bam,sam}"
- control_bam:
type: file
description: Coordinate sorted BAM/SAM file from control sample
description: Coordinate sorted BAM/SAM file from control sample or list of BAM/SAM files from control samples
pattern: "*.{bam,sam}"
- blacklist_bed:
type: file
Expand Down Expand Up @@ -77,3 +77,4 @@ output:
pattern: "*.{version.txt}"
authors:
- "@JoseEspinosa"
- "@samuelruizperez"
73 changes: 35 additions & 38 deletions tests/modules/nf-core/genrich/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,73 @@ nextflow.enable.dsl = 2

include { GENRICH } from '../../../../modules/nf-core/genrich/main.nf'
include { GENRICH as GENRICH_CTRL } from '../../../../modules/nf-core/genrich/main.nf'
include { GENRICH as GENRICH_SE } from '../../../../modules/nf-core/genrich/main.nf'
include { GENRICH as GENRICH_ALL } from '../../../../modules/nf-core/genrich/main.nf'
include { GENRICH as GENRICH_ATACSEQ } from '../../../../modules/nf-core/genrich/main.nf'
include { GENRICH as GENRICH_LIST } from '../../../../modules/nf-core/genrich/main.nf'

workflow test_genrich {
input = [ [ id:'test', single_end:false ], // meta map
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]]
control = [ ]
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ],
[ ]]
blacklist = [ ]

save_pvalues = false
save_pileup = false
save_bed = false
save_duplicates = false

GENRICH ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates )
GENRICH ( input, blacklist )
}

workflow test_genrich_ctrl {
input = [ [ id:'test', single_end:false ], // meta map
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]]
control = [ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ]
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ],
[ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ]]
blacklist = [ ]

save_pvalues = false
save_pileup = false
save_bed = false
save_duplicates = false
GENRICH_CTRL ( input, blacklist )
}

workflow test_genrich_se {
input = [ [ id:'test', single_end:true ], // meta map
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ],
[ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ]]
blacklist = [ ]

GENRICH_CTRL ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates )
GENRICH_SE ( input, blacklist )
}


workflow test_genrich_all_outputs {
input = [ [ id:'test', single_end:false ], // meta map
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]]
control = [ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ]
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ],
[ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ]]
blacklist = [ ]

save_pvalues = true
save_pileup = true
save_bed = true
save_duplicates = true

GENRICH_ALL ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates )
GENRICH_ALL ( input, blacklist )
}

workflow test_genrich_blacklist {
input = [ [ id:'test', single_end:false ], // meta map
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]]
control = [ ]
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ],
[ ]]
blacklist = [ file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)]

save_pvalues = false
save_pileup = false
save_bed = false
save_duplicates = false

GENRICH ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates )
GENRICH ( input, blacklist )
}

workflow test_genrich_atacseq {
input = [ [ id:'test', single_end:false ], // meta map
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]]
control = [ ]
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ],
[ ]]
blacklist = [ ]

save_pvalues = false
save_pileup = false
save_bed = false
save_duplicates = false
GENRICH_ATACSEQ ( input, blacklist )
}

workflow test_genrich_list {
input = [ [ id:'test', single_end:false ], // meta map
[ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true),
file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true)],
[ ]]
blacklist = [ file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)]

GENRICH_ATACSEQ ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates )
GENRICH_LIST ( input, blacklist )
}

17 changes: 16 additions & 1 deletion tests/modules/nf-core/genrich/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,27 @@ process {
ext.args = '-p 0.9'
}

withName: GENRICH_SE {
ext.args = '-p 0.9'
}

withName: GENRICH_ALL {
ext.args = '-r -p 0.1'
ext.args = {
[
"-p 0.9",
"-k ${meta.id}.pileup.bedGraph",
"-f ${meta.id}.pvalues.bedGraph",
"-b ${meta.id}.intervals.bed",
"-R ${meta.id}.duplicates.txt"
].join(' ').trim()
}
}

withName: GENRICH_ATACSEQ {
ext.args = '-j -p 0.1'
}

withName: GENRICH_LIST {
ext.args = '-p 0.1'
}
}
37 changes: 30 additions & 7 deletions tests/modules/nf-core/genrich/test.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
- name: genrich test_genrich
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/genrich/nextflow.config
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich -c ./tests/config/nextflow.config
tags:
- genrich
files:
- path: output/genrich/test.narrowPeak
md5sum: 6afabdd3f691c7c84c66ff8a23984681
- path: output/genrich/versions.yml

- name: genrich test_genrich_ctrl
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_ctrl -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/genrich/nextflow.config
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_ctrl -c ./tests/config/nextflow.config
tags:
- genrich
files:
- path: output/genrich/test.narrowPeak
md5sum: 2fcc392360b317f5ebee88cdbc149e05
- path: output/genrich/versions.yml

- name: genrich test_genrich_se
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_se -c ./tests/config/nextflow.config
tags:
- genrich
files:
- path: output/genrich/test.narrowPeak
md5sum: 1a835e303b090b5eea91b8e4f5cc1df6
- path: output/genrich/versions.yml

- name: genrich test_genrich_all_outputs
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_all_outputs -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/genrich/nextflow.config
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_all_outputs -c ./tests/config/nextflow.config
tags:
- genrich
files:
Expand All @@ -24,24 +35,36 @@
- path: output/genrich/test.intervals.bed
md5sum: 4bea65caa3f4043d703af4b57161112e
- path: output/genrich/test.narrowPeak
md5sum: d41d8cd98f00b204e9800998ecf8427e
md5sum: 82bc06c2e44e4d91152a6ac6557a2c6e
- path: output/genrich/test.pileup.bedGraph
md5sum: 03e53848de695b5794f32f15b2709203
- path: output/genrich/test.pvalues.bedGraph
md5sum: b14feef34b6d2379a173a734ca963cde
md5sum: 21ad9731340e9bedc30c4d34f7db7751
- path: output/genrich/versions.yml

- name: genrich test_genrich_blacklist
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_blacklist -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/genrich/nextflow.config
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_blacklist -c ./tests/config/nextflow.config
tags:
- genrich
files:
- path: output/genrich/test.narrowPeak
md5sum: 6afabdd3f691c7c84c66ff8a23984681
- path: output/genrich/versions.yml

- name: genrich test_genrich_atacseq
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_atacseq -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/genrich/nextflow.config
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_atacseq -c ./tests/config/nextflow.config
tags:
- genrich
files:
- path: output/genrich/test.narrowPeak
md5sum: ddea556b820f8be3695ffdf6c6f70aff
- path: output/genrich/versions.yml

- name: genrich test_genrich_list
command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_list -c ./tests/config/nextflow.config
tags:
- genrich
files:
- path: output/genrich/test.narrowPeak
md5sum: f793e0ff59274e6364151a7cd4eeeafd
- path: output/genrich/versions.yml

0 comments on commit 53cb517

Please sign in to comment.