Extract the DP and AD from VCF file along with the chromosome postion and alteration
2
0
Entering edit mode
2.4 years ago

Hi, I would like to extract the DP and AD 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 DP AD

chr1 8004518 . A G 692.77 . 90 49,39

I can able to extract DP tag using bcftools but cant able to extract AD

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

VCF • 2.4k views
ADD COMMENT
2
Entering edit mode
2.4 years ago

use [] to loop over the genotypes

bcftools query -f '%CHROM %POS [ %AD %DP]\n' in.vcf
ADD COMMENT
0
Entering edit mode

Thank you, but I also tried with awk you can check it out

ADD REPLY
1
Entering edit mode
2.4 years ago

By using awk

paste <(grep -v "^#" input.vcf | cut -f-5) <(grep -v "^#" input.vcf | cut -f10-| cut -d ":" -f2,3) |sed 's/:/\t/g' | sed '1i chr\tstart\tend\tref\talt\tNormal_DP\tAltered_DP\tDP'| awk 'BEGIN{FS=OFS="\t"}{sub(/,/,"\t",$6);print}' > output.tsv

ADD COMMENT

Login before adding your answer.

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