Is there a way to use hl.agg.collect() function on two rows, so I can get a list of structures?

Hello.
Is there a way to apply hl.agg.collect() on two rows at once (in my case, ‘locus’ and ‘alleles’), and get a set of structures?

For example, if this is what my matrixtable looks like:

locus alleles
1:1 [“A”,“C”]
1:2 [“A”,“C”]
1:3 [“A”,“C”]

I would like to get something like this:

{Struct(1:1, ["A","C"]), Struct(1:2, ["A","C"]), Struct(1:3, ["A","C"])}

Thanks in advance!

There’s hl.agg.collect_as_set. The following aggregate line should give you your desired output for the given input:

mt.aggregate_rows(hl.agg.collect_as_set(mt.row_key))

(assuming the row key is locus/alleles, you can always hl.agg.collect_as_set(hl.struct(locus=mt.locus, alleles=mt.alleles)) if not)