Add row annotation with label based on entry field of one sample

Hi,

I want to annotate rows in a matrix table with a label based on the GT entry field of one specific sample.
For example, the new label row field should be “0” if the genotype of this one particular sample within this row is ‘0/0’, etc. How can I do this? Thank you very much for your help!

Hey @dgb !

Accessing a single column is one of the trickiest parts of the Hail interface! Does this do what you’re looking for? It filters the genotypes at each row to those genotypes whose sample id is “bob” and then collects those genotypes and takes the only one (assuming only one person’s sample id is “bob”).

mt = mt.annotate_rows(
    bobs_n_alt_alleles = hl.agg.filter(
        mt.s == "bob",
        hl.agg.collect(mt.GT.n_alt_alleles())[0])
)

Yes this did the job, thank you so much!