-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add IDR module * Add meta and implement main todos * Modifying idr tests * Update tests/config/test_data.config Co-authored-by: Harshil Patel <[email protected]> * Update tests/config/test_data.config Co-authored-by: Harshil Patel <[email protected]> * Update main.nf * Update tests/config/test_data.config Co-authored-by: Harshil Patel <[email protected]> * Update test with new file name Co-authored-by: Jose Espinosa-Carrasco <[email protected]>
- Loading branch information
1 parent
bc8697b
commit 9fb26ae
Showing
7 changed files
with
267 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// | ||
// Utility functions used in nf-core DSL2 module files | ||
// | ||
|
||
// | ||
// Extract name of software tool from process name using $task.process | ||
// | ||
def getSoftwareName(task_process) { | ||
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase() | ||
} | ||
|
||
// | ||
// Extract name of module from process name using $task.process | ||
// | ||
def getProcessName(task_process) { | ||
return task_process.tokenize(':')[-1] | ||
} | ||
|
||
// | ||
// Function to initialise default values and to generate a Groovy Map of available options for nf-core modules | ||
// | ||
def initOptions(Map args) { | ||
def Map options = [:] | ||
options.args = args.args ?: '' | ||
options.args2 = args.args2 ?: '' | ||
options.args3 = args.args3 ?: '' | ||
options.publish_by_meta = args.publish_by_meta ?: [] | ||
options.publish_dir = args.publish_dir ?: '' | ||
options.publish_files = args.publish_files | ||
options.suffix = args.suffix ?: '' | ||
return options | ||
} | ||
|
||
// | ||
// Tidy up and join elements of a list to return a path string | ||
// | ||
def getPathFromList(path_list) { | ||
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries | ||
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", "") } // Trim whitespace and trailing slashes | ||
return paths.join('/') | ||
} | ||
|
||
// | ||
// Function to save/publish module results | ||
// | ||
def saveFiles(Map args) { | ||
def ioptions = initOptions(args.options) | ||
def path_list = [ ioptions.publish_dir ?: args.publish_dir ] | ||
|
||
// Do not publish versions.yml unless running from pytest workflow | ||
if (args.filename.equals('versions.yml') && !System.getenv("NF_CORE_MODULES_TEST")) { | ||
return null | ||
} | ||
if (ioptions.publish_by_meta) { | ||
def key_list = ioptions.publish_by_meta instanceof List ? ioptions.publish_by_meta : args.publish_by_meta | ||
for (key in key_list) { | ||
if (args.meta && key instanceof String) { | ||
def path = key | ||
if (args.meta.containsKey(key)) { | ||
path = args.meta[key] instanceof Boolean ? "${key}_${args.meta[key]}".toString() : args.meta[key] | ||
} | ||
path = path instanceof String ? path : '' | ||
path_list.add(path) | ||
} | ||
} | ||
} | ||
if (ioptions.publish_files instanceof Map) { | ||
for (ext in ioptions.publish_files) { | ||
if (args.filename.endsWith(ext.key)) { | ||
def ext_list = path_list.collect() | ||
ext_list.add(ext.value) | ||
return "${getPathFromList(ext_list)}/$args.filename" | ||
} | ||
} | ||
} else if (ioptions.publish_files == null) { | ||
return "${getPathFromList(path_list)}/$args.filename" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Import generic module functions | ||
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions' | ||
|
||
params.options = [:] | ||
options = initOptions(params.options) | ||
|
||
process IDR { | ||
tag "$prefix" | ||
label 'process_low' | ||
publishDir "${params.outdir}", | ||
mode: params.publish_dir_mode, | ||
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:[:], publish_by_meta:[]) } | ||
|
||
conda (params.enable_conda ? "bioconda::idr=2.0.4.2" : null) | ||
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) { | ||
container "https://depot.galaxyproject.org/singularity/idr:2.0.4.2--py39hcbe4a3b_5" | ||
} else { | ||
container "quay.io/biocontainers/idr:2.0.4.2--py38h9af456f_5" | ||
} | ||
|
||
input: | ||
path peaks | ||
val peak_type | ||
val prefix | ||
|
||
output: | ||
path "*idrValues.txt", emit: idr | ||
path "*log.txt" , emit: log | ||
path "*.png" , emit: png | ||
path "versions.yml" , emit: versions | ||
|
||
script: | ||
if (peaks.toList().size < 2) { | ||
log.error "[ERROR] idr needs at least two replicates only one provided." | ||
} | ||
def peak_types = ['narrowPeak', 'broadPeak', 'bed'] | ||
if (!peak_types.contains(peak_type)) { | ||
log.error "[ERROR] Invalid option: '${peak_type}'. Valid options for 'peak_type': ${peak_types.join(', ')}." | ||
} | ||
def idr_vals = prefix ? "${prefix}.idrValues.txt" : "idrValues.txt" | ||
def log_file = prefix ? "${prefix}.log.txt" : "log.txt" | ||
""" | ||
idr \\ | ||
--samples $peaks \\ | ||
--input-file-type $peak_type \\ | ||
--output-file $idr_vals \\ | ||
--log-output-file $log_file \\ | ||
--plot \\ | ||
$options.args | ||
cat <<-END_VERSIONS > versions.yml | ||
${getProcessName(task.process)}: | ||
${getSoftwareName(task.process)}: \$(echo \$(idr --version 2>&1) | sed 's/^.*IDR //; s/ .*\$//') | ||
END_VERSIONS | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: idr | ||
description: | | ||
Measures reproducibility of ChIP-seq, ATAC-seq peaks using IDR (Irreproducible | ||
Discovery Rate) | ||
keywords: | ||
- IDR | ||
- peaks | ||
- ChIP-seq | ||
- ATAC-seq | ||
tools: | ||
- idr: | ||
description: | | ||
The IDR (Irreproducible Discovery Rate) framework is a unified approach | ||
to measure the reproducibility of findings identified from replicate | ||
experiments and provide highly stable thresholds based on reproducibility. | ||
homepage: None | ||
documentation: None | ||
tool_dev_url: https://github.com/kundajelab/idr | ||
doi: "" | ||
licence: ['GPL v2'] | ||
input: | ||
- peaks: | ||
type: tuple of two files | ||
description: BED, narrowPeak or broadPeak files of replicates | ||
pattern: "*" | ||
- peak_type: | ||
type: value | ||
description: Type of peak file | ||
pattern: "{narrowPeak,broadPeak,bed}" | ||
- prefix: | ||
type: value | ||
description: Prefix for output files | ||
output: | ||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
- idr: | ||
type: file | ||
description: Text file containing IDR values | ||
pattern: "*.{txt}" | ||
- log: | ||
type: file | ||
description: Log file | ||
pattern: "*.{txt}" | ||
- png: | ||
type: file | ||
description: Plot generated by idr | ||
pattern: "*{.png}" | ||
|
||
authors: | ||
- "@drpatelh" | ||
- "@joseespinosa" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env nextflow | ||
|
||
nextflow.enable.dsl = 2 | ||
|
||
include { IDR } from '../../../modules/idr/main.nf' addParams( options: [:] ) | ||
|
||
workflow test_idr_narrowpeak { | ||
|
||
input = [ | ||
file(params.test_data['homo_sapiens']['illumina']['test_narrowpeak'], checkIfExists: true), | ||
file(params.test_data['homo_sapiens']['illumina']['test2_narrowpeak'], checkIfExists: true) | ||
] | ||
|
||
IDR ( input, 'narrowPeak', 'test' ) | ||
} | ||
|
||
workflow test_idr_broadpeak { | ||
|
||
input = [ | ||
file(params.test_data['homo_sapiens']['illumina']['test_broadpeak'], checkIfExists: true), | ||
file(params.test_data['homo_sapiens']['illumina']['test2_broadpeak'], checkIfExists: true) | ||
] | ||
|
||
IDR ( input, 'broadPeak', 'test' ) | ||
} | ||
|
||
workflow test_idr_noprefix { | ||
|
||
input = [ | ||
file(params.test_data['homo_sapiens']['illumina']['test_narrowpeak'], checkIfExists: true), | ||
file(params.test_data['homo_sapiens']['illumina']['test2_narrowpeak'], checkIfExists: true) | ||
] | ||
|
||
IDR ( input, 'narrowPeak', '' ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
- name: idr test_idr_narrowpeak | ||
command: nextflow run tests/modules/idr -entry test_idr_narrowpeak -c tests/config/nextflow.config | ||
tags: | ||
- idr | ||
files: | ||
- path: output/idr/test.idrValues.txt | ||
md5sum: 09be837cc6abbc3eb5958b74802eea55 | ||
- path: output/idr/test.idrValues.txt.png | ||
md5sum: 4a7143ccc0ccadb37c2317bf626e6d96 | ||
- path: output/idr/test.log.txt | ||
md5sum: 6443507ac66b9d3b64bc56b78328083e | ||
|
||
- name: idr test_idr_broadpeak | ||
command: nextflow run tests/modules/idr -entry test_idr_broadpeak -c tests/config/nextflow.config | ||
tags: | ||
- idr | ||
files: | ||
- path: output/idr/test.idrValues.txt | ||
md5sum: 387441c716815e4caec3e70a2cc11a4a | ||
- path: output/idr/test.idrValues.txt.png | ||
md5sum: 7204083ca5b920b4215a5991c12cb4e7 | ||
- path: output/idr/test.log.txt | ||
md5sum: e6917133112b5cec135c182ffac19237 | ||
|
||
- name: idr test_idr_noprefix | ||
command: nextflow run tests/modules/idr -entry test_idr_noprefix -c tests/config/nextflow.config | ||
tags: | ||
- idr | ||
files: | ||
- path: output/idr/idrValues.txt | ||
md5sum: 09be837cc6abbc3eb5958b74802eea55 | ||
- path: output/idr/idrValues.txt.png | ||
md5sum: 4a7143ccc0ccadb37c2317bf626e6d96 | ||
- path: output/idr/log.txt | ||
md5sum: 6443507ac66b9d3b64bc56b78328083e |