Filter out variants on sex chromosomes from matrixtable

Hi,

I’m very new to Hail so probably have very basic questions…

I have a matrix table and after run ‘hl.summarize_variants(mt)’, I noted there are variants on X and Y chr. I need to exclude those variants from some analysis. How could I remove those variants from the matrix table?

I searched the tutorial but only found some function for removing variants from vds format (e.g., vds_filter_variants_expr) but it seems not working for matrix table.

Any suggestion would be appreciated.

Thank you!

If you have a matrix table, you’re looking for filter_rows:

mt = mt.filter_rows(mt.locus.contig != 'X') 
mt = mt.filter_rows(mt.locus.contig != 'Y') 

The new VDS format has some customized verbiage for genetics which unfortunately gets prioritized by the search system.

Got it. It worked.

Thank you!

1 Like