Filtermutectcalls (#796)

* first commit with files for filtermutectcalls initialised

* found missing test file that needs to be resolved

* saving config changes

* fixing pytest_module conflict

* finished module, just needs repository side tests added

* test data added, versions file updated

* modified to emit correct versions file

* Update main.nf

* Update test_data.config

* updated test script

* fixed main.nf

* Update main.nf

* Update main.nf

* removed whitespace from test script

* Update test_data.config

* Update .gitignore

* Update test_data.config

* tests changed to new names, main script edited to match comments on learnreads pr

* Update meta.yml

* Apply suggestions from code review

* Update main.nf

* Apply suggestions from code review

* Apply suggestions from code review

* Update main.nf

* Update main.nf

* Update main.nf

* Update main.nf

Co-authored-by: GCJMackenzie <gavin.mackenzie@nibsc.org>
Co-authored-by: James A. Fellows Yates <jfy133@gmail.com>
Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
This commit is contained in:
GCJMackenzie 2021-10-23 18:45:19 +01:00 committed by GitHub
parent 81ed0e0ff2
commit 7676d9d728
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 331 additions and 0 deletions

View 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"
}
}

View file

@ -0,0 +1,65 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
params.options = [:]
options = initOptions(params.options)
process GATK4_FILTERMUTECTCALLS {
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(vcf), path(tbi), path(stats), path(orientationbias), path(segmentation), path(contaminationfile), val(contaminationest)
path fasta
path fastaidx
path dict
output:
tuple val(meta), path("*.vcf.gz") , emit: vcf
tuple val(meta), path("*.vcf.gz.tbi") , emit: tbi
tuple val(meta), path("*.filteringStats.tsv"), emit: stats
path "versions.yml" , emit: versions
script:
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
def orientationbias_options = ''
if (orientationbias) {
orientationbias_options = '--orientation-bias-artifact-priors ' + orientationbias.join(' --orientation-bias-artifact-priors ')
}
def segmentation_options = ''
if (segmentation) {
segmentation_options = '--tumor-segmentation ' + segmentation.join(' --tumor-segmentation ')
}
def contamination_options = contaminationest ? " --contamination-estimate ${contaminationest} " : ''
if (contaminationfile) {
contamination_options = '--contamination-table ' + contaminationfile.join(' --contamination-table ')
}
"""
gatk FilterMutectCalls \\
-R $fasta \\
-V $vcf \\
$orientationbias_options \\
$segmentation_options \\
$contamination_options \\
-O ${prefix}.vcf.gz \\
$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
"""
}

View file

@ -0,0 +1,84 @@
name: gatk4_filtermutectcalls
description: |
Filters the raw output of mutect2, can optionally use outputs of calculatecontamination and learnreadorientationmodel to improve filtering.
keywords:
- filtermutectcalls
- mutect2
- gatk4
- filtervcf
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' ]
- vcf:
type: file
description: compressed vcf file of mutect2calls
pattern: "*.vcf.gz"
- tbi:
type: file
description: Index of vcf file
pattern: "*vcf.gz.tbi"
- stats:
type: file
description: Stats file that pairs with output vcf file
pattern: "*vcf.gz.stats"
- orientationbias:
type: list
description: files containing artifact priors for input vcf. Optional input.
pattern: "*.artifact-prior.tar.gz"
- segmentation:
type: list
description: tables containing segmentation information for input vcf. Optional input.
pattern: "*.segmentation.table"
- contaminationfile:
type: list
description: table(s) containing contamination contamination data for input vcf. Optional input, takes priority over contaminationest.
pattern: "*.contamination.table"
- contaminationest:
type: val
description: estimation of contamination value as a double. Optional input, will only be used if contaminationfile is not specified.
- fasta:
type: file
description: The reference fasta file
pattern: "*.fasta"
- fastaidx:
type: file
description: Index of reference fasta file
pattern: "fasta.fai"
- dict:
type: file
description: GATK sequence dictionary
pattern: "*.dict"
output:
- vcf:
type: file
description: file containing filtered mutect2 calls.
pattern: "*.vcf.gz"
- tbi:
type: file
description: tbi file that pairs with vcf.
pattern: "*.vcf.gz.tbi"
- stats:
type: file
description: file containing statistics of the filtermutectcalls run.
pattern: "*.filteringStats.tsv"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@GCJMackenzie"

View file

@ -410,6 +410,10 @@ gatk4/fastqtosam:
- modules/gatk4/fastqtosam/** - modules/gatk4/fastqtosam/**
- tests/modules/gatk4/fastqtosam/** - tests/modules/gatk4/fastqtosam/**
gatk4/filtermutectcalls:
- modules/gatk4/filtermutectcalls/**
- tests/modules/gatk4/filtermutectcalls/**
gatk4/getpileupsummaries: gatk4/getpileupsummaries:
- modules/gatk4/getpileupsummaries/** - modules/gatk4/getpileupsummaries/**
- tests/modules/gatk4/getpileupsummaries/** - tests/modules/gatk4/getpileupsummaries/**

View file

@ -0,0 +1,65 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { GATK4_FILTERMUTECTCALLS } from '../../../../modules/gatk4/filtermutectcalls/main.nf' addParams( options: [suffix:'.filtered'] )
workflow test_gatk4_filtermutectcalls_base {
input = [
[ id:'test'], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_vcf_gz'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_vcf_gz_tbi'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_vcf_gz_stats'], checkIfExists: true),
[],
[],
[],
[]
]
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
fastaidx = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)
dict = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true)
GATK4_FILTERMUTECTCALLS ( input, fasta, fastaidx, dict )
}
workflow test_gatk4_filtermutectcalls_with_files {
input = [
[ id:'test'], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_vcf_gz'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_vcf_gz_tbi'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_vcf_gz_stats'], checkIfExists: true),
[ file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_artifact_prior_tar_gz'], checkIfExists: true) ],
[ file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_segmentation_table'], checkIfExists: true) ],
[ file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_contamination_table'], checkIfExists: true) ],
[]
]
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
fastaidx = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)
dict = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true)
GATK4_FILTERMUTECTCALLS ( input, fasta, fastaidx, dict )
}
workflow test_gatk4_filtermutectcalls_use_val {
input = [
[ id:'test'], // meta map
file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_vcf_gz'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_vcf_gz_tbi'], checkIfExists: true),
file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_vcf_gz_stats'], checkIfExists: true),
[ file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_mutect2_calls_artifact_prior_tar_gz'], checkIfExists: true) ],
[ file(params.test_data['homo_sapiens']['illumina']['test_test2_paired_segmentation_table'], checkIfExists: true) ],
[],
'20.0'
]
fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
fastaidx = file(params.test_data['homo_sapiens']['genome']['genome_fasta_fai'], checkIfExists: true)
dict = file(params.test_data['homo_sapiens']['genome']['genome_dict'], checkIfExists: true)
GATK4_FILTERMUTECTCALLS ( input, fasta, fastaidx, dict )
}

View file

@ -0,0 +1,35 @@
- name: gatk4 filtermutectcalls test_gatk4_filtermutectcalls_base
command: nextflow run tests/modules/gatk4/filtermutectcalls -entry test_gatk4_filtermutectcalls_base -c tests/config/nextflow.config
tags:
- gatk4
- gatk4/filtermutectcalls
files:
- path: output/gatk4/test.filtered.vcf.gz
- path: output/gatk4/test.filtered.vcf.gz.filteringStats.tsv
md5sum: 98e1b87a52999eb8f429ef4a7877eb3f
- path: output/gatk4/test.filtered.vcf.gz.tbi
md5sum: d88d2b745c9226ddf284e3494db8b9d2
- name: gatk4 filtermutectcalls test_gatk4_filtermutectcalls_with_files
command: nextflow run tests/modules/gatk4/filtermutectcalls -entry test_gatk4_filtermutectcalls_with_files -c tests/config/nextflow.config
tags:
- gatk4
- gatk4/filtermutectcalls
files:
- path: output/gatk4/test.filtered.vcf.gz
- path: output/gatk4/test.filtered.vcf.gz.filteringStats.tsv
md5sum: 98e1b87a52999eb8f429ef4a7877eb3f
- path: output/gatk4/test.filtered.vcf.gz.tbi
md5sum: d88d2b745c9226ddf284e3494db8b9d2
- name: gatk4 filtermutectcalls test_gatk4_filtermutectcalls_use_val
command: nextflow run tests/modules/gatk4/filtermutectcalls -entry test_gatk4_filtermutectcalls_use_val -c tests/config/nextflow.config
tags:
- gatk4
- gatk4/filtermutectcalls
files:
- path: output/gatk4/test.filtered.vcf.gz
- path: output/gatk4/test.filtered.vcf.gz.filteringStats.tsv
md5sum: 98e1b87a52999eb8f429ef4a7877eb3f
- path: output/gatk4/test.filtered.vcf.gz.tbi
md5sum: d88d2b745c9226ddf284e3494db8b9d2