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

Iterating through variants #1171

Open
hyanwong opened this issue Jan 19, 2024 · 0 comments
Open

Iterating through variants #1171

hyanwong opened this issue Jan 19, 2024 · 0 comments

Comments

@hyanwong
Copy link

hyanwong commented Jan 19, 2024

Possibly more of a zarr question, but I want to iterate over the variant information in an SGkit file, when that information is scattered over a number of arrays.

For example in my case, I want to look at the ancestral allele defined in variant_AA, do some string manipulation (e.g. change it to uppercase / lowercase), match the result against the corresponding list in variant.alleles, and then save it in a new array.

In other works, it would be useful to jointly iterate over arrays using e.g. zip. Something like

for aa, alleles in zip(ds.variant_AA, ds.alleles):  # probably doesn't work
    anc = aa.split("|")[0].lower()
    if anc in alleles:
        # do something
    # Save `anc` back out to another Zarr array - not sure how?

I imagine this sort of joint iteration is generally useful, but being a SGkit newbie, have no idea what the recommended approach is. Could it be added to the FAQ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant