Skip to content

Commit

Permalink
Add macs3/callpeak module (#6014)
Browse files Browse the repository at this point in the history
* Add macs3/callpeak module

* Make lint happy

* Add defaults to make nf-core lint happy

* Make nf-core lint happy
  • Loading branch information
JoseEspinosa authored Jul 22, 2024
1 parent 5ad5bc9 commit 6046db9
Show file tree
Hide file tree
Showing 7 changed files with 633 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nf-core/macs3/callpeak/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "macs3_callpeak"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::macs3=3.0.1"
70 changes: 70 additions & 0 deletions modules/nf-core/macs3/callpeak/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@

process MACS3_CALLPEAK {
tag "$meta.id"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/macs3:3.0.1--py311h0152c62_3':
'biocontainers/macs3:3.0.1--py311h0152c62_3' }"

input:
tuple val(meta), path(ipbam), path(controlbam)
val macs3_gsize

output:
tuple val(meta), path("*.{narrowPeak,broadPeak}"), emit: peak
tuple val(meta), path("*.xls") , emit: xls
path "versions.yml" , emit: versions

tuple val(meta), path("*.gappedPeak"), optional:true, emit: gapped
tuple val(meta), path("*.bed") , optional:true, emit: bed
tuple val(meta), path("*.bdg") , optional:true, emit: bdg

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

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def args_list = args.tokenize()
def format = meta.single_end ? 'BAM' : 'BAMPE'
def control = controlbam ? "--control $controlbam" : ''
if(args_list.contains('--format')){
def id = args_list.findIndexOf{it=='--format'}
format = args_list[id+1]
args_list.remove(id+1)
args_list.remove(id)
}
"""
macs3 \\
callpeak \\
${args_list.join(' ')} \\
--gsize $macs3_gsize \\
--format $format \\
--name $prefix \\
--treatment $ipbam \\
$control
cat <<-END_VERSIONS > versions.yml
"${task.process}":
macs3: \$(macs3 --version | sed -e "s/macs3 //g")
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.gappedPeak
touch ${prefix}.bed
touch ${prefix}.bdg
touch ${prefix}.narrowPeak
touch ${prefix}.xls
cat <<-END_VERSIONS > versions.yml
"${task.process}":
macs3: \$(macs3 --version | sed -e "s/macs3 //g")
END_VERSIONS
"""
}
73 changes: 73 additions & 0 deletions modules/nf-core/macs3/callpeak/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "macs3_callpeak"
description: Peak calling of enriched genomic regions of ChIP-seq and ATAC-seq experiments
keywords:
- alignment
- atac-seq
- chip-seq
- peak-calling
tools:
- macs3:
description: "Model Based Analysis for ChIP-Seq data"
homepage: "https://macs3-project.github.io/MACS/"
documentation: "https://macs3-project.github.io/MACS/"
tool_dev_url: "https://github.com/macs3-project/MACS/"
doi: "10.1101/496521"
licence: ["BSD-3-clause"]

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample_1', single_end:false ]`
- ipbam:
type: file
description: The ChIP-seq treatment file
- controlbam:
type: file
description: The control file
- macs2_gsize:
type: string
description: |
Effective genome size. It can be 1.0e+9 or 1000000000,
or shortcuts:'hs' for human (2,913,022,398), 'mm' for mouse
(2,652,783,500), 'ce' for C. elegans (100,286,401)
and 'dm' for fruitfly (142,573,017), Default:hs.
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- versions:
type: file
description: File containing software version
pattern: "versions.yml"
- peak:
type: file
description: BED file containing annotated peaks
pattern: "*.gappedPeak,*.narrowPeak}"
- xls:
type: file
description: xls file containing annotated peaks
pattern: "*.xls"
- gapped:
type: file
description: Optional BED file containing gapped peak
pattern: "*.gappedPeak"
- bed:
type: file
description: Optional BED file containing peak summits locations for every peak
pattern: "*.bed"
- bdg:
type: file
description: Optional bedGraph files for input and treatment input samples
pattern: "*.bdg"

authors:
- "@JoseEspinosa"
maintainers:
- "@JoseEspinosa"
5 changes: 5 additions & 0 deletions modules/nf-core/macs3/callpeak/tests/bam.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: 'MACS3_CALLPEAK' {
ext.args = '--qval 0.1'
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/macs3/callpeak/tests/bed.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {
withName: 'MACS3_CALLPEAK' {
ext.args = '--format BED --qval 10 --nomodel --extsize 200'
}
}
113 changes: 113 additions & 0 deletions modules/nf-core/macs3/callpeak/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
nextflow_process {

name "Test Process MACS3_CALLPEAK"
script "../main.nf"
process "MACS3_CALLPEAK"

tag "modules"
tag "modules_nfcore"
tag "macs3"
tag "macs3/callpeak"

test("homo_sapiens - callpeak - bed") {

when {
config "./bed.config"
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/pacbio/bed/alz.ccs.fl.NEB_5p--NEB_Clontech_3p.flnc.clustered.singletons.merged.aligned_tc.bed', checkIfExists: true) ],
[]
]
input[1] = 4000
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("homo_sapiens - callpeak - bam") {

when {
config "./bam.config"
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.name.sorted.bam', checkIfExists: true) ],
[]
]
input[1] = 40000
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("homo_sapiens - callpeak - control - bam") {

when {
config "./bam.config"
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test.paired_end.name.sorted.bam', checkIfExists: true) ],
[ file(params.modules_testdata_base_path + 'genomics/homo_sapiens/illumina/bam/test2.paired_end.name.sorted.bam', checkIfExists: true) ]
]
input[1] = 40000
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("sarscov2 - bam - stub") {

options "-stub"

when {
process {
"""
input[0] = [
[ id:'test', single_end:false ], // meta map
[ file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true) ],
[]
]
input[1] = 40000
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
Loading

0 comments on commit 6046db9

Please sign in to comment.