How to extract entire info column from VCF file using bcftools
1
0
Entering edit mode
5.6 years ago
Tails ▴ 80

I want to extract the whole info column, and the documentation indicates that %INFO should extract the whole info column.

https://samtools.github.io/bcftools/bcftools.html#query

I've tried the following:

bcftools query -f '%CHROM\t%POS\t%REF\t%ALT\t%INFO[\t%SAMPLE=%AD]\n' file.vcf

But I get an error saying it cannot parse format string.

The reason I want the whole info column is that there are about 20 different fields there and I don't want to extract them one by one.

bcftools software error SNP • 5.2k views
ADD COMMENT
0
Entering edit mode
5.6 years ago

Hello,

unfortunately this is not possible. See here: https://github.com/samtools/bcftools/issues/637

If you have a good reason why you need it and cut isn't enough, please leave a comment in this issue. Maybe it will be implemented.

fin swimmer

ADD COMMENT
0
Entering edit mode

Indeed, and, with cut or awk, you can still merge these via paste to output of bcftools query, which is still very useful to use to extract tag information that is embedded in INFO or FORMAT:

paste \
  <(bcftools view test.bcf | \
    awk '!/^#/ {print $1":"$2":"$4":"$5}') \
  <(bcftools query --samples 2610,2661,6313,6318 -f '%CHROM\t%POS\t%REF\t%ALT\t%DP\t[%AD\t]\n' test.bcf) \
  | head -10
1:65797:T:C 1   65797   T   C   5012    .   .   .   .   
1:65841:T:G 1   65841   T   G   3234    .   .   .   .   
1:65851:C:T 1   65851   C   T   3271    .   .   .   .   
1:65872:T:G 1   65872   T   G   32370   236,39  .   .   205,47  
1:65918:C:T 1   65918   C   T   8629    .   .   .   232,0   
1:65974:A:G 1   65974   A   G   7623    .   .   .   .   
1:65999:G:C 1   65999   G   C   1767    .   .   .   .   
1:66162:A:T 1   66162   A   T   805 1,1 3,1 .   1,2 
1:69270:A:G 1   69270   A   G   1064    .   .   .   .   
1:69428:T:G 1   69428   T   G   870 .   .   .   .
ADD REPLY

Login before adding your answer.

Traffic: 1677 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