Filter samples from MatrixTable


i want to filter from MatrixTable only individuals(samples) of interest
I found in previous post:

mt.filter_rows(mt.s == ‘NA00001’)

which works for single sample, but how can I filter it if I have a list of samples such as:

samples = [‘NA00001’, ‘NA00002’]


1 Like

I’m doing exactly this solution and I’m getting this error:
TypeError: array: parameter ‘collection’: expected expression of type set or array or dict<(‘any’, ‘any’)>, found

This is my code:
samples = table[‘target panel prefix’]
mt = mt.filter_cols(hl.array(samples).contains(mt.s))

What can be the reason?

samples here isn’t a python list, it’s a table field. If you do:

samples = table['target panel prefix'].collect()

This should work, I think

Thank you so much, it worked!