How to filter to PASS variants from VCFs

We slightly changed the way this worked a few months ago, and we neither made a discourse post (naughty!) nor changed the docs (unforgivable!).

When a VCF is imported with Hail, the FILTER field is read into va.filters, which is of type Set[String]. This needs to be a set because a variant can have multiple filters applied. PASS means that no filters were applied, and produces an empty set in va.filters. The best way to filter to PASS variants is:

pass_vds = vds.filter_variants_expr('va.filters.isEmpty()', keep=True)

Hi, I am using 0.2 version of hail and above line gives me the following error

MatrixTable instance has no field, method, or property 'filter_variants_expr

I am wondering if there is a way to do this in 0.2 version.

Thanks in advance.

Hi Monica,
This post is for 0.1, not 0.2. Sorry! We may need a better system going forward for marking posts with the version. We have things better categorized on Zulip.

Take a look at the import_vcf docs for an example of how to do exactly this!

thanks a lot. That works perfectly :slight_smile: