Skip to content

ConceptLibraryClient Packages

Ieuan Scanlon edited this page Oct 11, 2023 · 2 revisions

3. ConceptLibraryClient Packages

We have developed wrapper packages for easy access and use of the Concept Library API:

  • Python client, you can find more information on how to use it here
  • R client, you can find more information on how to use it here

3.1. Phenotype Definition Files

Both the Python and R clients support creating and updating phenotypes using YAML files. Essentially, the phenotype is defined in the YAML file, where metadata fields capture information about the algorithm, data sources, controlled clinical terminologies and other information. You can download the definition files of already available phenotypes by calling the phenotype functions within the packages.

The information required to define a specific type of phenotype is defined by its template. You can view the template definition of a specific group of phenotypes by calling the templates functions within the packages.

In Python:

from pyconceptlibraryclient import Client

# Log in to the ConceptLibrary
client = Client(public=False)

# Save the definition file of a phenotype
client.phenotypes.save_definition_file('./where/to/save/my-phenotype.yaml', 'PH1')

# Query the Clinical-Coded Phenotype template
template_detail = client.templates.get_detail(1)

In R:

library(ConceptLibraryClient)

# Log in to the ConceptLibrary
client = ConceptLibraryClient::Connection$new(public=FALSE)

# Save the definition file of a phenotype
client$phenotypes$save_definition_file('./where/to/save/my-phenotype.yaml', 'PH1')

# Query the Clinical-Coded Phenotype template
template_detail = client$templates$get_detail(1)

3.2. Creating and Updating Phenotypes

Once you've created a phenotype definition YAML file, you can create and update phenotypes by calling the respective function within the packages.

In Python:

from pyconceptlibraryclient import Client

# Log in to the ConceptLibrary
client = Client(public=False)

# Create a phenotype
result = client.phenotypes.create('./path/to/file/my-phenotype.yaml')

# Update a phenotype
result = client.phenotypes.update('./path/to/file/my-phenotype.yaml')

In R:

library(ConceptLibraryClient)

# Log in to the ConceptLibrary
client = ConceptLibraryClient::Connection$new(public=FALSE)

# Create a phenotype
result = client$phenotypes$create('./path/to/file/my-phenotype.yaml')

# Update a phenotype
result = client$phenotypes$update('./path/to/file/my-phenotype.yaml')