samtools / bcftools

This is the official development repository for BCFtools. See installation instructions and other documentation here http://samtools.github.io/bcftools/howtos/install.html
http://samtools.github.io/bcftools/
Other
680 stars 240 forks source link

bcftools annotate produce different result for vcf vs tab annotation file. #1334

Closed theodorc closed 4 years ago

theodorc commented 4 years ago

Hi

I'm using bcftools: Version: 1.9-290-gb224270 (using htslib 1.9-456-gc1c8c80) I'm wondering why after annotation, it seems like the second allele (CCCAG) is deleted from ALT column in the output vcf file when the annotation is a vcf file opposed to a tab file. Is this normal or am I missing something obvious?

zcat NA12878.vcf.gz |grep 11709052

1 11709052 rs4397658 C G,CCCAG 991.73 . AC=1,1;AF=0.500,0.500;AN=2;DB;DP=29;ExcessHet=3.0103;FS=0.000;MLEAC=1,1;MLEAF=0.500,0.500;MQ=60.00;QD=52.20;SOR=2.419 GT:AD:DP:GQ:PL 1/2:0,9,10:19:99:1029,447,392,312,0,349

zcat aaa.tab.vcf.gz |tail -n2

CHROM POS ID REF ALT QUAL FILTER INFO FORMAT

1 11709052 . C G 0 . TTT_AF=0.561151

bcftools annotate -a aaa.tab.vcf.gz -h header -c CHROM,POS,REF,ALT,INFO/TTT_AF --collapse both NA12878.vcf.gz |grep 11709052

1 11709052 rs4397658 C G 991.73 . AC=1,1;AF=0.5,0.5;AN=2;DB;DP=29;ExcessHet=3.0103;FS=0;MLEAC=1,1;MLEAF=0.5,0.5;MQ=60;QD=52.2;SOR=2.419;TTT_AF=0.561151 GT:AD:DP:GQ:PL 1/2:0,9,10:19:99:1029,447,392,312,0,349

bcftools annotate -a aaa.tab.gz -h header -c CHROM,POS,REF,ALT,INFO/TTT_AF NA12878.vcf.gz |grep 11709052

1 11709052 rs4397658 C G,CCCAG 991.73 . AC=1,1;AF=0.5,0.5;AN=2;DB;DP=29;ExcessHet=3.0103;FS=0;MLEAC=1,1;MLEAF=0.5,0.5;MQ=60;QD=52.2;SOR=2.419;TTT_AF=0.561151 GT:AD:DP:GQ:PL 1/2:0,9,10:19:99:1029,447,392,312,0,349

theodorc commented 4 years ago

Correction to the command, without the --collapse flag:

bcftools annotate -a aaa.tab.vcf.gz -h header -c CHROM,POS,REF,ALT,INFO/TTT_AF NA12878.vcf.gz |grep 11709052

pd3 commented 4 years ago

Can you try with the latest version please? 1.9 is rather old.

theodorc commented 4 years ago

I have tried with 1.11. The result is the same.

theodorc commented 4 years ago

Installed the lastest. Version: 1.11-5-g9c15769 (using htslib 1.11-12-g90f27ab) I'm perplexed. Thank you for your time.

pd3 commented 4 years ago

When you are annotating from a VCF file (as opposed from a tab-delimited file), the format is clear and all columns specified via -c are transferred, including ALT in your case. The command should have just -c INFO/TTT_AF. When -a is a tab-delimited file, the situation is different, the -c CHROM,POS, and optionally REF,ALT, are to tell the program which of the columns should be used to match the records in the two files. This works for me:

bcftools annotate -c INFO/TTT_AF -a annot.vcf.gz test.vcf.gz

Does this help?