This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Convert a VCF-file in a user specific Format

Hello everyone,

I am curious if it is possible to convert a VCF-File (with multiple samples) in a Format whith 5 columns.

  1. Column should be Sample ID
  2. Column: Position on the chromosome
  3. Genotyp
  4. Number of reads covering site
  5. QUAL phred-scaled quality score for the assertion made in ALT.

May there is allready a tool which can perform this, or if I need to do it myself may you can recommend me a good programm (like awk or sed) and recommend me a code.

Aim of this should be that afterwards i can filter variants via Quality score and number of reads covering site.

Thanks a lot in advance

vcf

Can you post a few (2-3 lines of your .vcf + all of the header?). I can give you a solution then.

Thank you very much Jorges answer was allready very helpful

1 answer

That's precisely what bcftools query was designed for. You just have to build your desired output format using the existing VCF variables. I'm guessing from your query that this command should be helpful:

bcftools query -f '[%SAMPLE\t%POS\t%GT\t%DP\t%QUAL\n]' file.vcf.gz

This is absolutely what bcftools query was designed for. Thank you very much, it helps a lot:)

Log in to answer this question.