Question: How to create ID field in vcf with vcftools
gravatar for gen
5.4 years ago by
gen0 wrote:

vcftools is really good at extracting some information from vcf files.

However, I have some missing information in the output file when I try this: 

vcftools --vcf my.vcf --get-INFO AF --out my.out.vcf

my.out should keep "ID" field (rsID) as in the original my.vcf, but it doesn't.


Is there any vcftools option or other ways to keep ID in the result vcf?

I've cosulted many documentations but no one can answer it.


Thanks in advance.






software error • 3.7k views
ADD COMMENTlink modified 5.3 years ago by Biostar ♦♦ 20 • written 5.4 years ago by gen0
gravatar for Jorge Amigo
5.4 years ago by
Jorge Amigo12k
Santiago de Compostela, Spain
Jorge Amigo12k wrote:

the --get-INFO option from vcftools generates a tabulated file with the mandatory columns (CHROM, POS, REF, ALT) plus the variable of the INFO column that you require. unfortunately the ID is not usually contained in the INFO column, so extracting it would have to be done manually by scripting or programming an ad hoc solution.

but the best way to my knowledge to get the desired output from a vcf file is through bcftools query:

bcftools query -f '%CHROM\t%POS\t%ID\t%REF\t%ALT\t%INFO/AF\n' my.vcf >

it still generates a tabulated file, but it contains all the columns you seem to be interested in.

ADD COMMENTlink modified 5.4 years ago • written 5.4 years ago by Jorge Amigo12k

Hi Jorge,

I am having the same problem at the moment and have tried your solution but for some reason I was unable to open the output file from the bcftools. It just came up empty. Any ideas as to why this may be so? Thanks in advance.

ADD REPLYlink written 4.1 years ago by noor.suaini0

the output can only be empty if the input file or the command is wrong. check that there aren't any errors in the command line (such as "no such tag defined" or "fail to open file"), and that the input file is a valid vcf file.

ADD REPLYlink written 4.1 years ago by Jorge Amigo12k

Great, thanks Jorge!

ADD REPLYlink written 4.1 years ago by noor.suaini0
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 986 users visited in the last hour