How to filter to a specific locus

I wanted to filter based on a locus; however it is giving me an error.

data = mt.filter_rows((mt.locus == 1:139120)),keep=True)

I have tried several permutations of the above; the error persists

type errors, probably.

try:

filter_rows(mt.locus == hl.locus('1', 139120))

3 posts were split to a new topic: How do I filter to a one megabase range of a matrix table

Hi,

What is the best way to filter for multiple locations? For example python list of 1000 <LocusExpression of type locus<GRCh37>>. How should I pass it to the .mt to filter most efficiently?

Thanks.

I created snps_locuses - a list of 1000 <LocusExpression of type locus<GRCh37>>

The solution that worked for me:
mt = mt.filter_rows(hl.literal(snps_locuses).contains(mt.locus))

Thanks.

1 Like