Skip to main content

hubmap-api-py-client

PyPI version

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:

>>> 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_celltypes', 'select_clusters', 'select_datasets', 'select_genes', 'select_organs', 'select_proteins']

>>> gene_symbol = client.select_genes(where="modality", has=["rna"]).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(where="gene", has=[f'{gene_symbol} > 1'], genomic_modality="rna", min_cell_percentage=0.0).get_list()[0]['uuid']
>>> dataset_b_uuid = client.select_datasets(where="gene", has=[f'{gene_symbol} > 1'], genomic_modality="rna", min_cell_percentage=0.0).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

# Get a list; should run quickly:
>>> cell_list = cells_with_gene.get_list()

>>> cells = cell_list[0:10]
>>> assert len(cells) > 0
>>> assert cells[0].keys() == {'cell_id', 'modality', 'dataset', 'organ', 'cell_type' ,'clusters'}

More documentation:

Only some types of objects can be retrieved from other types of objects:

where=... None cell cluster dataset gene organ protein modality celltype
select_cells() ✓ ✓ ✓ ✓ ✓ ✓ ✓ ✓
select_clusters() ✓ ✓ ✓ ✓ ✩ ✩ ✩ ✓
select_datasets() ✓ ✓ ✓ ✓ ✶ ✓ ✓
select_genes() ✓ ✓ ✩ ✓ ✓ ✩ ✩
select_organs() ✓ ✓ ✩ ✶ ✓ ✩ ✓ ✩ ✓
select_proteins() ✓ ✩ ✩ ✩
select_celltypes() ✓ ✓ ✓ ✓ ✩ ✓ ✓
  • "✓" = 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)

Metadata

Release files for hubmap-api-py-client 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for hubmap-api-py-client 0.0.11
File Interpreter ABI Platform
hubmap_api_py_client-0.0.11-py3-none-any.whl Python 3 none any Details

Release files / hubmap_api_py_client-0.0.11-py3-none-any.whl

Download URL hubmap_api_py_client-0.0.11-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65576f80fb449688027cabd43cd7f130e52fa8f43c4e823a579b6111085203e1
BLAKE2b-256 checksum
How to use checksums
64d392e8ff84f95b3a800a54f985139ce8e40ca5b19dccb2dbad79d8c5540504
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.6

Security for hubmap-api-py-client 0.0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page