Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregate GT over rows #3581

Open
iris-garden opened this issue May 6, 2024 · 0 comments
Open

Aggregate GT over rows #3581

iris-garden opened this issue May 6, 2024 · 0 comments
Labels
discourse migrated from discuss.hail.is

Comments

@iris-garden
Copy link
Owner

Note

The following post was exported from discuss.hail.is, a forum for asking questions about Hail which has since been deprecated.

(Jan 04, 2024 at 16:43) miye said:

Hi,

I am new to hail / genomics. I have a matrix table with locus and allele as row fields, s as a column field, and GT as an entry field. I want to find the counts of each genotype for each locus. So as example:

locus alleles s GT
chr:pos [“T”,“C”] 1 0/1
chr:pos [“T”,“C”] 2 0/0
chr:pos2 [“A”,“G”] 1 0/1
chr:pos2 [“A”,“G”] 2 1/1

Then I’d want to get

locus alleles count_GT
chr:pos [“T”,“C”] {0/0: 1, 0/1:1, 1/1:0}
chr:pos2 [“A”, “G”]. {0/0:0, 0/1:1, 1/1:1}

Thank you :slight_smile:

(Jan 09, 2024 at 11:40) jsmadsen said:

Seems like variant_qc fits the bill, no?

(Jan 09, 2024 at 17:37) miye said:

Yes, it seems like a very simple thing I missed:

result = hl.variant_qc(mt)
result.head(num_variants, 1).entries().show()

I was able to do it in another roundabout way but could compare the correctness.

mt = mt.annotate_entries(GT_str = hl.str(mt.GT))
row_agg_mt = mt.annotate_rows(gt_counter=hl.agg.counter(mt.GT_str))
row_agg_mt.rows().show()

Both results are giving me the same answer, so I think these are what I want, thank you jsmadsen

@iris-garden iris-garden added the discourse migrated from discuss.hail.is label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discourse migrated from discuss.hail.is
Projects
None yet
Development

No branches or pull requests

1 participant