Skip to content

Commit

Permalink
add gatherbqsrreports
Browse files Browse the repository at this point in the history
  • Loading branch information
maxulysse committed Jul 25, 2020
1 parent 496b745 commit 6f3c37f
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
36 changes: 31 additions & 5 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,10 @@ include { BUILD_INDICES } from './modules/local/subworkflow/build_indices'
================================================================================
*/

include { GATK_MARKDUPLICATES as MARKDUPLICATES } from './modules/nf-core/software/gatk_markduplicates'
include { GATK_BASERECALIBRATOR as BASERECALIBRATOR } from './modules/nf-core/software/gatk_baserecalibrator'
include { MULTIQC } from './modules/nf-core/software/multiqc'
include { GATK_BASERECALIBRATOR as BASERECALIBRATOR } from './modules/nf-core/software/gatk_baserecalibrator'
include { GATK_GATHERBQSRREPORTS as GATHERBQSRREPORTS } from './modules/nf-core/software/gatk_gatherbqsrreports'
include { GATK_MARKDUPLICATES as MARKDUPLICATES } from './modules/nf-core/software/gatk_markduplicates'
include { MULTIQC } from './modules/nf-core/software/multiqc'

/*
================================================================================
Expand Down Expand Up @@ -368,7 +369,7 @@ workflow {

BWAMEM2_MEM(QC_TRIM.out.reads, bwa, fasta, fai, params.modules['bwamem2_mem'])

results = BWAMEM2_MEM.out.map{ meta, bam, bai ->
BWAMEM2_MEM.out.map{ meta, bam, bai ->
patient = meta.patient
sample = meta.sample
gender = meta.gender
Expand All @@ -378,7 +379,7 @@ workflow {
.branch{
single: it[4].size() == 1
multiple: it[4].size() > 1
}.set { bam }
}.set{ bam }

bam_single = bam.single.map {
patient, sample, gender, status, bam, bai ->
Expand Down Expand Up @@ -423,6 +424,31 @@ workflow {

BASERECALIBRATOR(bam_baserecalibrator, dbsnp, dbsnp_tbi, dict, fai, fasta, known_indels, known_indels_tbi)

if (!params.no_intervals) {
BASERECALIBRATOR.out.report.map{ meta, table ->
patient = meta.patient
sample = meta.sample
gender = meta.gender
status = meta.status
[patient, sample, gender, status, table]
}.groupTuple(by: [0,1]).set{ recaltable }

recaltable = recaltable.map {
patient, sample, gender, status, recal ->

def meta = [:]
meta.patient = patient
meta.sample = sample
meta.gender = gender[0]
meta.status = status[0]
meta.id = sample

[meta, recal]
}

GATHERBQSRREPORTS(recaltable)
}

OUTPUT_DOCUMENTATION(
output_docs,
output_docs_images)
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-core/software/gatk_baserecalibrator.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ process GATK_BASERECALIBRATOR {

output:
tuple val(meta), path("${prefix}${meta.sample}.recal.table"), emit: report
val meta, emit: tsv
val meta, emit: tsv

//when: params.known_indels

Expand Down
28 changes: 28 additions & 0 deletions modules/nf-core/software/gatk_gatherbqsrreports.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
process GATK_GATHERBQSRREPORTS {
label 'memory_singleCPU_2_task'
label 'cpus_2'
tag "${meta.id}"

publishDir params.outdir, mode: params.publish_dir_mode,
saveAs: {
if (it == "${meta.sample}.recal.table" && !params.skip_markduplicates) "Preprocessing/${meta.sample}/DuplicatesMarked/${it}"
else "Preprocessing/${meta.sample}/Mapped/${it}"
}

input:
tuple val(meta), path(recal)

output:
tuple val(meta), path("${meta.sample}.recal.table"), emit: table
path "${meta.sample}.recal.table", emit: report
val meta, emit: tsv

script:
input = recal.collect{"-I ${it}"}.join(' ')
"""
gatk --java-options -Xmx${task.memory.toGiga()}g \
GatherBQSRReports \
${input} \
-O ${meta.sample}.recal.table \
"""
}

0 comments on commit 6f3c37f

Please sign in to comment.