Coder Social home page Coder Social logo

apple629 / ukbscrape Goto Github PK

View Code? Open in Web Editor NEW

This project forked from asoroosh/ukbscrape

0.0 1.0 0.0 8 KB

Scrapes the UKBiobank website to provide a built-in dictionary for the field IDs. Also, check which of the variable are missed from your application to the website.

Python 82.94% Shell 17.06%

ukbscrape's Introduction

UKBscrape

Requirements

You should have a linux/mac machine with an internet connection.

Code

Python packages: os, numpy, pandas and re

Data

You should have a text file which conatins all FieldIDs available in your UKB application. If you have a CSV file of all the variables, you can do head -n 1 /path/2/your/UKB/ukbXXXXX.csv > ukbXXXX_Headers.txt

Configuration

If it is your first time that you use the UKBscrape, please make sure you are connected to the internet and run the following in the same directory as UKBscrape:

import UKBscrape as ukbs
ukbs.update()

This will make a sub-directory ~/IDLabCat which contains list of all variables and their categories.

Function & Usage

Matching

It helps you find intersection between variables available through your application and (almost) all other UKB advertised through https://biobank.ctsu.ox.ac.uk/

ukbs.match(UKBCSVFile = 'ukbXXXX_Headers.txt',Report2 = '/write/me/down/a/report/')

Report2 [optional]: if you need to save the reports, set a path for the results. This will produce two csv files:

  • YouDontHave.csv`: FieldID, label and category of the variables that you don't have
  • WasntParsed.csv`: the variables that may have missed in parsing but your application has!

Dictionary

It acts as a dictionary, you can pass a variable Field ID and it will return the variable name and its category (by category I mean UKbiobank pre-defined categories.)

ukbs.dictionary(UKBCSVFile = '', FieldID = '' ,SaveMe2 = '')
  • UKBCSVFile: path to the file of your UKB csv file (it is only to check whether you have that specific Field ID)
  • FieldID: The Field ID that you need to use the dictionary for. This has to be list of integers
  • SaveMe2 [optional]: path to a directory to save the results as tsv file. It saves the FieldID, labels and categories of passed FieldIDs

For example:


ukbs.dictionary(UKBCSVFile = 'ukbXXXXX_Headers.txt',FieldID=['4056','26412']);

You requested dictionary for 2 data fields.
                            Label                         Category WeHave
4056         Age stroke diagnosed               Medical conditions   True
26412  Employment score (England)  Indices of Multiple Deprivation  False

ukbscrape's People

Contributors

asoroosh 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.