From 1677b34514424a5f38716f42daaa862e698d2e35 Mon Sep 17 00:00:00 2001 From: Sebastian Schoenherr Date: Fri, 14 Jun 2024 14:38:16 +0200 Subject: [PATCH] Add phasing window (#16) * Add phasing window * Add phasing window to beagle * Simplify syntax * Fix typo * Remove characters in beagle call --- modules/local/imputation/minimac4.nf | 8 ++++---- modules/local/phasing/beagle.nf | 13 ++++++++----- modules/local/phasing/eagle.nf | 14 ++++++++------ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/local/imputation/minimac4.nf b/modules/local/imputation/minimac4.nf index bee938f..825d441 100644 --- a/modules/local/imputation/minimac4.nf +++ b/modules/local/imputation/minimac4.nf @@ -11,10 +11,10 @@ process MINIMAC4 { script: def map = minimac_map ? '--referenceEstimates --map ' + minimac_map : '' - def chunkfile_name = "${chunkfile}".replaceAll('.vcf.gz', '') - def chr_cleaned = "${chr}".startsWith('X.') ? 'X' : "${chr}" - def chr_mapped = "${params.refpanel.build}" == 'hg38' ? 'chr' + "${chr_cleaned}" : "${chr_cleaned}" - def isChrM = "${chr}" == 'MT' ? '--myChromosome ' + "${chr}" : '' + def chunkfile_name = chunkfile.toString().replaceAll('.vcf.gz', '') + def chr_cleaned = chr.startsWith('X.') ? 'X' : chr + def chr_mapped = (params.refpanel.build == 'hg38') ? 'chr' + chr_cleaned : chr_cleaned + def isChrM = (chr == 'MT') ? '--myChromosome ' + chr : '' """ minimac4 \ diff --git a/modules/local/phasing/beagle.nf b/modules/local/phasing/beagle.nf index 8dc6821..ba545a7 100644 --- a/modules/local/phasing/beagle.nf +++ b/modules/local/phasing/beagle.nf @@ -10,18 +10,21 @@ process BEAGLE { script: //define basename without ending (do not use simpleName due to X.*) - def chunkfile_name = "$chunkfile".replaceAll('.vcf.gz', '') + def chunkfile_name = chunkfile.toString().replaceAll('.vcf.gz', '') // replace X.nonPAR etc with X for phasing - def chr_cleaned = "${chr}".startsWith('X.') ? 'X' : "${chr}" - def chr_mapped = "${params.refpanel.build}" == 'hg38' ? 'chr' + "${chr_cleaned}" : "${chr_cleaned}" - + def chr_cleaned = chr.startsWith('X.') ? 'X' : chr + def chr_mapped = params.refpanel.build == 'hg38' ? 'chr' + chr_cleaned : chr_cleaned + def phasing_start = start.toLong() - params.phasing_window + phasing_start = phasing_start < 0 ? 1 : phasing_start + def phasing_end = end.toLong() + params.phasing_window + """ java -jar /usr/bin/beagle.18May20.d20.jar \ ref=${bcf} \ gt=${chunkfile} \ out=${chunkfile_name}.phased \ nthreads=${task.cpus} \ - chrom=${chr_mapped}:${start}-${end} \ + chrom=${chr_mapped}:${phasing_start}-${phasing_end} \ map=${map_beagle} \ impute=false """ diff --git a/modules/local/phasing/eagle.nf b/modules/local/phasing/eagle.nf index d8c6692..b3a197b 100644 --- a/modules/local/phasing/eagle.nf +++ b/modules/local/phasing/eagle.nf @@ -11,11 +11,13 @@ process EAGLE { script: //define basename without ending (do not use simpleName due to X.*) - def chunkfile_name = "$chunkfile".replaceAll('.vcf.gz', '') + def chunkfile_name = chunkfile.toString().replaceAll('.vcf.gz', '') // replace X.nonPAR etc with X for phasing - def chr_cleaned = "${chr}".startsWith('X.') ? 'X' : "${chr}" - def chr_mapped = "${params.refpanel.build}" == 'hg38' ? 'chr' + "${chr_cleaned}" : "${chr_cleaned}" - + def chr_cleaned = chr.startsWith('X.') ? 'X' : chr + def chr_mapped = params.refpanel.build == 'hg38' ? 'chr' + chr_cleaned : chr_cleaned + def phasing_start = start.toLong() - params.phasing_window + phasing_start = phasing_start < 0 ? 1 : phasing_start + def phasing_end = end.toLong() + params.phasing_window """ tabix $chunkfile eagle \ @@ -24,8 +26,8 @@ process EAGLE { --geneticMapFile ${map_eagle} \ --outPrefix ${chunkfile_name}.phased \ --chrom $chr_mapped \ - --bpStart $start \ - --bpEnd $end \ + --bpStart $phasing_start \ + --bpEnd $phasing_end \ --allowRefAltSwap \ --vcfOutFormat z \ --keepMissingPloidyX \