# Splitting a phase GT field into haplotypes?

**URL:** <https://discuss.hail.is/t/splitting-a-phase-gt-field-into-haplotypes/2404>\
**Category:** Hail Query & hailctl\
**Created:** [December 11, 2021, 4:22pm UTC](https://discuss.hail.is/t/splitting-a-phase-gt-field-into-haplotypes/2404 "2021-12-11T16:22:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![CuriousGeneticist](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@CuriousGeneticist](https://discuss.hail.is/u/CuriousGeneticist)\
**Post date:** [December 11, 2021, 4:22pm UTC](https://discuss.hail.is/t/splitting-a-phase-gt-field-into-haplotypes/2404/1 "2021-12-11T16:22:01Z")

</div>

Hello all! If I have an entry of phased genotypes (GT), is it possible to split it into two different entries for each haplotype, within a matrixtable? Thank you!

---

<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:** [December 13, 2021, 4:51pm UTC](https://discuss.hail.is/t/splitting-a-phase-gt-field-into-haplotypes/2404/2 "2021-12-13T16:51:26Z")

</div>

Yes. `mt.GT[0]` and `mt.GT[1]` refer to the two alleles of a call, and if that call is phased these will refer to the two phased haplotypes.

---

<div class="post-metadata">

**Author:** ![CuriousGeneticist](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@CuriousGeneticist](https://discuss.hail.is/u/CuriousGeneticist)\
**Post date:** [December 13, 2021, 5:04pm UTC](https://discuss.hail.is/t/splitting-a-phase-gt-field-into-haplotypes/2404/3 "2021-12-13T17:04:51Z")

</div>

Oh ok that makes sense! Is there a way to split it into two different fields?

---

<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:** [December 13, 2021, 5:06pm UTC](https://discuss.hail.is/t/splitting-a-phase-gt-field-into-haplotypes/2404/4 "2021-12-13T17:06:21Z")

</div>

```auto
mt.annotate_entries(fieldOne = mt.GT[0], fieldTwo = mt.GT[1])

```

Where you can change `fieldOne` and `fieldTwo` to any names you like.

---

<div class="post-metadata">

**Author:** ![CuriousGeneticist](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@CuriousGeneticist](https://discuss.hail.is/u/CuriousGeneticist)\
**Post date:** [December 13, 2021, 5:52pm UTC](https://discuss.hail.is/t/splitting-a-phase-gt-field-into-haplotypes/2404/5 "2021-12-13T17:52:49Z")

</div>

Thank you for your response @johnc1231. I have tried that command and got this response:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/hail/original/1X/78bd549a4905bde2b2e810883c66b4cbc1e0ddbf.jpeg)  
The GT is within the entries, may I know if there is a way to resolve this?

---

<div class="post-metadata">

**Author:** ![danking](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/danking/32/43_2.png) [@danking](https://discuss.hail.is/u/danking)\
**Post date:** [December 13, 2021, 5:56pm UTC](https://discuss.hail.is/t/splitting-a-phase-gt-field-into-haplotypes/2404/6 "2021-12-13T17:56:12Z")

</div>

You don’t need to call `.entries()` to access the entry fields. `.entries()` is an _operation_: it converts from a dense, efficient MatrixTable format to a huge, inefficient Table format. It’s useful in a very limited set of circumstances.

Try this instead:

```auto
new_mt.annotate_entries(
    fieldOne = new_mt.mother_entry.PBT_GT[0],
    fieldTwo = new_mt.mother_entry.PBT_GT[1]
)

```

---

<div class="post-metadata">

**Author:** ![CuriousGeneticist](https://avatars.discourse-cdn.com/v4/letter/c/6f9a4e/32.png) [@CuriousGeneticist](https://discuss.hail.is/u/CuriousGeneticist)\
**Post date:** [December 13, 2021, 6:03pm UTC](https://discuss.hail.is/t/splitting-a-phase-gt-field-into-haplotypes/2404/7 "2021-12-13T18:03:03Z")

</div>

Oh okay, that makes sense! Sorry for this, a lot of Hail’s intricacies do not come naturally to me yet. Is there a way to transfer the haplotype information (+ the associated variant) into a CSV file so that I can work with it on Python?

Thank you sooo much for all your help.
