mirror of
https://github.com/MillironX/nf-core_modules.git
synced 2024-12-22 11:08:17 +00:00
new module: gatk4/calculatecontamination (#778)
* initiated files for calculate contamination * pushing local repo to remote * created script, filled in meta yml, created tests and test yml. local checks passing, needs repo side test data * added option and tests for outputting optional segmentation file * saving for test push * versions updated, test data added * Update main.nf * fixed versions info, should report correctly now * small update to main.nf outputs formatting * Apply suggestions from code review * Update test_data.config * Apply suggestions from code review Co-authored-by: GCJMackenzie <gavin.mackenzie@nibsc.org> Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
parent
053797510d
commit
aa32a8a72e
7 changed files with 250 additions and 0 deletions
78
modules/gatk4/calculatecontamination/functions.nf
Normal file
78
modules/gatk4/calculatecontamination/functions.nf
Normal file
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
47
modules/gatk4/calculatecontamination/main.nf
Normal file
47
modules/gatk4/calculatecontamination/main.nf
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
// Import generic module functions
|
||||||
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
||||||
|
|
||||||
|
params.options = [:]
|
||||||
|
options = initOptions(params.options)
|
||||||
|
|
||||||
|
process GATK4_CALCULATECONTAMINATION {
|
||||||
|
tag "$meta.id"
|
||||||
|
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:meta, publish_by_meta:['id']) }
|
||||||
|
|
||||||
|
conda (params.enable_conda ? "bioconda::gatk4=4.2.0.0" : null)
|
||||||
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
||||||
|
container "https://depot.galaxyproject.org/singularity/gatk4:4.2.0.0--0"
|
||||||
|
} else {
|
||||||
|
container "quay.io/biocontainers/gatk4:4.2.0.0--0"
|
||||||
|
}
|
||||||
|
|
||||||
|
input:
|
||||||
|
tuple val(meta), path(pileup), path(matched)
|
||||||
|
val segmentout
|
||||||
|
|
||||||
|
output:
|
||||||
|
tuple val(meta), path('*.contamination.table') , emit: contamination
|
||||||
|
tuple val(meta), path('*.segmentation.table') , optional:true, emit: segmentation
|
||||||
|
path "versions.yml" , emit: versions
|
||||||
|
|
||||||
|
script:
|
||||||
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
||||||
|
def matched_command = matched ? " -matched ${matched} " : ''
|
||||||
|
def segment_command = segmentout ? " -segments ${prefix}.segmentation.table" : ''
|
||||||
|
"""
|
||||||
|
gatk CalculateContamination \\
|
||||||
|
-I $pileup \\
|
||||||
|
$matched_command \\
|
||||||
|
-O ${prefix}.contamination.table \\
|
||||||
|
$segment_command \\
|
||||||
|
$options.args
|
||||||
|
|
||||||
|
cat <<-END_VERSIONS > versions.yml
|
||||||
|
${getProcessName(task.process)}:
|
||||||
|
${getSoftwareName(task.process)}: \$(echo \$(gatk --version 2>&1) | sed 's/^.*(GATK) v//; s/ .*\$//')
|
||||||
|
END_VERSIONS
|
||||||
|
"""
|
||||||
|
}
|
53
modules/gatk4/calculatecontamination/meta.yml
Normal file
53
modules/gatk4/calculatecontamination/meta.yml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
name: gatk4_calculatecontamination
|
||||||
|
description: |
|
||||||
|
Calculates the fraction of reads from cross-sample contamination based on summary tables from getpileupsummaries. Output to be used with filtermutectcalls.
|
||||||
|
keywords:
|
||||||
|
- gatk4
|
||||||
|
- calculatecontamination
|
||||||
|
- cross-samplecontamination
|
||||||
|
- getpileupsummaries
|
||||||
|
- filtermutectcalls
|
||||||
|
tools:
|
||||||
|
- gatk4:
|
||||||
|
description: |
|
||||||
|
Developed in the Data Sciences Platform at the Broad Institute, the toolkit offers a wide variety of tools
|
||||||
|
with a primary focus on variant discovery and genotyping. Its powerful processing engine
|
||||||
|
and high-performance computing features make it capable of taking on projects of any size.
|
||||||
|
homepage: https://gatk.broadinstitute.org/hc/en-us
|
||||||
|
documentation: https://gatk.broadinstitute.org/hc/en-us/categories/360002369672s
|
||||||
|
doi: 10.1158/1538-7445.AM2017-3590
|
||||||
|
|
||||||
|
input:
|
||||||
|
- meta:
|
||||||
|
type: map
|
||||||
|
description: |
|
||||||
|
Groovy Map containing sample information
|
||||||
|
e.g. [ id:'test' ]
|
||||||
|
- pileup:
|
||||||
|
type: file
|
||||||
|
description: File containing the pileups summary table of a tumor sample to be used to calculate contamination.
|
||||||
|
pattern: "*.pileups.table"
|
||||||
|
- matched:
|
||||||
|
type: file
|
||||||
|
description: File containing the pileups summary table of a normal sample that matches with the tumor sample specified in pileup argument. This is an optional input.
|
||||||
|
pattern: "*.pileups.table"
|
||||||
|
- segmentout:
|
||||||
|
type: boolean
|
||||||
|
description: specifies whether to output the segmentation table.
|
||||||
|
|
||||||
|
output:
|
||||||
|
- contamination:
|
||||||
|
type: file
|
||||||
|
description: File containing the contamination table.
|
||||||
|
pattern: "*.contamination.table"
|
||||||
|
- segmentation:
|
||||||
|
type: file
|
||||||
|
description: optional output table containing segmentation of tumor minor allele fractions.
|
||||||
|
pattern: "*.segmentation.table"
|
||||||
|
- versions:
|
||||||
|
type: file
|
||||||
|
description: File containing software versions
|
||||||
|
pattern: "versions.yml"
|
||||||
|
|
||||||
|
authors:
|
||||||
|
- "@GCJMackenzie"
|
|
@ -386,6 +386,10 @@ gatk4/bedtointervallist:
|
||||||
- modules/gatk4/bedtointervallist/**
|
- modules/gatk4/bedtointervallist/**
|
||||||
- tests/modules/gatk4/bedtointervallist/**
|
- tests/modules/gatk4/bedtointervallist/**
|
||||||
|
|
||||||
|
gatk4/calculatecontamination:
|
||||||
|
- modules/gatk4/calculatecontamination/**
|
||||||
|
- tests/modules/gatk4/calculatecontamination/**
|
||||||
|
|
||||||
gatk4/createsequencedictionary:
|
gatk4/createsequencedictionary:
|
||||||
- modules/gatk4/createsequencedictionary/**
|
- modules/gatk4/createsequencedictionary/**
|
||||||
- tests/modules/gatk4/createsequencedictionary/**
|
- tests/modules/gatk4/createsequencedictionary/**
|
||||||
|
|
|
@ -153,6 +153,8 @@ params {
|
||||||
|
|
||||||
test_baserecalibrator_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test.baserecalibrator.table"
|
test_baserecalibrator_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test.baserecalibrator.table"
|
||||||
test2_baserecalibrator_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test2.baserecalibrator.table"
|
test2_baserecalibrator_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test2.baserecalibrator.table"
|
||||||
|
test_pileups_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test.pileups.table"
|
||||||
|
test2_pileups_table = "${test_data_dir}/genomics/homo_sapiens/illumina/gatk/test2.pileups.table"
|
||||||
|
|
||||||
test_genome_vcf = "${test_data_dir}/genomics/homo_sapiens/illumina/gvcf/test.genome.vcf"
|
test_genome_vcf = "${test_data_dir}/genomics/homo_sapiens/illumina/gvcf/test.genome.vcf"
|
||||||
test_genome_vcf_gz = "${test_data_dir}/genomics/homo_sapiens/illumina/gvcf/test.genome.vcf.gz"
|
test_genome_vcf_gz = "${test_data_dir}/genomics/homo_sapiens/illumina/gvcf/test.genome.vcf.gz"
|
||||||
|
|
38
tests/modules/gatk4/calculatecontamination/main.nf
Normal file
38
tests/modules/gatk4/calculatecontamination/main.nf
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#!/usr/bin/env nextflow
|
||||||
|
|
||||||
|
nextflow.enable.dsl = 2
|
||||||
|
|
||||||
|
include { GATK4_CALCULATECONTAMINATION } from '../../../../modules/gatk4/calculatecontamination/main.nf' addParams( options: [:] )
|
||||||
|
|
||||||
|
workflow test_gatk4_calculatecontamination_tumor_only {
|
||||||
|
|
||||||
|
input = [ [ id:'test' ], // meta map
|
||||||
|
file(params.test_data['homo_sapiens']['illumina']['test2_pileups_table'], checkIfExists: true),
|
||||||
|
[] ]
|
||||||
|
|
||||||
|
segmentout = false
|
||||||
|
|
||||||
|
GATK4_CALCULATECONTAMINATION ( input, segmentout )
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_gatk4_calculatecontamination_matched_pair {
|
||||||
|
|
||||||
|
input = [ [ id:'test' ], // meta map
|
||||||
|
file(params.test_data['homo_sapiens']['illumina']['test2_pileups_table'], checkIfExists: true),
|
||||||
|
file(params.test_data['homo_sapiens']['illumina']['test_pileups_table'], checkIfExists: true) ]
|
||||||
|
|
||||||
|
segmentout = false
|
||||||
|
|
||||||
|
GATK4_CALCULATECONTAMINATION ( input, segmentout )
|
||||||
|
}
|
||||||
|
|
||||||
|
workflow test_gatk4_calculatecontamination_segmentation {
|
||||||
|
|
||||||
|
input = [ [ id:'test' ], // meta map
|
||||||
|
file(params.test_data['homo_sapiens']['illumina']['test2_pileups_table'], checkIfExists: true),
|
||||||
|
file(params.test_data['homo_sapiens']['illumina']['test_pileups_table'], checkIfExists: true) ]
|
||||||
|
|
||||||
|
segmentout = true
|
||||||
|
|
||||||
|
GATK4_CALCULATECONTAMINATION ( input, segmentout )
|
||||||
|
}
|
28
tests/modules/gatk4/calculatecontamination/test.yml
Normal file
28
tests/modules/gatk4/calculatecontamination/test.yml
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
- name: gatk4 calculatecontamination test_gatk4_calculatecontamination_tumor_only
|
||||||
|
command: nextflow run tests/modules/gatk4/calculatecontamination -entry test_gatk4_calculatecontamination_tumor_only -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- gatk4/calculatecontamination
|
||||||
|
- gatk4
|
||||||
|
files:
|
||||||
|
- path: output/gatk4/test.contamination.table
|
||||||
|
md5sum: ff348a26dd09404239a7ed0da7d98874
|
||||||
|
|
||||||
|
- name: gatk4 calculatecontamination test_gatk4_calculatecontamination_matched_pair
|
||||||
|
command: nextflow run tests/modules/gatk4/calculatecontamination -entry test_gatk4_calculatecontamination_matched_pair -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- gatk4/calculatecontamination
|
||||||
|
- gatk4
|
||||||
|
files:
|
||||||
|
- path: output/gatk4/test.contamination.table
|
||||||
|
md5sum: ff348a26dd09404239a7ed0da7d98874
|
||||||
|
|
||||||
|
- name: gatk4 calculatecontamination test_gatk4_calculatecontamination_segmentation
|
||||||
|
command: nextflow run tests/modules/gatk4/calculatecontamination -entry test_gatk4_calculatecontamination_segmentation -c tests/config/nextflow.config
|
||||||
|
tags:
|
||||||
|
- gatk4/calculatecontamination
|
||||||
|
- gatk4
|
||||||
|
files:
|
||||||
|
- path: output/gatk4/test.contamination.table
|
||||||
|
md5sum: ff348a26dd09404239a7ed0da7d98874
|
||||||
|
- path: output/gatk4/test.segmentation.table
|
||||||
|
md5sum: 478cb4f69ec001944b9cd0e7e4de01ef
|
Loading…
Reference in a new issue