Skip to content

Phenotype queries

Milton Pividori edited this page Oct 24, 2018 · 10 revisions

Using columns from command line

You can select data-fields by using the columns option:

$ curl -G \
  -H "Accept:text/csv" \
  "http://127.0.0.1:5000/ukbrest/api/v1.0/phenotype" \
  --data-urlencode "columns=c50_0_0 as height" \
  --data-urlencode "columns=c21002_1_0 as weight" \
  > my_data.csv

Using ecolumns with regular expressions

For greater flexibility, you can also use ecolumns which allows you to match several data-fields in just one call, without the need to specify them one by one. Here we are choosing all genetic principal components (40 columns) with just one usage of ecolumns:

$ curl -G \
  -H "Accept:text/csv" \
  "http://127.0.0.1:5000/ukbrest/api/v1.0/phenotype" \
  --data-urlencode "columns=c21003_0_0 as age" \
  --data-urlencode "ecolumns=c22009_0_\d+" \
  > my_data.csv

Using a YAML file

Check the main page or the collection of real use cases in the wiki.

Change the output format

You can also change the output file format. For instance, if you use plink, BGENIE or Hail to run a GWAS, then you need a specific file format for each of them.

plink2

This is the same query shown above, but with a different Accept HTTP header, saying ukbREST that you want the data in plink2 format (with FID and IID columns, and separated by tab).

$ curl -G \
  -H "Accept:text/plink2" \
  "http://127.0.0.1:5000/ukbrest/api/v1.0/phenotype" \
  --data-urlencode "columns=c50_0_0 as height" \
  --data-urlencode "columns=c21002_1_0 as weight" \
  > my_data.csv

BGENIE

$ curl -G \
  -H "Accept:text/bgenie" \
  "http://127.0.0.1:5000/ukbrest/api/v1.0/phenotype" \
  --data-urlencode "columns=c50_0_0 as height" \
  --data-urlencode "columns=c21002_1_0 as weight" \
  > my_data.csv