Coder Social home page Coder Social logo

ukb-tools's Introduction

UKB-Tools

Introduction

This repository provides tools in Python to quickly start using the UK-BioBank dataset before UKB RAP. The folder has the following structure:

├── commands/
    ├── create_data.py
    ├── create_eu_set.py
    ├── get_newest_baskets.py
├── ukb_tools/
    ├── preprocess
        ├── filtering.py
        ├── labeling.py
        ├── utils.py
    ├── __init__.py
    ├── data.py
    ├── logger.py
    ├── tools.py

Installation

Clone the repository:

git clone https://github.com/TemryL/UKB-Tools.git

Move to the directory:

cd UKB-Tools

Create a virtual environment with Python 3.11 installed. Then install the dependencies:

pip install -r requirements.txt

Usage

UK-BioBank is organized by projects and baskets. Each project ID can have several basket IDs associated. When somenone requests new fields or a data update under the same project ID, a new basket will be created. Data across projects cannot be merged (because of eids randomization). However, data across baskets of the same project can be merged and it is preferable to get data for a given UKB field from the most recent basket.

Let's say we want to create a dataset with UKB fields 31, 131369, 3066. Then one can store the fields in a text file as follow:

ukb_fields.txt:

31
131369
3066

Run the following command to retrieve, for a given project ID, the most recent basket that contains the given UKB fields:

python commands/get_newest_baskets.py ${/dir/to/ukb_folder} ${project_id} ${data/ukb_fields.txt} ${data/field_to_basket.json}

The results will be stored in a JSON file as follow:

field_to_basket.json:

{
    "31": "project_52887_41230",
    "131369": "project_52887_676883",
    "3066": "project_52887_669338",
}

Finally, to merge the data in a single CSV file, run the following command:

python commands/create_data.py ${/dir/to/ukb_folder} ${data/field_to_basket.json} ${data.csv}

Contribute

Feel free to contribute to this repo by fixing issues, improving performances or adding new features!

ukb-tools's People

Contributors

temryl avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.