Skip to content

Commit ede591a

Browse files
committed
Add bcf format for results
1 parent 8092031 commit ede591a

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

modules/local/compression/compression_encryption_vcf.nf

+11-9
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,31 @@ process COMPRESSION_ENCRYPTION_VCF {
1919
def meta_joined = ArrayUtil.sort(imputed_meta_vcf_data)
2020
def info_joined = ArrayUtil.sort(imputed_info)
2121
def prefix = "chr${chr}"
22-
def imputed_name = "${prefix}.dose.vcf.gz"
23-
def meta_name = "${prefix}.empiricalDose.vcf.gz"
22+
def minimac4_format = params.imputation.format
23+
def bcftools_output = minimac4_format == 'bcf' ? "b" : "z"
24+
def imputed_name = "${prefix}.dose.$minimac4_format"
25+
def meta_name = "${prefix}.empiricalDose.$minimac4_format"
2426
def zip_name = "chr_${chr}.zip"
25-
def info_name = "${prefix}.info.gz"
27+
def info_name = "${prefix}.info.$minimac4_format"
2628
def aes = params.encryption.aes ? "-mem=AES256" : ""
2729
def panel_version = params.refpanel.id
28-
30+
2931
"""
3032
# concat info files
31-
bcftools concat --threads ${task.cpus} -n ${info_joined} -o ${info_name} -Oz
33+
bcftools concat --threads ${task.cpus} -n ${info_joined} -o ${info_name} -O$bcftools_output
3234
3335
# concat dosage files and update header
34-
bcftools concat --threads ${task.cpus} -n ${imputed_joined} -o intermediate_${imputed_name} -Oz
36+
bcftools concat --threads ${task.cpus} -n ${imputed_joined} -o intermediate_${imputed_name} -O$bcftools_output
3537
echo "##mis_pipeline=${workflow.manifest.version}" > add_header.txt
3638
echo "##mis_phasing=${params.phasing.engine}" >> add_header.txt
3739
echo "##mis_panel=${panel_version}" >> add_header.txt
38-
bcftools annotate --threads ${task.cpus} -h add_header.txt intermediate_${imputed_name} -o ${imputed_name} -Oz
40+
bcftools annotate --threads ${task.cpus} -h add_header.txt intermediate_${imputed_name} -o ${imputed_name} -O$bcftools_output
3941
rm intermediate_${imputed_name}
4042
4143
# write meta files
4244
if [[ "${params.imputation.meta}" = true ]]
4345
then
44-
bcftools concat --threads ${task.cpus} -n ${meta_joined} -o ${meta_name} -Oz
46+
bcftools concat --threads ${task.cpus} -n ${meta_joined} -o ${meta_name} -O$bcftools_output
4547
tabix ${meta_name}
4648
fi
4749
@@ -55,7 +57,7 @@ process COMPRESSION_ENCRYPTION_VCF {
5557
if [[ "${params.encryption.enabled}" = true ]]
5658
then
5759
7z a -tzip ${aes} -mmt${task.cpus} -p"${params.encryption_password}" ${zip_name} ${prefix}*
58-
rm *vcf.gz* *info.gz add_header.txt
60+
rm *$minimac4_format add_header.txt
5961
fi
6062
6163
# create md5 of zip file

modules/local/imputation/minimac4.nf

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ process MINIMAC4 {
1616
val probThresholdS1
1717
val minRecombination
1818
output:
19-
tuple val(chr), val(start), val(end), file("*.dose.vcf.gz"), file("*.info.gz"), file("*.empiricalDose.vcf.gz"), emit: imputed_chunks
19+
tuple val(chr), val(start), val(end), file("*.dose.*"), file("*.info.*"), file("*.empiricalDose.*"), emit: imputed_chunks
2020

2121
script:
2222
def map = minimac_map ? '--map ' + minimac_map : ''
@@ -29,20 +29,20 @@ process MINIMAC4 {
2929
def chr_cleaned = chr.startsWith('X.') ? 'X' : chr
3030
def chr_mapped = (refpanel_build == 'hg38') ? 'chr' + chr_cleaned : chr_cleaned
3131
def used_threads = params.service.threads != -1 ? params.service.threads : task.cpus
32-
32+
def minimac4_format = params.imputation.format
3333
"""
3434
tabix ${chunkfile}
3535
3636
minimac4 \
3737
--region $chr_mapped:$start-$end \
3838
--overlap $minimac_window \
39-
--output ${chunkfile_name}.dose.vcf.gz \
40-
--output-format vcf.gz \
39+
--output ${chunkfile_name}.dose.$minimac4_format \
40+
--output-format $minimac4_format \
4141
--format GT,DS,GP,HDS \
4242
--min-ratio $minimac_min_ratio \
4343
--all-typed-sites \
44-
--sites ${chunkfile_name}.info.gz \
45-
--empirical-output ${chunkfile_name}.empiricalDose.vcf.gz \
44+
--sites ${chunkfile_name}.info.$minimac4_format \
45+
--empirical-output ${chunkfile_name}.empiricalDose.$minimac4_format \
4646
--threads $used_threads \
4747
--decay $decay \
4848
--temp-prefix ./ \

nextflow.config

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ params {
4444
]
4545

4646
imputation = [
47+
format: 'vcf.gz',
4748
enabled: true,
4849
window: 500000,
4950
minimac_min_ratio: 0.00001,

0 commit comments

Comments
 (0)