I generated 2 fields in my MatrixTable. One is an array with N elements, another - just float64 field. I want to concatenate the 2nd one to the end of the first one, so, for instance, if the first field for the 1st row (locus) looks like:
[0, 0, 1, 0]
and the 2nd looks like:
0.2
The end result should be:
[0, 0, 1, 0, 0.2]
I tried converting the float64 field into array, then merging them in an annotate_rows statement but its just not working since its trying to zip arrays when I have + and I don’t see any hl.concat() function for that purpose. Here is the code that I have:
pos_min = mt.aggregate_rows(hl.agg.min(mt.pos))
pos_max = mt.aggregate_rows(hl.agg.max(mt.pos))
mt = mt.annotate_rows(
normalized_pos=(mt.pos - pos_min) / (pos_max - pos_min)
)
mt = mt.annotate_rows(normalized_pos_array=[mt.normalized_pos])
# Concatenating two fields - normalized_pos which is float64 and chromosome_one_hot which is array<float64>
mt_concat = mt.annotate_rows(chromosome_one_hot=mt.chromosome_one_hot + mt.normalized_pos_array)
The last line is wrong of course and that’s what I am trying to figure out.
The function you’re looking for is extend, used like mt.chromosome_one_hot.extend(mt.normalized_pos_array). But even simpler is mt.chromosome_one_hot.append(mt.normalized_pos).