requireNamespace("knitr") knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
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
library(gorr) library(magrittr) # pipe library(tibble)
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
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
categories <- get_categories(conn) tail(categories, 4)
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)
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)
tail(get_categories(conn), 5) print(name) # Category to be deleted category_delete(name, conn) tail(get_categories(conn), 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.