accessClass: Access Classes

View source: R/accessClass.R

accessClassR Documentation

Access Classes

Description

Access classes (including both regular and provisional) by ontology and class id.

Usage

accessClass(
  api.key,
  ontology,
  id,
  sub = NA_character_,
  output.mode = "content"
)

Arguments

api.key

character. An API Key is required to access any API call. It is used within cedarr as a header for http requests. An API key is linked to a CEDAR account (https://cedar.metadatacenter.org/profile)

ontology

character. Ontology name to display.

id

character. Class ID to get, formatted as an URL. (item @id in the result of accessOntology())

sub

character. Class content ID to retrieve. Can be: NA, "tree", "children", "descendants" or "parents".

output.mode

character. "full" will return the whole response object (from httr) or "content" will fetch the interest values from the response object. Getting the whole object might be interesting to have a look at system metadata, or in case of error to debug the connection. (defaults to "content")

Details

This function matches the following queries from the Swagger UI (https://terminology.metadatacenter.org/api/#/):

  • /ontologies/{ontology}/classes/{id}

  • /ontologies/{ontology}/classes/{id}/tree

  • /ontologies/{ontology}/classes/{id}/children

  • /ontologies/{ontology}/classes/{id}/descendants

  • /ontologies/{ontology}/classes/{id}/parents

These differents requests are differenciated by the sub argument.

Value

Setting sub to NA will retrieve the class item such as it is presented in the return of accessOntology() (item @id). Setting sub to "tree" will return the roots of the ontology in a data.frame. Setting sub to "children" will return all of the descendants from the class that happen to be one level below the class itself in its ontology. Setting sub to "descendants" will return all of the descendants from the class, whatever is their level below the target class. Setting sub to "parents" will return the class coming before the target class in its ontology.

If output.mode = "full", the whole http response object (see httr::response). It is structured as a list with response metadata wrapping the content item which contains the wanted result.

If output.mode = "content", the content item is directly returned, containing database metadata and the interesting information in the collection subitem.

Examples

## Not run: 
my.api.key <- readline()

# Fetch 'biome' class in ENVO
result <- cedarr::accessClass(
  my.api.key,
  "ENVO",
  "http://purl.obolibrary.org/obo/ENVO_00000428"
)

View(result)

## End(Not run)


earnaud/cedarr documentation built on Oct. 25, 2022, 6:27 a.m.