docstr: This test depends on certain properties of the trio matrix VCF and
  pedigree structure. This test is NOT a valid test if the pedigree
  includes quads: the trio_matrix method will duplicate the parents
  appropriately, but the genotypes_table and samples_table orthogonal
  paths would require another duplication/explode that we haven't written.
docstr_tok: ["This","test","depends","on","certain","properties","of","the","trio","matrix","VCF","and","pedigree","structure",".","This","test","is","NOT","a","valid","test","if","the","pedigree","includes","quads",":","the","trio_matrix","method","will","duplicate","the","parents","appropriately",",","but","the","genotypes_table","and","samples_table","orthogonal","paths","would","require","another","duplication\/explode","that","we","have","n't","written","."]
code: def test_trio_matrix_2(self):
      """
      This test depends on certain properties of the trio matrix VCF and
      pedigree structure. This test is NOT a valid test if the pedigree
      includes quads: the trio_matrix method will duplicate the parents
      appropriately, but the genotypes_table and samples_table orthogonal
      paths would require another duplication/explode that we haven't written.
      """
      ped = hl.Pedigree.read(resource("triomatrix.fam"))
      ht = hl.import_fam(resource("triomatrix.fam"))
  
      mt = hl.import_vcf(resource("triomatrix.vcf"))
      mt = mt.annotate_cols(fam=ht[mt.s].fam_id)
  
      dads = ht.filter(hl.is_defined(ht.pat_id))
      dads = dads.select(dads.pat_id, is_dad=True).key_by("pat_id")
  
      moms = ht.filter(hl.is_defined(ht.mat_id))
      moms = moms.select(moms.mat_id, is_mom=True).key_by("mat_id")
  
      # test annotations
      e_cols = mt.cols().join(dads, how="left").join(moms, how="left")
      e_cols = e_cols.annotate(
          is_dad=hl.is_defined(e_cols.is_dad),
          is_mom=hl.is_defined(e_cols.is_mom),
      )
      e_cols = e_cols.group_by(fam=e_cols.fam).aggregate(
          data=hl.agg.collect(
              hl.struct(
                  role=hl.case()
                  .when(e_cols.is_dad, 1)
                  .when(e_cols.is_mom, 2)
                  .default(0),
                  sa=hl.struct(**e_cols.row.select(*mt.col)),
              )
          )
      )
      e_cols = (
          e_cols.filter(hl.len(e_cols.data) == 3)
          .select("data")
          .explode("data")
      )
  
      t_cols = hl.trio_matrix(mt, ped, complete_trios=True).cols()
      t_cols = (
          t_cols.annotate(
              fam=t_cols.proband.fam,
              data=[
                  hl.struct(role=0, sa=t_cols.proband),
                  hl.struct(role=1, sa=t_cols.father),
                  hl.struct(role=2, sa=t_cols.mother),
              ],
          )
          .key_by("fam")
          .select("data")
          .explode("data")
      )
      t_cols = t_cols.filter(hl.is_defined(t_cols.data.sa))
  
      assert e_cols.key.dtype == t_cols.key.dtype
      assert e_cols.row.dtype == t_cols.row.dtype
      assert e_cols._same(t_cols)
  
imports: import unittest
  import hail
  from ..helpers import *
label_desc: Use image node_id 2 for calling the Tests obj's underlying member method code with example usage: obj.test_trio_matrix_2() without return types