I have a very large VCF file where the 'ID' column is a unique ID comprising of 'chr:bp'.  I would like to update the 'ID' column to dbSNP IDs.

I have downloaded a bed file [chr, from, to, rsid], which I have sorted and tabix indexed. The bedfile is for hg19, which is correct for my data, chromosomes are formatted with 'chr' and their is no header.

It seems that the BCFtools annotate function does allow 'ID' column to be updated, but I am not clear how. I have tried;

 i) `bcftools annotate -a dbsnp.bed.gz -c 'CHROM,POS,-,ID' my.vcf.gz` 

 ii) `bcftools annotate -a dbsnp.bed.gz -c 'CHROM,FROM,TO,ID' my.vcf.gz`

neither of which updated the ID column. I also tried removing the 'ID' first from the VCF `-R` , and piped the vcf into the two commands above. Perhaps this is not the right tool? Any advice appreciated.



   
    bcftools annotate -c CHROM,FROM,TO,ID -a my_ids.bed.gz   -o output.vcf  input.vcf.gz 

works fore me. 

It did also take me some time to get it to work and it is hard to debug were the mistake is:

Some things to try / check:

 1. VCF is 1 based, BED is zero based.  POS 10 in VCF is start 9 end 10 in BED. https://genome.ucsc.edu/FAQ/FAQformat#format1

 2. Make sure your chromosome names match exactly, Chr1 and chr_1 are not the same for bcftools.

 3. Remove the quotes around the column list  'CHROM,FROM,TO,ID' -> CHROM,FROM,TO,ID

 4. Test with a very small subset of your VCF and BED file that should produce an annotated VCF file. This makes it faster to debug and test different options / formattings until you get it right. 

