# Annotate\_rows between 2 different reference genome matrix tables

**URL:** <https://discuss.hail.is/t/annotate-rows-between-2-different-reference-genome-matrix-tables/3516>\
**Category:** Hail Query & hailctl\
**Created:** [July 30, 2023, 7:56am UTC](https://discuss.hail.is/t/annotate-rows-between-2-different-reference-genome-matrix-tables/3516 "2023-07-30T07:56:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![takeo-naito](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@takeo-naito](https://discuss.hail.is/u/takeo-naito)\
**Post date:** [July 30, 2023, 7:56am UTC](https://discuss.hail.is/t/annotate-rows-between-2-different-reference-genome-matrix-tables/3516/1 "2023-07-30T07:56:44Z")

</div>

Hello Hail team,

I have two different Matrix tables (MTs). The name of MTs are mt and allmt.  
The reference genome of allmt is “GRCh37” and that of mt is “hs37d5” which is kind of GRCh37.  
What I wanted to do is as below.

```python

allmt = allmt.annotate_rows(MAF_tommo = mt.rows()[allmt.row_key].info.AF,
                           AC_tommo = mt.rows()[allmt.row_key].info.AC,
                           AN_tommo = mt.rows()[allmt.row_key].info.AN)

```

However, the code generated error messages as below.

- 

```python
-------------------------------------------------------------------------
TableIndexKeyError Traceback (most recent call last)
~/miniconda3/envs/hail/lib/python3.7/site-packages/hail/table.py in index(self, all_matches, *exprs)
   1777 try:
-> 1778 return self._index(*exprs, all_matches=all_matches)
   1779 except TableIndexKeyError as err:

~/miniconda3/envs/hail/lib/python3.7/site-packages/hail/table.py in _index(self, all_matches, *exprs)
   1848 and isinstance(exprs[0], StructExpression)):
-> 1849 return self._index(*exprs[0].values(), all_matches=all_matches)
   1850 

~/miniconda3/envs/hail/lib/python3.7/site-packages/hail/table.py in _index(self, all_matches, *exprs)
   1851 if not is_interval:
-> 1852 raise TableIndexKeyError(self.key.dtype, exprs)
   1853 

TableIndexKeyError: 

During handling of the above exception, another exception occurred:

ExpressionException Traceback (most recent call last)
<ipython-input-49-3a9bf305d4d1> in <module>
----> 1 allmt = allmt.annotate_rows(MAF_tommo = mt.rows()[allmt.row_key].info.AF,
      2 AC_tommo = mt.rows()[allmt.row_key].info.AC,
      3 AN_tommo = mt.rows()[allmt.row_key].info.AN)

~/miniconda3/envs/hail/lib/python3.7/site-packages/hail/table.py in __getitem__ (self, item)
    374 
    375 try:
--> 376 return self.index(*wrap_to_tuple(item))
    377 except TypeError as e:
    378 raise TypeError("Table. __getitem__ : invalid index argument(s)\n"

~/miniconda3/envs/hail/lib/python3.7/site-packages/hail/table.py in index(self, all_matches, *exprs)
   1778 return self._index(*exprs, all_matches=all_matches)
   1779 except TableIndexKeyError as err:
-> 1780 raise ExpressionException(f"Key type mismatch: cannot index table with given expressions:\n"
   1781 f" Table key: {', '.join(str(t) for t in err.key_type.values()) or '<<<empty key>>>'}\n"
   1782 f" Index Expressions: {', '.join(str(e.dtype) for e in err.index_expressions)}")

ExpressionException: Key type mismatch: cannot index table with given expressions:
  Table key: locus<hs37d5>, array<str>
  Index Expressions: locus<GRCh37>, array<str>

```

I think this error is because of the different reference genome.  
Could you let me know if there are some ways to solve this problem?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![takeo-naito](https://avatars.discourse-cdn.com/v4/letter/t/3bc359/32.png) [@takeo-naito](https://discuss.hail.is/u/takeo-naito)\
**Post date:** [July 31, 2023, 8:59am UTC](https://discuss.hail.is/t/annotate-rows-between-2-different-reference-genome-matrix-tables/3516/2 "2023-07-31T08:59:47Z")

</div>

I could solve this problem by importing VCF of “hs37d5" using reference\_genome=‘GRCh37’ and skip\_invalid\_loci.
