# Filtering INFO fields

**URL:** <https://discuss.hail.is/t/filtering-info-fields/3359>\
**Category:** Hail Query & hailctl\
**Created:** [April 27, 2023, 11:36am UTC](https://discuss.hail.is/t/filtering-info-fields/3359 "2023-04-27T11:36:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![uridavid](https://avatars.discourse-cdn.com/v4/letter/u/b9e5f3/32.png) [@uridavid](https://discuss.hail.is/u/uridavid)\
**Post date:** [April 27, 2023, 11:36am UTC](https://discuss.hail.is/t/filtering-info-fields/3359/1 "2023-04-27T11:36:48Z")

</div>

Hi.  
I appreciate the hail package, because it is super fast.  
I would like to take a VCF from gnomad, and filter out some of the INFO fields - gnomad has 900+, and I only care about a few of them.

Example code

```python
import hail as hl
import re
chr22mt = hl.read_matrix_table('data/gnomad.genomes.v3.1.2.sites.chr22.mt')
chr22mt.info.select(*[x for x in chr22mt.info.keys() if re.match('AF_\S{2,3}$', x)]).describe()

```

That gets me a much smaller INFO set, which what I want.

However, trying to take the filtered info into chr22mt fails.

```python
chr22mt.info = chr22mt.info.select(*[x for x in chr22mt.info.keys() if re.match('AF_\S{2,3}$', x)]).describe()
--------------------------------------------------------
Type:
        struct {
        AF_oth: array<float64>, 
        AF_ami: array<float64>, 
        AF_sas: array<float64>, 
        AF_XX: array<float64>, 
        AF_fin: array<float64>, 
        AF_XY: array<float64>, 
        AF_eas: array<float64>, 
        AF_amr: array<float64>, 
        AF_afr: array<float64>, 
        AF_raw: array<float64>, 
        AF_mid: array<float64>, 
        AF_asj: array<float64>, 
        AF_nfe: array<float64>
    }
--------------------------------------------------------
Source:
    <hail.matrixtable.MatrixTable object at 0x7f6980d417c0>
Index:
    ['row']
--------------------------------------------------------
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pipeline-user/.local/lib/python3.9/site-packages/hail/table.py", line 117, in __setattr__
    raise NotImplementedError(f"'{self. __class__. __name__ }' object is not mutable")
NotImplementedError: 'MatrixTable' object is not mutable\

```

I’m clearly missing something, but it doesn’t seem like any of select\_rows(), select\_cols(), select\_entries() would work. How do I filter out fields of INFO from a VCF?

Thank you,

Uri David

---

<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:** [April 27, 2023, 3:44pm UTC](https://discuss.hail.is/t/filtering-info-fields/3359/2 "2023-04-27T15:44:23Z")

</div>

The way to add or modify fields on a table is `annotate`, or here, `annotate_rows` to update a row field. You have to annotate top-level fields, so the way to do this is to update the entire info field to select the ones you want:

```python
chr22mt = chr22mt.annotate_rows(info = chr22mt.info.select(...))

```
