OK I will give it a try and let you know. Thank you.
Hello,
I have a VCF file containing SNP data from 100 individuals. I followed the GATK best practices with necessary filtering options. I want to perform another filtration based on Allele-balance. So, I used the following code for doing that:
bcftools view -i 'AB > 0.25 && AB < 0.75 | AB < 0.01' only_SNPs_filter_removed_maxmiss_0.5.recode_dustmasked_header.vcf > AB.vcf
But it throws an error message stating that the AB tag is not found in the VCF header. I think unless specified, GATK does not produce that in the output VCF file. I also used Vcflib to do so but there I received another error message stating
cannot compare (>) objects of dissimilar types
3 4
Can you please suggest how to perform that AB filtering on my current VCF file? Thank you.
1 answer
Have you tried to run some manual awk? Something like this could work:
awk -F'\t' '{if ( $1 ~ /^#/ ){print}else{split($8,l1,";");split(l1[1],l2,"="); ab=l2[2];if (ab<0.01){print}; if (ab>0.25 && ab<0.75){print}}}' INPUT_FILE
This one liner assumes that the AB field in INFO column is the first field. Modify the l1[1] part (to l1[2], l1[3] ... etc), if AB field is not the first one.
Log in to answer this question.
what INFO and FORMAT are present in your VCF ?
Here are the INFO in the VCF header
Have you tried
vcffilter?Also, if the issue is that the AB header is missing in the VCF, maybe you could add it manually yourself and see if it works?
Yes, I tried VCFfilter and then I got the above error. I posted it.
Hi, I manually added the AB header in the VCF file and then the
vcffilterran successfully. But using the above parameters the number of SNPs did not change after filtering for AB.