# Annotating gene names from file (gtf)

**URL:** <https://discuss.hail.is/t/annotating-gene-names-from-file-gtf/1281>\
**Category:** Hail Query & hailctl\
**Created:** [February 10, 2020, 11:19pm UTC](https://discuss.hail.is/t/annotating-gene-names-from-file-gtf/1281 "2020-02-10T23:19:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![orr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/orr/32/846_2.png) [@orr](https://discuss.hail.is/u/orr)\
**Post date:** [February 10, 2020, 11:19pm UTC](https://discuss.hail.is/t/annotating-gene-names-from-file-gtf/1281/1 "2020-02-10T23:19:45Z")

</div>

I want to add gene names (stored in mt from an imported GTF file as locus interval) to an imported mt from VCF. I annotate by the conditional that the locus is contained in the locus interval:

`mt_vcf= mt_vcf.annotate_rows(gencode= hl.cond(gencode_genes_mt.interval.contains(mt_vcf.locus), gencode_genes_mt.gene_name))`

And get the following error. What is the best way to do so?

```
ExpressionException: Cannot combine expressions from different source objects.
    Found fields from 2 objects:
        <hail.matrixtable.MatrixTable object at 0x7fa1c03254a8>: ['interval']
        <hail.matrixtable.MatrixTable object at 0x7fa1c00a3160>: ['locus']

```

Thanks.

---

<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:** [February 11, 2020, 1:44pm UTC](https://discuss.hail.is/t/annotating-gene-names-from-file-gtf/1281/2 "2020-02-11T13:44:23Z")

</div>

The method you should be using is [Table.index](https://hail.is/docs/0.2/hail.Table.html#hail.Table.index):

```auto
mt_vcf = mt_vcf.annotate_rows(gencode = gencode_genes[mt.locus].gene_name)

```

I thought we had a how-to on doing this, I’l make a note to add one.

---

<div class="post-metadata">

**Author:** ![orr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/orr/32/846_2.png) [@orr](https://discuss.hail.is/u/orr)\
**Post date:** [February 11, 2020, 5:27pm UTC](https://discuss.hail.is/t/annotating-gene-names-from-file-gtf/1281/3 "2020-02-11T17:27:12Z")

</div>

Worked. thanks Tom
