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']
>>> gene_symbol = client.select_genes().get_list()[0]['gene_symbol']
>>> cells_with_gene = client.select_cells(where='gene', has=[f'{gene_symbol} > 0.5'], genomic_modality='rna')
>>> assert len(cells_with_gene) > 0
# Select cells from the datasets with the following UUIDs:
>>> dataset_a_uuid = client.select_datasets().get_list()[0]['uuid']
>>> dataset_b_uuid = client.select_datasets().get_list()[1]['uuid']
>>> 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_gene_in_datasets = cells_with_gene & cells_in_datasets
>>> assert len(cells_with_gene_in_datasets) > 0
# Get a list; should run quickly:
>>> cell_list = cells_with_gene_in_datasets.get_list()
>>> cells = cell_list[0:10]
>>> assert len(cells) > 0
>>> assert cells[0].keys() == {'cell_id', 'modality', 'dataset', 'organ', 'clusters'}
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
hubmap-api-py-client-0.0.9.tar.gz
(14.8 kB
view hashes)
Built Distribution
Close
Hashes for hubmap-api-py-client-0.0.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8af6df46374ed838d3aeb5fb7298d7212145eb0f8dca01c095147fb05e304ee2 |
|
MD5 | e97860827f65205652ff52c1c32b792a |
|
BLAKE2b-256 | 0496d5b90d8ecfb31255efc055fb3f891dace800c705aa0eaaf96911d079aafc |
Close
Hashes for hubmap_api_py_client-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a4601d8d3df9c56d6803cee2678844589808bd9df71657ac459a2559c0a3ccd |
|
MD5 | 29a18133bbf2390f0ee744cacd206d92 |
|
BLAKE2b-256 | ee75f5eb07c955b72d5b20bad7e2a232a857ef2e178d1068d4acd9c3aa52b8dd |