vignettes/phenotype-categories.Rmd
phenotype-categories.Rmd
In this example, we’re going to explore the capabilities of the
phenotype-services using the gorr
package.
First load the gorr
package, the tidyverse
package is recommended in general, but not required for this example
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:55
#> • Access token expires at: 2022-06-17 15:55:55
If everything goes as planned, we’ll have a conn
object
to pass into subsequent functions.
All available categories can be listed by passing the
conn
object to the get_categories
function
categories <- get_categories(conn)
categories
#> [1] "statistics" "cardiovascular" "rtestCat73" "rtestCat16"
The results come back as a vector
of categories
If we want to add a new category to the catalog we can do so using
create_category
along with the name of the category to be
added as follows.
NB: Before creating a new category, make sure you have the privileges (admin rights to category management) to do so.
name <- paste0("rtestcat", sample(1:99, 1)) # Name of new category
new_category <- create_category(name, conn)
A new category has now been added and assigned to the variable
new_category
:
print(new_category)
#> $name
#> [1] "rtestcat47"
Categories can be removed from project by passing the name of the
category to category_delete
along with the connector
object.
get_categories(conn)
print(name) # Category to be deleted
category_delete(name, conn)
get_categories(conn)
#> [1] "statistics" "cardiovascular" "rtestcat47" "rtestCat73"
#> [5] "rtestCat16"
#> [1] "rtestcat47"
#> Response [https://platform.wuxinextcodedev.com/api/phenotype-catalog/projects/ukbb_hg38/categories/rtestcat47]
#> Date: 2022-06-16 15:55
#> Status: 204
#> Content-Type: <unknown>
#> <EMPTY BODY>
#> [1] "statistics" "cardiovascular" "rtestCat73" "rtestCat16"