This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to filter VCF with HRun > 8 and AB > 0.2 and AB < 0.2

Hello,

I have vcf files containing R8 and LowVariantFreq variants (they are flagged as PASS) and I would like to filter out these variants. I have tried without sucess vcftools... Do you have any suggestion on how to proceed ?

Thank you very much !

vcf filtering

Hello,

have you tried searching the web by How to filter VCF? What problems have you faced?

fin swimmer

Thank you for your reply.
I apologize in advance but I only have basic knowledges in bioinformatics. So I might do some strange things...
I have tried the following command line.

for elt in mini/*indel.vcf ; do vcffilter -s -f "AB > 0.25 & AB < 0.75" $elt > {$elt%.vcf}_filtered.vcf  ; done

But no variant are excluded by this command.
Any suggestion ?
Henri

Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.
code_formatting

Hello again,

I cannot help you with vcftools. I would recommend to use bcftools instead. Have a look at bcftools filter and the descriptions of expressions.

fin swimmer

Hello again, I have made some progress to filter vcf based on allelic balance. I used the tools vcffilterjdk with the following command line :

java -jar vcffilterjdk.jar -e 'return variant.getGenotypes().stream().filter(G->G.hasAD()).map(G->G.getAD()).allMatch(A->A.length>1 && A[0]>0 && A[1]/(double)A[0]> 0.2);' input.vcf  > output.vcf

To filter R8 variant I flagged variants in the filter fields based with the tool vcfpolyx.jar :

java -jar /cfpolyx.jar -R /genome_ref/hg19.fa -n 8 -o output.vcf input.vcf

Now I have a vcf like this with the POLYX_ge_8 flag:

chr1    985443  .   AG  A   558.71  POLYX_ge_8;SB   BaseQRankSum=0.284;DP=68;FS=13.961;HRun=15;HaplotypeScore=332.152;MQ=60;MQ0=0;MQRankSum=-0.557;POLYX=15;QD=8.22;ReadPosRankSum=0.83;SB=0    GT:AD:DP:GQ:PL:MQ:GQX:VF    0/1:41,23:68:99:598,0,121:60:99:0.359

I would like now to use bcftools to filter my vcf based on this field but I am not successfull so far. My attempt :

bcftools filter -e 'POLYX_ge_8' input.vcf

I know the answer must be pretty simple but again I am a newbie...

Thanks !

Hi,

You can filter vcf based on AB tag using:

bcftools view -i 'AB>0.25 && AB < 0.75' input.vcf > out.vcf

0 answers

No answers yet.

Log in to answer this question.