The new annotate_variants_keytable
command adds variant annotations based on a KeyTable.
For example, we can annotate variants by the pLI
of the gene in which they lie:
pLI_per_gene = hc.import_keytable("pLI-per-gene.tsv", ['gene'])
pLI_annotated_vds = hc.read("my.vds")
.annotate_variants_keytable(pLI_per_gene, 'va.pLI = table.pLI', ['va.gene']])
The third argument is an array of hail expressions whose types should match the keys of the key table. This expression sets va.pLI
, for every variant, to the value of the pLI
column from the row whose key matches the given variant’s gene.
I should stress that the array is an array of hail expressions, so this is also valid:
hc.read("my.vds")
.annotate_variants_keytable(a_key_table, 'va.foo = table.bar', ['exp(v.gq + va.gq_offset)']])