This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bcftools filter applied to specific sample column

Hello, I'd like to filter for sites that have a DP>5 in my normal sample and DP>10 in the tumor. My vcf has two samples columns, TUMOR NORMAL. How do I do that with a bcftools expression? I see in the documentation how to apply the filter for one or all samples in a vcf row but I couldn't find a way to specify the sample name. Thanks a lot.

bcftools filter view

3 answers

Actually bcftools supports this also. This worked for me:

bcftools filter -s MY_FILTER -m + -e "FMT/DP[0] <= 5 || FMT/DP[1] <= 10" my.vcf

which appends MY_FILTER based on the exclusion criteria

Hava a look at SnpSift filter.

With SnpSift you can build any expression that evaluates to TRUE / FALSE using the attributes of the variant and or the attributes of one or more specific samples.

http://snpeff.sourceforge.net/SnpSift.html#filter

cat my.vcf | java -jar SnpSift.jar filter "GEN[0].DP > 5 && GEN[1].DP > 10"

thanks that worked brilliantly!

not using bcftools but picard http://broadinstitute.github.io/picard/command-line-overview.html and FilterVcf with a javascript file or vcffilterjs https://github.com/lindenb/jvarkit/wiki/VCFFilterJS

variant.getGenotype("NORMAL").getDP() > 5 && variant.getGenotype("TUMOR").getDP() > 10

Log in to answer this question.