This is a test version of Biostars. For the public version, visit https://www.biostars.org.
VCF filtering with Allele Balance (AB) using FilterVcf (Picard)

Hello,

I am trying to use FilterVcf (Picard) to filter out variant with AB<0.2 and AB>0.75 on my GATK vcf file. I saw that on FilterVcf documentation only have --MIN_AB parameter. Therefore, I cannot exclude variants with AB>0.75. Is there another software that can do this or do an annotation of AB on GATK vcf (because now there no AB annotation in GATK vcf)?

allele-balance filtervcf picard gatk

3 answers

You can do that kind of operation with one-liners, they can be powerful when dealing with VCF files. See the example here) for MAF filtering on a homozygous species, you will need to adapt it for your own needs.

FilterVcf also has a scripting feature to filter variants.

Here is one that I have made for filtering CNV calls. You can modify the inner functions as you see fit. function accept() is mandatory.

function accept(vc) {

var qs = vc.getGenotype(0).getAnyAttribute("QS");
var cn = vc.getGenotype(0).getAnyAttribute("CN");
var np = vc.getGenotype(0).getAnyAttribute("NP");

switch (cn) {
    case 0:
        return qs >= Math.min(1000, Math.max(400, 10*np));
    case 1:
        return qs >= Math.min(1000, Math.max(100, 10*np));
    default:
        return qs >= Math.min(400, Math.max(50, 4*np));
    } 
} 
accept(variant);

Just add this to a file named yourfilter.js and give it as a parameter.

I think I got using bcftools.

Here is my command:

bcftools filter -i 'FMT/GT = "het" & FMT/DP>=20 & sum(FMT/AD[*:1]/FMT/DP)>.2 & sum(FMT/AD[*:1]/FMT/DP)<=.75 | GT="hom" & FMT/DP>=20' input.vcf.gz -Oz9 --threads 36 -o output.vcf.gz

Can anyone check if it is correct?

Log in to answer this question.