This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract the DP from VCF file along with the chromosome postion and alteration

Hi, I would like to extract the DP from my VCF file, along with the chromosome position and alteration

Example VCF file

CHROM POS ID REF ALT QUAL FILTER INFO FORMAT SRRS1

chr1 8004518 . A G 692.77 . AC=1;AF=0.500;AN=2;BaseQRankSum=-1.550;ClippingRankSum=0.000;DP=90;ExcessHet=3.0103;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=60.00;MQRankSum=0.000;QD=7.87;ReadPosRankSum=0.521;SOR=0.703 GT:AD:DP:GQ:PL 0/1:49,39:88:99:721,0,1038

Desired Output

CHROM POS ID REF ALT QUAL FILTER INFO

chr1 8004518 . A G 692.77 . 90

dp vcf

use the following command

bcftools query -f '%CHROM %POS %REF %ALT %DP\n' You.vcf > output.tsv

2 answers

use bcftools query

bcftools query -f '%CHROM %POS %REF %ALT %DP\n' You.vcf > output.tsv

paste <(grep -v "^#" YourVCF | cut -f-5) <(grep -v "^#" YourVCF | cut -f10-| cut -d ":" -f3) | sed '1i chr\tstart\tend\tref\talt\tDP' > output

Log in to answer this question.