Skip to content

Commit

Permalink
Add phasing window (#16)
Browse files Browse the repository at this point in the history
* Add phasing window

* Add phasing window to beagle

* Simplify syntax

* Fix typo

* Remove characters in beagle call
  • Loading branch information
seppinho authored Jun 14, 2024
1 parent 172116a commit 1677b34
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
8 changes: 4 additions & 4 deletions modules/local/imputation/minimac4.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
13 changes: 8 additions & 5 deletions modules/local/phasing/beagle.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
14 changes: 8 additions & 6 deletions modules/local/phasing/eagle.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand Down

0 comments on commit 1677b34

Please sign in to comment.