bcftools norm -m +snps doesn't combine INFO fields when combining identical SNPs

Open
#362 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
c

Research direction

Start with the bcftools norm -m +snps handling described in the issue and reproduce the behavior using tiny.vcf. The change is done when identical SNP records combine their INFO values as requested, including summed AC and AF, while the different-allele example continues to produce comma-separated values.

Written by the indexing model from the issue text.

Description

enhancement

Below is a tiny vcf file containing two data records, each describing the same SNP. When I run bcftools norm -m +snps on it, it properly outputs only one data record, but it doesn't combine the INFO fields-- it just takes the INFO field from the second data record.

$ cat tiny.vcf
##fileformat=VCFv4.1
##FILTER=<ID=PASS,Description="All filters passed">
##contig=<ID=1,URL=ftp://somewhere.org/assembly.fa>
##INFO=<ID=AF,Number=A,Type=Float,Description="Allele Frequency">
##INFO=<ID=AC,Number=A,Type=Integer,Description="Allele Count">
##INFO=<ID=AN,Number=1,Type=Integer,Description="Total number of alleles in data sources">
##INFO=<ID=END,Number=.,Type=Integer,Description="End position">
##INFO=<ID=DS,Number=A,Type=String,Description="Data Sources containing allele">
##INFO=<ID=OLD_MULTIALLELIC,Number=1,Type=String,Description="Original chr:pos:ref:alt encoding">
##INFO=<ID=OLD_VARIANT,Number=.,Type=String,Description="Original chr:pos:ref:alt encoding">
#CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO
1       10440   .       C       A       .       .       AF=0.0002305;AC=6;AN=26028
1       10440   .       C       A       .       .       AF=0.0001153;AC=3;AN=26028

$ bcftools norm -m+snps tiny.vcf  #header info omitted
1       10440   .       C       A       .       .       AF=0.0001153;AC=3;AN=26028

bcftools norm -m +snps does combine INFO fields when combining two different SNP alleles at the same position--it combines the AC and AF values by separating them with commas (see below).

$ cat tiny2.vcf #header info same as above; omitted
1       10440   .       C       A       .       .       AF=0.0002305;AC=6;AN=26028
1       10440   .       C       T       .       .       AF=0.0001153;AC=3;AN=26028

$  bcftools norm -m+snps tiny2.vcf
1       10440   .       C       A,T     .       .       AF=0.0002305,0.0001153;AC=6,3;AN=26028

I'd like it to also do the right thing when the two alleles are the same--I'd like it to sum the AC and AF values, producing the following for tiny.vcf:

1       10440   .       C       A       .       .       AF=0.0003458;AC=9;AN=26028

I am using this version of bcftools:

$ bcftools --version
bcftools 1.2-190-g71921ca
Using htslib 1.2.1-226-g1e5c377
Dominant language
C
Stars
891
Forks
277
Avg merge
2d 23h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from samtools/bcftools

All issues in samtools/bcftools

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.