How to create ID field in vcf with vcftools
1
0
Entering edit mode
9.6 years ago
gen • 0

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 consulted many documentations but no one can answer it.

Thanks in advance

software-error • 5.5k views
ADD COMMENT
0
Entering edit mode
9.6 years ago

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 > my.out.tab

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

ADD COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

Great, thanks Jorge!

ADD REPLY

Login before adding your answer.

Traffic: 1617 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6