I’m trying to create a Hail Table keyed on a variant so I can convert it to a matrix table. I have the chr, pos, alt, and ref fields, and must create a variant from this.
The equivalent v01 code is the following
.annotate("variant=Variant(chr, pos, ref, alt)").key_by('variant')
I believe v02 does not have the Variant class available anymore, and see that I can create a locus and an allele array and key by those two.
.annotate(locus=hl.Locus(ht.chr, ht.pos)) .annotate(alleles=[ht.ref, ht.alt]) .key_by('locus', 'alleles')
But have trouble creating the locus with this error:
TypeError: __init__: parameter 'contig': expected (str or int), found hail.expr.expressions.typed_expressions.StringExpression: <StringExpression of type str>
It looks like I have to pass in a literal value, but I only have access to the expression values and can’t find a way to convert it. What would you recommend?
Also, is the rest of the logic (creating an array of ref and alt alleles and keying on the locus-allele array pair the right idea to then import into a Matrix Table?