Client for the HuBMAP Cells API
Project description
hubmap-api-py-client
Python client for the HuBMAP Cells API;
See also: hubmap-api-js-client
.
Contributors start here.
Usage
Install from pypi:
pip install hubmap-api-py-client
Find cells with different criteria, and intersect resulting sets:
$ export API_ENDPOINT='https://cells.dev.hubmapconsortium.org/api/'
>>> from os import environ
>>> from hubmap_api_py_client import Client
>>> client = Client(environ['API_ENDPOINT'])
>>> [m for m in dir(client) if m.startswith('select_')]
['select_cells', 'select_clusters', 'select_datasets', 'select_genes', 'select_organs', 'select_proteins']
>>> cells_with_vim = client.select_cells(where='gene', has=['VIM > 0.5'], genomic_modality='rna')
>>> assert len(cells_with_vim) > 0
# Select cells from the datasets with the following UUIDs:
>>> dataset_a_uuid = '68159e4bd6a2cea1cd66e8f3050cfcb7'
>>> dataset_b_uuid = 'e8d642084fc5ec8b5d348ebab96a4b22'
>>> cells_in_a_len = len(client.select_cells(where='dataset', has=[dataset_a_uuid]))
>>> cells_in_b_len = len(client.select_cells(where='dataset', has=[dataset_b_uuid]))
>>> cells_in_datasets = client.select_cells(where='dataset', has=[dataset_a_uuid, dataset_b_uuid])
>>> cells_in_datasets_len = len(cells_in_datasets)
>>> assert cells_in_datasets_len > 0
>>> assert cells_in_datasets_len == cells_in_a_len + cells_in_b_len
# Combine criteria with intersection:
>>> cells_with_vim_in_datasets = cells_with_vim & cells_in_datasets
>>> assert len(cells_with_vim_in_datasets) > 10
# Get a list; should run quickly:
>>> cell_list = cells_with_vim_in_datasets.get_list()
>>> cells = cell_list[0:10]
>>> assert len(cells) == 10
>>> assert cells[0].keys() == {'cell_id', 'modality', 'dataset', 'organ', 'clusters', 'protein_mean', 'protein_total', 'protein_covar'}
More documentation:
Only some types of objects can be retrieved from other types of objects:
where=... |
None | cell |
cluster |
dataset |
gene |
organ |
protein |
---|---|---|---|---|---|---|---|
select_cells() |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
select_clusters() |
✓ | ✓ | ✓ | ✓ ✩ | ✩ | ✩ | |
select_datasets() |
✓ | ✓ | ✓ | ✓ | ✶ | ||
select_genes() |
✓ | ✓ ✩ | ✓ | ✓ ✩ | ✩ | ||
select_organs() |
✓ | ✓ | ✩ | ✶ | ✓ ✩ | ✓ | ✩ |
select_proteins() |
✓ | ✩ | ✩ | ✩ |
- "✓" = Supported by Cells API, and this client.
- "✶" = Supported by Entities API; support in this client is on the roadmap.
- "✩" = Possible connection to ASCT-B (Anatomical Structures / Cell Types / Biomarkers)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for hubmap-api-py-client-0.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f503d311e835c3fc26421ff15046e3df2ec47a26c91571752afe267c58b17f2 |
|
MD5 | d3e090d2cc9472deb99170b6d53aace1 |
|
BLAKE2b-256 | 223e3d0115266e7ee2608dc7fd8a24b80f6cdb2f74963516b1ea4f74556647ec |
Close
Hashes for hubmap_api_py_client-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f46e0cf00f06fadf9f59495c0bb37aca17b582604f37133c7ebe11c8354b9ee |
|
MD5 | d78f403e4c31cd374e76f8bfce5db105 |
|
BLAKE2b-256 | adb4839d94fa71813d20517cfdce606afd5c0058c5e41e8c3c341da0778f6e3f |