Fill a VCF record field that is partially annotated
1
0
Entering edit mode
5.9 years ago

I have a VCF like:

chr1    65310489    .   T   C   3483.8  PASS AF=0.476857;AO=441;DP=931;FAO=443;FDP=929;FDVR=5 [...] AF_gnomAD=0.353 [...]

chr1    65310518    .  A    T 96.8  PASS AF=0.00107066;AO=1;DP=934;FAO=1;FDP=934;FDVR=10 [...]

...

Where I added an extra field with the AF using the gnomAD database and vcfanno (https://github.com/brentp/vcfanno). This package adds the AF of the coincident coordinates to the vcf but it does not include any field into the ones that do not appear in gnomAD (I know some of this variant will be false positives in the postprocessing).

I would like to add a field in the records that are not annotated something like "AF_gnomAD=0" (or a very low number).

Any suggestions? Thanks!

vcf SNP vcfanno gnomAD • 1.3k views
ADD COMMENT
1
Entering edit mode
5.9 years ago

assuming there is only one ALT allele:

awk -F '\t' '/^#/ {print; next} ($8 ~ /AF_gnomAD=/) {print;next;} {OFS="\t"; $8=sprintf("%s;AF_gnomAD=0",$8);print;}' input.vcf
ADD COMMENT
0
Entering edit mode

It works great! Thanks! Also, if there is more than one ALT allele and they are separated with commas (,) there is no problem with this command :)

ADD REPLY
0
Entering edit mode

Also, if there is more than one ALT allele and they are separated with commas (,) there is no problem with this command

yes but an AF tag should have the same number of values than the number of ALT alleles (one frequency for each allele)

ADD REPLY

Login before adding your answer.

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