Question: How to extract entire info column from VCF file using bcftools
0
gravatar for Tails
22 months ago by
Tails60
New Zealand
Tails60 wrote:

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.

snp bcftools software error • 1.9k views
ADD COMMENTlink modified 22 months ago by finswimmer14k • written 22 months ago by Tails60
0
gravatar for finswimmer
22 months ago by
finswimmer14k
Germany
finswimmer14k wrote:

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 COMMENTlink written 22 months ago by finswimmer14k

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 REPLYlink written 22 months ago by Kevin Blighe71k
Please log in to add an answer.

Help
Access

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