bcftools view filter exclude not working when using logical operators
I am trying to filter a vcf to exclude variants where the INFO values R2<0.9 AND MAF<0.1 with bcftools 1.9
This appears to filter R2 correctly:
bcftools view -e 'R2<0.9' my_fav.vcf.gz
This appears to filter MAF correctly:
bcftools view -e 'MAF<0.1' my_fav.vcf.gz
This still seems to include some variants where MAF or R2 do not satisfy my conditions:
bcftools view -e 'MAF<0.1 & R2<0.9' my_fav.vcf.gz
Actually this looks like it might be giving me results with MAF<0.1 OR R2<0.9
How do I filter MAF AND R2?
• 1,455 views
•
link
0 answers
No answers yet.
Log in to answer this question.
Hello curious ,
could you please add an example of your vcf including the header an some variant lines?
fin swimmer
nevermind I just answered my own question, I was using the wrong operator for what I wanted.
It would be good if you add your solution and a short explanation to the answer box so others with the same issue can benefit in the future.
IT was actually just a really embarrassing case where I was tired and for some reason thought & should be giving me what | should give me. There was no logic that anyone else could benefit from just human fatigue :)
I think, & and && have different meanings, see this filtering tutorial.
Solved by OP, therefore closed.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!