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_meanas 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_meanas a nested field insideinfo, instead of a top-level field, we need to annotate theinfofield itself.Construct an expression
mt.info.annotate(gq_mean=...)which adds the field toinfo. Then, reassign this expression toinfousingMatrixTable.annotate_rows().
Remove a nested annotation
- description:
Drop a field
AF, which is nested inside theinfofield.
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: