Annotate_rows in Hail0.2 VS annotate_variants_expr(expr) in Hail0.1

Hi,

I am re-building Hail0.1 qc script with Hail0.2.
I searched doc, but not sure about this:

In hail0.1, we tried to “Replace INFO field allele count with the corrected variant qc allele count value”
vds.annotate_variants_expr(‘va.info.AC = va.qc.AC’)

In hail0.2, I try to do the same thing via: mt.annotate_rows(mt.info.AC[0] = mt.variant_qc.AC[0],mt.info.AC[1] = mt.variant_qc.AC[1]), I am not 100% sure whether this command line will do what I need?

Any help are welcome. Thanks.

The annotate_rows command doesn’t work quite like this.

mt.annotate_rows(mt.info.AC[0] = mt.variant_qc.AC[0],mt.info.AC[1] = mt.variant_qc.AC[1])

You can only annotate “fields” and you can only update one level of field at a time. Try this:

mt.annotate_rows(
    info = mt.info.annotate(AC = mt.variant_qc.AC)
)

Unfortunately, this is more verbose than the 0.1 syntax. My apologies! We have not yet discovered a succinct way to write this in Python 3.

The advantage of this style of syntax is that a Python IDE (such as PyCharm) can tell you what operations are available when you write mt.info! You should get a tooltip that lists all the available options.

1 Like