Filter cols from python list

Hi all! I have a python list containing sample IDs, and I am trying to filter the columns of my mt with this:

mt = mt.filter_cols(mt.s in id_list)

However, this does not work. Can I get some advice on how to do that? Thank you!

hl.set(id_list).contains(mt.s) should work.

The problem is that mt.s is a hail expression, and id_list is a python list of strings, which certainly does not contain mt.s or any other hail expression. The above turns the python list into a hail set, which can then be queried for mt.s during the execution of the pipeline.

1 Like