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

gwas.py gwas crashes with a KeyError: 0 trying to rename the IID column #163

Open
rzetterberg opened this issue Apr 28, 2023 · 5 comments
Open
Assignees
Labels
bug Something isn't working no-issue-activity

Comments

@rzetterberg
Copy link
Contributor

When running gwas.py gwas it crashes with a KeyError: 0 when trying to rename the IID column:

run2

Here's the offending line from gwas.py:

    iid_column_name = pheno_dict.loc[pheno_dict['TYPE'] == 'IID', 'FIELD'][0]

At first I was using a dict file that looked like this:

dict_file1

But now that you are not allowed to have multiple IID type columns, I changed the FID column to NOMINAL type,
(as I saw done in one of the use cases dict files):

dict_file2

When I then ran gwas.py gwas I was given the error above. Before commit 92fc902 I did not get this error.

Let me know if you need me to provide any additional information.

@rzetterberg rzetterberg added the bug Something isn't working label Apr 28, 2023
@espenhgn
Copy link
Contributor

Hi @rzetterberg. Can you try without the FID column? This document suggests it is not required: https://github.com/comorment/containers/blob/main/gwas/pheno_geno_specification.md#phenotypes-and-covariates

@ttfiliz
Copy link
Contributor

ttfiliz commented Apr 28, 2023

Hi @rzetterberg could you also try renaming the 'COLUMN' in the header of the dict file as 'FIELD'?

@rzetterberg
Copy link
Contributor Author

Thanks for the suggestions, @espenhgn and @ttfiliz! 👍🏻

Renaming the COLUMN in the header of the dict file to FIELD had no effect on the outcome.
But removing the FID column resolved the problem.

In the link @espenhgn sent it says:

If FID column is included in the phenotype file it will be simply ignored.

But if you include the FID column the program will crash, like it did for me. I'm not sure how many people will encounter this crash, since they won't be adding the FID column anyway. The reason I had the FID column was that I was simply rerunning an analysis from a couple of months ago with the latest version of the containers.

@espenhgn
Copy link
Contributor

Good! It would be good to add a test to check that the included columns are valid perhaps, producing a more meaningful error message than what you encountered above.

@github-actions
Copy link

This issue appears to be stale due to non-activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-issue-activity
Projects
Status: No status
Development

No branches or pull requests

3 participants