Page tree
Skip to end of metadata
Go to start of metadata


To do very simple queries on the clinical/phenotype data you can use the LabKey application on the Research Environment desktop. However, in order to do more complex analyses across multiple tables, or query very large tables, it is recommended that you use the provided LabKey APIs.

The LabKey client libraries (APIs) provide secure, auditable, programmatic access to LabKey data and services and allow you to:

  • Analyse and visualise data stored in LabKey in a statistical tool such as R or Python

  • Perform routine, automated tasks in a programmatic way.

  • Query and manipulate data in a repeatable and consistent way.

Currently, LabKey supports working with the following programming languages/environments.

  • Rlabkey Package

  • Python API

  • JavaScript API

  • Java API

  • Perl API

  • SAS Macros

We highly recommend using either the Python LabKey API or the R LabKey API to query the Genomics England clinical/phenotype data.

Configuring access

You firstly need to provide your credentials to the API so that you can access the data you are allowed. These credentials will be stored in a file called .netrc (dot net rc), located in your home directory.

  1. Obtain the .netrc template by following the steps outlined here: R, RStudio, and R libraries#ConfigurationofR or R, RStudio, and R libraries#ConfigurationofRonHelix
    1. Please note that you need to do this both in the Research Environment and on the HPC separately. So if you need access via the HPC, please login the HPC first and edit the template from there.
    2. The copy task listed there will provide you with additional files that may be required depending whether you will use the R or Python client. They will not hurt your overall session configuration.
  2. Once you have the .netrc template, open the Terminal application from the Research Environment desktop.
    1. If you need access via the HPC, please also login to the HPC.
  3. Open the file called .netrc in nano by typing nano .netrc and pressing enter/return.
    1. This should open a new view containing the information below:
    2. .netrc default content
      login yourusername
      password yourPasswordHere
  4. replace "yourusername" and "yourPasswordHere" with the same username and password that you use to login the Research Environment.
  5. Once the information is entered, save the file using Ctrl+O then hit enter/return. Exit nano with Ctrl+x.

Because the file contains your password, it should be set to read-write only for yourself.

  • The file permissions can be checked by entering ls -alh in the terminal. 
    • You should see a line like the following: -rw------- <username> <username> .netrc
  • If the permissions are in any other form, e.g. -rw-rw-rw-, they are visible to others and need to be changed.
  • This can be done with the following command: chmod 600 .netrc, which will set read-write to you only.

Further configuration

For R and Python you will need to make specific changes to your scripts. Please have a look at the following pages for example scripts and how to set up your own script:

R LabKey API - Please make sure that you follow the steps outlined in R, RStudio, and R libraries#ConfigurationofR

Python LabKey API

Troubleshooting: Potential errors upon incorrect setup (i.e. DOCTYPE, user permission denied, curl_fetch_memory)

In case the RLabKey API is incorrectly setup, please have a look here:
LabKey DOCTYPE error

LabKey curl_fetch_memory error
If this does not resolve the issue, and you still have problems using the R LabKey API, please contact the Service Desk.

  • No labels