Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Genrich module input tuple and argument #3720

Merged
merged 18 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions modules/nf-core/genrich/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,36 @@ 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("*.narrowPeak") , emit: peak
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
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

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 args = task.ext.args ?: ""
def prefix = task.ext.prefix ?: "${meta.id}"
def layout = (!args.contains("-y") && meta.single_end) ? "-y" : ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this doing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, would like also to know

Copy link
Contributor Author

@samuelruizperez samuelruizperez Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Single-end data can only be analyzed if unpaired alignments are kept (-y or -w <int>) so it defaults to -y if neither is already in args (jsh58/Genrich#77 (comment)). Should be clearer now.

def treatment = treatment_bam ? "-t ${treatment_bam.sort().join(',')}" : ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you sort here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, is it trying to maintain the correspondence between control and treatment files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, is it trying to maintain the correspondence between control and treatment files?

That was my intention, but I don't think it's necessary (?)

def control = control_bam ? "-c ${control_bam.sort().join(',')}" : ""
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"
Expand All @@ -44,11 +46,12 @@ process GENRICH {
duplicates = "-r -R ${prefix}.duplicates.txt"
}
}

"""
Genrich \\
-t $treatment_bam \\
$treatment \\
$args \\
$control \\
$layout \\
$blacklist \\
-o ${prefix}.narrowPeak \\
$pvalues \\
Expand All @@ -62,4 +65,5 @@ process GENRICH {
genrich: \$(echo \$(Genrich --version 2>&1) | sed 's/^Genrich, version //; s/ .*\$//')
END_VERSIONS
"""

}
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"
46 changes: 31 additions & 15 deletions tests/modules/nf-core/genrich/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,74 +6,90 @@ 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_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, save_pvalues, save_pileup, save_bed, save_duplicates )
}

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, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates )
GENRICH_CTRL ( input, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates )
}

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, save_pvalues, save_pileup, save_bed, save_duplicates )
}

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, save_pvalues, save_pileup, save_bed, save_duplicates )
}

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, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates )
GENRICH_ATACSEQ ( input, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates )
}

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)]

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

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

3 changes: 3 additions & 0 deletions tests/modules/nf-core/genrich/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ process {
ext.args = '-j -p 0.1'
}

withName: GENRICH_LIST {
ext.args = '-p 0.1'
}
}
14 changes: 14 additions & 0 deletions tests/modules/nf-core/genrich/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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
Expand All @@ -13,6 +14,7 @@
files:
- path: output/genrich/test.narrowPeak
md5sum: 2fcc392360b317f5ebee88cdbc149e05
- 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
Expand All @@ -29,6 +31,7 @@
md5sum: 03e53848de695b5794f32f15b2709203
- path: output/genrich/test.pvalues.bedGraph
md5sum: b14feef34b6d2379a173a734ca963cde
- 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
Expand All @@ -37,6 +40,7 @@
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
Expand All @@ -45,3 +49,13 @@
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 -c ./tests/modules/nf-core/genrich/nextflow.config
tags:
- genrich
files:
- path: output/genrich/test.narrowPeak
md5sum: f793e0ff59274e6364151a7cd4eeeafd
- path: output/genrich/versions.yml
Loading