bcftools view changes GT format field value when it is declared as Type=Integer
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- c
- Domain
- bioinformatics
Research direction
Start by reproducing the behavior with the attached gt_integer_missing.vcf.gz and test2.vcf.gz using bcftools view. Trace how incorrectly declared Integer GT fields are decoded and written; done means missing, 0, 1, 2, and 3 values are preserved as expected instead of being changed.
Written by the indexing model from the issue text.
Description
When the GT format field is incorrectly declared as Type=Integer, bcftools view changes the GT value.
Yes, Integer as the type for the GT format field is clearly wrong, but the behavior is surprising.
Input:
gt_integer_missing.vcf.gz
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##INFO=<ID=END,Number=1,Type=Integer,Description="End coordinate of the variant">
##FORMAT=<ID=GT,Number=1,Type=Integer,Description="Genotype">
##FORMAT=<ID=CN,Number=1,Type=Integer,Description="Copy number maximum a posteriori value">
##contig=<ID=Y>
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT sample
Y 21154053 . N <DUP> . . END=21154895 GT:CN .:.
Command:
bcftools view gt_integer_missing.vcf
Actual output:
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##INFO=<ID=END,Number=1,Type=Integer,Description="End coordinate of the variant">
##FORMAT=<ID=GT,Number=1,Type=Integer,Description="Genotype">
##FORMAT=<ID=CN,Number=1,Type=Integer,Description="Copy number maximum a posteriori value">
##contig=<ID=Y>
##bcftools_viewVersion=1.22+htslib-1.22
##bcftools_viewCommand=view gt_integer_missing.vcf; Date=Thu Jul 3 18:56:39 2025
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT sample
Y 21154053 . N <DUP> . . END=21154895 GT:CN -65:.
GT value -65 in the output.
Expected output:
I would have expected it to keep the genotype as ., not changing it, even if the type is incorrect.
Version:
$ bcftools --version
bcftools 1.22
Using htslib 1.22
Copyright (C) 2025 Genome Research Ltd.
License Expat: The MIT/Expat license
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Additional information:
It also appears to change GT=0 or GT=1 to GT=. and GT=2 or GT=3 to GT=0. This seems more insidious as the more subtle change will be harder to spot. (The negative value outputted causing problems downstream was the reason why I noticed this in the first place.)
$ cat test2.vcf
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##FORMAT=<ID=GT,Number=1,Type=Integer,Description="Genotype">
##contig=<ID=Y>
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT test2
Y 21154053 missing T A,C,G . PASS . GT .
Y 21154053 ref T A,C,G . PASS . GT 0
Y 21154053 alt1 T A,C,G . PASS . GT 1
Y 21154053 alt2 T A,C,G . PASS . GT 2
Y 21154053 alt3 T A,C,G . PASS . GT 3
$ bcftools view test2.vcf
##fileformat=VCFv4.2
##FILTER=<ID=PASS,Description="All filters passed">
##FORMAT=<ID=GT,Number=1,Type=Integer,Description="Genotype">
##contig=<ID=Y>
##bcftools_viewVersion=1.22+htslib-1.22
##bcftools_viewCommand=view test2.vcf; Date=Thu Jul 3 21:00:24 2025
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT test2
Y 21154053 missing T A,C,G . PASS . GT -65
Y 21154053 ref T A,C,G . PASS . GT .
Y 21154053 alt1 T A,C,G . PASS . GT .
Y 21154053 alt2 T A,C,G . PASS . GT 0
Y 21154053 alt3 T A,C,G . PASS . GT 0
- Dominant language
- C
- Stars
- 891
- Forks
- 277
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from samtools/bcftools
-
needs-feedback
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 45/100
-
htslib-dependent P2: Desirable
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
-
needs-feedback requires-test-case
Difficulty 3/5 1-2 days Newbie friendliness 55/100
All issues in samtools/bcftools
Similar issues
-
[adam] AdamNet network read doesn't cap to MAX_ADAM_PACKET_LEN, overflows client receive buffers Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
FujiNetWIFI/fujinet-firmware#1649 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
HarbourMasters/Shipwright#7229 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
riscv-software-src/riscv-isa-sim#2435 · 1 comment ·
-
bug Self Built Image SNAPSHOT Supported Device target/ramips
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100