In this example, we’re going to demonstrate how to interact with the covariate services API using the gorr package.

Loading required packages

Connect to Genuity Science’s services.

First we’ll need to establish a connection to our API services. To do that we’ll need to call platform_connect and provide it with the relevant parameters pointing to the phenotype-catalog-service, i.e. api_key and project:

conn <- platform_connect(api_key = Sys.getenv("GOR_API_KEY"),
                          project = Sys.getenv("GOR_API_PROJECT"))
conn
#> ── GOR API service connection ──────────────────────────────────────────────────
#> • Service Root/s: https://platform.wuxinextcodedev.com/api/query, https://platform.wuxinextcodedev.com/api/phenotype-catalog, https://platform.wuxinextcodedev.com/queryserver, https://platform.wuxinextcodedev.com/workflow
#> • Project: ukbb_hg38
#> • API key issued at: 2022-05-18 10:18:54
#> • API key expires at: Never
#> • Access token issued at: 2022-06-16 15:55:10
#> • Access token expires at: 2022-06-17 15:55:10

If everything goes as planned, we’ll have a conn object to pass into subsequent functions.

List available covariates

Covariates available to users can be listed by passing the conn object to get_covariates.

covariates <- get_covariates(conn)
covariates

The results come back as a list of covariates available to the user.

Get phenotype

Now can fetch a covariate from the project get_covariate and passing the covariate’s unique id along with the conn object .

covariate <- get_covariate(id = 1, conn)
covariate