# Add AF to regression output

**URL:** <https://discuss.hail.is/t/add-af-to-regression-output/3947>\
**Category:** Hail Query & hailctl\
**Created:** [September 30, 2024, 4:31pm UTC](https://discuss.hail.is/t/add-af-to-regression-output/3947 "2024-09-30T16:31:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kelly\_Brewer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/kelly_brewer/32/1148_2.png) [@Kelly\_Brewer](https://discuss.hail.is/u/Kelly_Brewer)\
**Post date:** [September 30, 2024, 4:31pm UTC](https://discuss.hail.is/t/add-af-to-regression-output/3947/1 "2024-09-30T16:31:15Z")

</div>

I would like to add a matrixtable row “new\_AF” to my logistic regression output table by matching the locus and alleles. Both mt\_rows and log\_reg (ht) is keyed to locus and allele.

If I run  
log\_reg2 = log\_reg.annotate(AF = mt.index\_rows(log\_reg.key).new\_AF)  
I get error  
“ExpressionException: Key type mismatch: cannot index matrix table with given expressions:  
MatrixTable row key: locus, array  
Index expressions: str, array”

Not exactly certain what the error means or how to merge.

Thanks,

Kelly

---

<div class="post-metadata">

**Author:** ![chrisvittal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/chrisvittal/32/327_2.png) [@chrisvittal](https://discuss.hail.is/u/chrisvittal)\
**Post date:** [October 4, 2024, 2:13pm UTC](https://discuss.hail.is/t/add-af-to-regression-output/3947/2 "2024-10-04T14:13:56Z")

</div>

This error is indicating that `log_reg.row_key` is not of type `locus, alleles`, but that the first field is a string. Did the locus field get converted into a string at some point?

---

<div class="post-metadata">

**Author:** ![brewek04](https://avatars.discourse-cdn.com/v4/letter/b/da6949/32.png) [@brewek04](https://discuss.hail.is/u/brewek04)\
**Post date:** [October 4, 2024, 4:10pm UTC](https://discuss.hail.is/t/add-af-to-regression-output/3947/3 "2024-10-04T16:10:57Z")

</div>

Thank you. I must have been doing something odd.  
log\_reg2 = log\_reg.annotate(AF = mt.index\_rows(log\_reg.key).new\_AF) works now after I fixed by:

-Set key  
log\_reg = log\_reg.key\_by(‘locus’, ‘alleles’)
