Pulling out "alts" from a multisample vcf by sample ID - bcftools syntax question
1
1
Entering edit mode
2.6 years ago
tacrolimus ▴ 140

Dear Biostars,

I have a multisample vcf. I would like a to turn this into a per sample "alts" file as below.

The desired outcome would be :

chr10:12342:A:T  SAMPLEID1:0/1 SAMPLEID2:1/1 ...
chr10:432234:G:C SAMPLEID4:0/1 SAMPLEID7:1/1 ...

I have tried :

bcftools query -f "%CHROM:%POS:%REF:%ALT\n[%SAMPLE:%GT\t]'  i- 'GT="alt"' input.vcf 

which gives me:

chr10:12342:A:T  SAMPLEID1:0/1 SAMPLEID2:1/1 chr10:432234:G:C 
SAMPLEID4:0/1 SAMPLEID7:1/1 ...

or

 bcftools query -f "%CHROM:%POS:%REF:%ALT\t[%SAMPLE:%GT\n']  i- 'GT="alt"' input.vcf 


chr10:12342:A:T  SAMPLEID1:0/1 
SAMPLEID2:1/1 
chr10:432234:G:C SAMPLEID4:0/1 
SAMPLEID7:1/1 

or

  bcftools query -f "%CHROM:%POS:%REF:%ALT\t[%SAMPLE:%GT\t']  i- 'GT="alt"' input.vcf 

  chr10:12342:A:T  SAMPLEID1:0/1 SAMPLEID2:1/1 chr10:432234:G:C SAMPLEID4:0/1 SAMPLEID7:1/1 

I can't quite get my head around the correct syntax and sure there is an easy fix! Your help would be much appreciated.

All the best

bcftools vcf • 627 views
ADD COMMENT
3
Entering edit mode
2.6 years ago
tacrolimus ▴ 140

Figured it out!

bcftools query -f "%CHROM:%POS:%REF:%ALT[\t%SAMPLE:%GT]\n'  i- 'GT="alt"' input.vcf 

Just needed to move the \n out of the square brackets!

ADD COMMENT

Login before adding your answer.

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