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_1(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")
  
      et = (
          mt.entries()
          .key_by("s")
          .join(dads, how="left")
          .join(moms, how="left")
      )
      et = et.annotate(
          is_dad=hl.is_defined(et.is_dad),
          is_mom=hl.is_defined(et.is_mom),
      )
  
      et = et.group_by(et.locus, et.alleles, fam=et.fam).aggregate(
          data=hl.agg.collect(
              hl.struct(
                  role=hl.case()
                  .when(et.is_dad, 1)
                  .when(et.is_mom, 2)
                  .default(0),
                  g=hl.struct(
                      GT=et.GT, AD=et.AD, DP=et.DP, GQ=et.GQ, PL=et.PL
                  ),
              )
          )
      )
  
      et = et.filter(hl.len(et.data) == 3)
      et = et.select("data").explode("data")
  
      tt = (
          hl.trio_matrix(mt, ped, complete_trios=True)
          .entries()
          .key_by("locus", "alleles")
      )
      tt = tt.annotate(
          fam=tt.proband.fam,
          data=[
              hl.struct(
                  role=0,
                  g=tt.proband_entry.select(
                      "GT", "AD", "DP", "GQ", "PL"
                  ),
              ),
              hl.struct(
                  role=1,
                  g=tt.father_entry.select(
                      "GT", "AD", "DP", "GQ", "PL"
                  ),
              ),
              hl.struct(
                  role=2,
                  g=tt.mother_entry.select(
                      "GT", "AD", "DP", "GQ", "PL"
                  ),
              ),
          ],
      )
      tt = tt.select("fam", "data").explode("data")
      tt = tt.filter(hl.is_defined(tt.data.g)).key_by(
          "locus", "alleles", "fam"
      )
  
      assert et.key.dtype == tt.key.dtype
      assert et.row.dtype == tt.row.dtype
      assert et._same(tt)
  
imports: import unittest
  import hail
  from ..helpers import *
label_desc: Use image node_id 1 for calling the Tests obj's underlying member method code with example usage: obj.test_trio_matrix_1() without return types