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

Updating dictionaries #4

Open
theisuru opened this issue Sep 21, 2020 · 1 comment
Open

Updating dictionaries #4

theisuru opened this issue Sep 21, 2020 · 1 comment

Comments

@theisuru
Copy link
Contributor

Hi,
I tried to browse UKB showcase and find updated dictionaries (lookups). But I could only find updated dictionary for all fields (df_lkp_fields.tsv). So I am missing updated values for encoding and stats. Is it possible to update the readme file with links to these files.
Thanks

@spiros
Copy link
Owner

spiros commented Oct 5, 2020

Hey - df_lkp_encodings.csv is basically an concatenated version of all the individual lookup files - you can easily regenerate it doing something like this:

import pandas as pd

base_url = 'http://biobank.ctsu.ox.ac.uk/crystal/scdown.cgi?fmt=txt&id='
files = [ '11', '12', '5', '6' ]

df_lkp_encodings = pd.concat(
   [ pd.read_csv(base_url+f, sep="\t", encoding="latin-1") for f in files ], sort=True
)

df_lkp_encodings['code_id'] = df_lkp_encodings['code_id'].astype('Int64')
df_lkp_encodings = df_lkp_encodings[['encoding_id', 'code_id', 'value', 'meaning', 'selectable']]
df_lkp_encodings.to_csv('df_lkp_encodings.csv', index=False)

The descriptive stats file is a bit more complicated - you need to scrape the UKB portal and then extract it from there. Happy to share the code but probably best to do this in private, could you get in touch?

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

2 participants