Annotation
Annotations are Hail’s way of adding data fields to Hail’s tables and matrix tables.
Create a nested annotation
- description:
Add a new field
gq_mean
as a nested field insideinfo
- code:
>>> mt = mt.annotate_rows(info=mt.info.annotate(gq_mean=hl.agg.mean(mt.GQ)))
- dependencies:
- understanding:
To add a new field
gq_mean
as a nested field insideinfo
, instead of a top-level field, we need to annotate theinfo
field itself.Construct an expression
mt.info.annotate(gq_mean=...)
which adds the field toinfo
. Then, reassign this expression toinfo
usingMatrixTable.annotate_rows()
.
Remove a nested annotation
- description:
Drop a field
AF
, which is nested inside theinfo
field.
To drop a nested field AF
, construct an expression mt.info.drop('AF')
which drops the field from its parent field, info
. Then, reassign this
expression to info
using MatrixTable.annotate_rows()
.
- code:
>>> mt = mt.annotate_rows(info=mt.info.drop('AF'))
- dependencies: