# Filter all loci that are also included in another matrix table

**URL:** <https://discuss.hail.is/t/filter-all-loci-that-are-also-included-in-another-matrix-table/1303>\
**Category:** Hail Query & hailctl\
**Created:** [February 20, 2020, 5:52pm UTC](https://discuss.hail.is/t/filter-all-loci-that-are-also-included-in-another-matrix-table/1303 "2020-02-20T17:52:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![orr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/orr/32/846_2.png) [@orr](https://discuss.hail.is/u/orr)\
**Post date:** [February 20, 2020, 5:52pm UTC](https://discuss.hail.is/t/filter-all-loci-that-are-also-included-in-another-matrix-table/1303/1 "2020-02-20T17:52:55Z")

</div>

How can i filter all rows to only include loci that are also in another mt (or lis of loci)? I tried the intersect method, but with no success.

Thanks

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [February 20, 2020, 5:55pm UTC](https://discuss.hail.is/t/filter-all-loci-that-are-also-included-in-another-matrix-table/1303/2 "2020-02-20T17:55:22Z")

</div>

[semi\_join\_rows](https://hail.is/docs/0.2/hail.MatrixTable.html#hail.MatrixTable.semi_join_rows):

```auto
mt = mt.semi_join_rows(mt2.rows())

```

---

<div class="post-metadata">

**Author:** ![orr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/orr/32/846_2.png) [@orr](https://discuss.hail.is/u/orr)\
**Post date:** [February 20, 2020, 6:01pm UTC](https://discuss.hail.is/t/filter-all-loci-that-are-also-included-in-another-matrix-table/1303/3 "2020-02-20T18:01:31Z")

</div>

thanks

---

<div class="post-metadata">

**Author:** ![orr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/orr/32/846_2.png) [@orr](https://discuss.hail.is/u/orr)\
**Post date:** [February 20, 2020, 6:07pm UTC](https://discuss.hail.is/t/filter-all-loci-that-are-also-included-in-another-matrix-table/1303/4 "2020-02-20T18:07:30Z")

</div>

Will it be sorted in the same order automatically?

---

<div class="post-metadata">

**Author:** ![johnc1231](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/johnc1231/32/286_2.png) [@johnc1231](https://discuss.hail.is/u/johnc1231)\
**Post date:** [February 20, 2020, 7:20pm UTC](https://discuss.hail.is/t/filter-all-loci-that-are-also-included-in-another-matrix-table/1303/5 "2020-02-20T19:20:21Z")

</div>

The order of `mt` should be maintained.
