HuBMAP Cells API客户端
项目描述
hubmap-api-py-client
用于HuBMAP Cells API的Python客户端;另见:hubmap-api-js-client
。
贡献者从这里开始。
用法
从PyPI安装
pip install hubmap-api-py-client
根据不同标准查找细胞,并交集结果集
>>> 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'}
更多文档
只能从某些类型的对象检索到其他类型的对象
where=... |
None | 单元格 |
簇 |
数据集 |
基因 |
器官 |
蛋白质 |
模式 |
细胞类型 |
---|---|---|---|---|---|---|---|---|---|
select_cells() |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | |
select_clusters() |
✓ | ✓ | ✓ | ✓ ✩ | ✩ | ✩ | ✓ | ||
select_datasets() |
✓ | ✓ | ✓ | ✓ | ✶ | ✓ | ✓ | ||
select_genes() |
✓ | ✓ ✩ | ✓ | ✓ ✩ | ✩ | ||||
select_organs() |
✓ | ✓ | ✩ | ✶ | ✓ ✩ | ✓ | ✩ | ✓ | |
select_proteins() |
✓ | ✩ | ✩ | ✩ | |||||
select_celltypes() |
✓ | ✓ | ✓ | ✓ | ✩ | ✓ | ✓ |
项目详情
关闭
hubmap_api_py_client-0.0.11-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 65576f80fb449688027cabd43cd7f130e52fa8f43c4e823a579b6111085203e1 |
|
MD5 | 47805ad10e9af5b7078b46859e804590 |
|
BLAKE2b-256 | 64d392e8ff84f95b3a800a54f985139ce8e40ca5b19dccb2dbad79d8c5540504 |