Skip to content

Commit 6c40ed4

Browse files
Add ontology term name and cell state to obs (#52)
* add ontology term and cell state to obs * change domain * update docs domain * version bump * name fix and docs update * Update test_main.py
1 parent dacf0a0 commit 6c40ed4

File tree

7 files changed

+181
-29
lines changed

7 files changed

+181
-29
lines changed

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
---
2424
<a href="https://colab.research.google.com/drive/1aRLsI3mx8JR8u5BKHs48YUbLsqRsh2N7?usp=sharing" target="_blank">Example Notebook</a> |
25-
<a href="https://nygen-labs-prod--cytetype-api.modal.run/report/2b514924-334f-4f5c-aa25-347155586634?v=251123" target="_blank">Example output</a> |
25+
<a href="https://prod.cytetype.nygen.io/report/2b514924-334f-4f5c-aa25-347155586634?v=251123" target="_blank">Example output</a> |
2626
<a href="docs/examples.md">Atlas scale results</a>
2727

2828
Switch to R/Seurat package: <a href="https://github.com/NygenAnalytics/CyteTypeR">CyteTypeR</a>
@@ -47,19 +47,25 @@ sc.pp.log1p(adata)
4747
sc.pp.highly_variable_genes(adata, n_top_genes=1000)
4848
sc.pp.pca(adata)
4949
sc.pp.neighbors(adata)
50-
sc.tl.leiden(adata, key_added="clusters")
51-
sc.tl.rank_genes_groups(adata, groupby="clusters", method="t-test")
50+
51+
group_key = 'clusters' # Wherever you want to store or already have clusters in adata.obs
52+
53+
sc.tl.leiden(adata, key_added=group_key)
54+
sc.tl.umap(adata)
55+
sc.tl.rank_genes_groups(adata, groupby=group_key, method="t-test")
5256
# ------ Example Scanpy Pipeline ------
5357

5458
# ------ CyteType ------
55-
annotator = CyteType(adata, group_key="clusters")
59+
annotator = CyteType(adata, group_key=group_key)
5660
adata = annotator.run(
5761
study_context="Brief study description (e.g., Human brain tissue ...)",
5862
)
5963

60-
# View results
61-
print(adata.obs.cytetype_annotation_clusters)
62-
print(adata.obs.cytetype_cellOntologyTerm_clusters)
64+
# Visualize results
65+
sc.pl.embedding(adata, basis='umap', color=f'cytetype_annotation_{group_key}')
66+
sc.pl.embedding(adata, basis='umap', color=f'cytetype_cellOntologyTerm_{group_key}')
67+
sc.pl.embedding(adata, basis='umap', color=f'cytetype_ontologyTermID_{group_key}')
68+
sc.pl.embedding(adata, basis='umap', color=f'cytetype_cellState_{group_key}')
6369
```
6470

6571
## Documentation

cytetype/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .main import CyteType
22

33
__all__ = ["CyteType"]
4-
__version__ = "0.10.0"
4+
__version__ = "0.11.0"

cytetype/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def _transform_results(results_data: Dict[str, Any]) -> Dict[str, Any]:
157157
"clusterId": annotation_data.get("clusterId", cluster_id),
158158
"annotation": annotation_data.get("annotation", "Unknown"),
159159
"ontologyTerm": annotation_data.get(
160+
"cellOntologyTermName", "Unknown"
161+
),
162+
"ontologyTermID": annotation_data.get(
160163
"cellOntologyTerm", "Unknown"
161164
),
162165
# Include additional fields from new format

cytetype/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
)
1212

1313

14-
DEFAULT_API_URL = "https://nygen-labs-prod--cytetype-api.modal.run"
14+
DEFAULT_API_URL = "https://prod.cytetype.nygen.io"
1515
DEFAULT_POLL_INTERVAL = 10
1616
DEFAULT_TIMEOUT = 7200

cytetype/main.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,31 @@ def _store_results_and_annotations(
218218
).astype("category")
219219
)
220220

221+
# Update ontology term IDs
222+
ontology_id_map = {
223+
item["clusterId"]: item["ontologyTermID"]
224+
for item in result_data.get("annotations", [])
225+
}
226+
self.adata.obs[f"{results_prefix}_cellOntologyTermID_{self.group_key}"] = (
227+
pd.Series(
228+
[
229+
ontology_id_map.get(cluster_id, "Unknown")
230+
for cluster_id in self.clusters
231+
],
232+
index=self.adata.obs.index,
233+
).astype("category")
234+
)
235+
236+
# Update cell states
237+
cell_state_map = {
238+
item["clusterId"]: item.get("cellState", "")
239+
for item in result_data.get("annotations", [])
240+
}
241+
self.adata.obs[f"{results_prefix}_cellState_{self.group_key}"] = pd.Series(
242+
[cell_state_map.get(cluster_id, "") for cluster_id in self.clusters],
243+
index=self.adata.obs.index,
244+
).astype("category")
245+
221246
# Check for unannotated clusters if requested
222247
if check_unannotated:
223248
unannotated_clusters = set(
@@ -238,6 +263,8 @@ def _store_results_and_annotations(
238263
logger.success(
239264
f"Annotations successfully added to `adata.obs['{results_prefix}_annotation_{self.group_key}']`\n"
240265
f"Ontology terms added to `adata.obs['{results_prefix}_cellOntologyTerm_{self.group_key}']`\n"
266+
f"Ontology term IDs added to `adata.obs['{results_prefix}_ontologyTermID_{self.group_key}']`\n"
267+
f"Cell states added to `adata.obs['{results_prefix}_cellState_{self.group_key}']`\n"
241268
f"Full results added to `adata.uns['{results_prefix}_results']`."
242269
)
243270

docs/examples.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ The following are notebooks used to run CyteType on all the single-cell datasets
55

66
| Dataset | Links |
77
| --- | --- |
8-
| **Tabula Sapiens** | [Colab](https://colab.research.google.com/drive/1EyQXaruDJBPICUvlUY1E19zxOm_L4_VU?usp=sharing) - [CyteType Report](https://nygen-labs-prod--cytetype-api.modal.run/report/15332f10-2048-4099-ab1e-baf2ab9e39c3) - [H5ad](https://drive.google.com/file/d/1URo7niPqAo-9HGVH8f3QJfqll9lc8JN_/view?usp=drive_link) |
9-
| **GTEX v9** | [Colab](https://colab.research.google.com/drive/1uvqG2eVaUuNe66e0_7bp682uCdKx6-KL?usp=sharing) - [CyteType Report](https://nygen-labs-prod--cytetype-api.modal.run/report/5242f3b8-0078-417d-954e-00d1bb19bdf6) - [H5ad](https://drive.google.com/file/d/1EIpudRyasLUHR6J2v8fdpmBTbCE2__UF/view?usp=drive_link) |
10-
| **Hypomap** | [Colab](https://colab.research.google.com/drive/1OuTnh8xHoXaINCGcgu_1q-jANwXL8ggF?usp=sharing) - [CyteType Report](https://nygen-labs-prod--cytetype-api.modal.run/report/3840b662-bacf-4067-b93d-4e57c1f21187) - [H5ad](https://drive.google.com/file/d/1QMvZNdoDlKpOmyguAXSk45-YVz97v4tM/view?usp=drive_link) |
11-
| **Human Lung Cell Atlas (Core)** | [Colab](https://colab.research.google.com/drive/1FoTD-XzLNDPgYSlgVsxnLwPnWF5YiKny?usp=sharing) - [CyteType Report](https://nygen-labs-prod--cytetype-api.modal.run/report/6da1458a-392f-4bce-b6c9-4ccb308c8797) - [H5ad](https://drive.google.com/file/d/13O0dyUnwJKLPm8fncRt597S5hs2COsxx/view?usp=drive_link) |
12-
| **Immune Cell Atlas** | [Colab](https://colab.research.google.com/drive/1Kum9S_kU76QvS__42ABd-Xp1GpH4c9jU?usp=sharing) - [CyteType Report](https://nygen-labs-prod--cytetype-api.modal.run/report/05ff7629-8f0c-4b95-ac65-30bba9b384c5) - [H5ad](https://drive.google.com/file/d/1iqkC7dG1ovgKsU_8HdZ2eyELIxB0sM3t/view?usp=drive_link) |
13-
| **Mouse Pancreatic Cell Atlas** | [Colab](https://colab.research.google.com/drive/1fg9W3Lz-E_yAVoqs_6XrQsYkfsfnzFey?usp=sharing) - [CyteType Report](https://nygen-labs-prod--cytetype-api.modal.run/report/6d248cd2-6b61-4beb-bc58-1d63c7a2fc34) - [H5ad](https://drive.google.com/file/d/19qpRfz4WGuUsRNl0YKuy3YENfHKI6pz-/view?usp=drive_link) |
14-
| **Diabetic Kidney Disease** | [Colab](https://colab.research.google.com/drive/1kb3urFbl0PEPW4T_ti0DBTAmi5YK_-t1?usp=sharing) - [CyteType Report](https://nygen-labs-prod--cytetype-api.modal.run/report/0da4eaef-f165-4800-a4e3-c5cf8ec165ad) - [H5ad](https://drive.google.com/file/d/1yZXYlfZHLYcPL18Jy25J4v8kWQYhSsd7/view?usp=drive_link) |
8+
| **Tabula Sapiens** | [Colab](https://colab.research.google.com/drive/1EyQXaruDJBPICUvlUY1E19zxOm_L4_VU?usp=sharing) - [CyteType Report](https://prod.cytetype.nygen.io/report/15332f10-2048-4099-ab1e-baf2ab9e39c3) - [H5ad](https://drive.google.com/file/d/1URo7niPqAo-9HGVH8f3QJfqll9lc8JN_/view?usp=drive_link) |
9+
| **GTEX v9** | [Colab](https://colab.research.google.com/drive/1uvqG2eVaUuNe66e0_7bp682uCdKx6-KL?usp=sharing) - [CyteType Report](https://prod.cytetype.nygen.io/report/5242f3b8-0078-417d-954e-00d1bb19bdf6) - [H5ad](https://drive.google.com/file/d/1EIpudRyasLUHR6J2v8fdpmBTbCE2__UF/view?usp=drive_link) |
10+
| **Hypomap** | [Colab](https://colab.research.google.com/drive/1OuTnh8xHoXaINCGcgu_1q-jANwXL8ggF?usp=sharing) - [CyteType Report](https://prod.cytetype.nygen.io/report/3840b662-bacf-4067-b93d-4e57c1f21187) - [H5ad](https://drive.google.com/file/d/1QMvZNdoDlKpOmyguAXSk45-YVz97v4tM/view?usp=drive_link) |
11+
| **Human Lung Cell Atlas (Core)** | [Colab](https://colab.research.google.com/drive/1FoTD-XzLNDPgYSlgVsxnLwPnWF5YiKny?usp=sharing) - [CyteType Report](https://prod.cytetype.nygen.io/report/6da1458a-392f-4bce-b6c9-4ccb308c8797) - [H5ad](https://drive.google.com/file/d/13O0dyUnwJKLPm8fncRt597S5hs2COsxx/view?usp=drive_link) |
12+
| **Immune Cell Atlas** | [Colab](https://colab.research.google.com/drive/1Kum9S_kU76QvS__42ABd-Xp1GpH4c9jU?usp=sharing) - [CyteType Report](https://prod.cytetype.nygen.io/report/05ff7629-8f0c-4b95-ac65-30bba9b384c5) - [H5ad](https://drive.google.com/file/d/1iqkC7dG1ovgKsU_8HdZ2eyELIxB0sM3t/view?usp=drive_link) |
13+
| **Mouse Pancreatic Cell Atlas** | [Colab](https://colab.research.google.com/drive/1fg9W3Lz-E_yAVoqs_6XrQsYkfsfnzFey?usp=sharing) - [CyteType Report](https://prod.cytetype.nygen.io/report/6d248cd2-6b61-4beb-bc58-1d63c7a2fc34) - [H5ad](https://drive.google.com/file/d/19qpRfz4WGuUsRNl0YKuy3YENfHKI6pz-/view?usp=drive_link) |
14+
| **Diabetic Kidney Disease** | [Colab](https://colab.research.google.com/drive/1kb3urFbl0PEPW4T_ti0DBTAmi5YK_-t1?usp=sharing) - [CyteType Report](https://prod.cytetype.nygen.io/report/0da4eaef-f165-4800-a4e3-c5cf8ec165ad) - [H5ad](https://drive.google.com/file/d/1yZXYlfZHLYcPL18Jy25J4v8kWQYhSsd7/view?usp=drive_link) |
1515

1616
## CellHint Organ Atlases
1717

@@ -20,22 +20,22 @@ Data was annotated in across three notebooks: [Colab 1/3](https://colab.research
2020

2121
| Tissue | Links |
2222
| --- | --- |
23-
| **Blood** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/d0c219b4-2b4a-4b27-bac9-aea280a972f1) |
24-
| **Bone Marrow** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/bc5099b5-42c2-4ba7-8fdd-bc7b5dd3e84d) |
25-
| **Heart** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/2ffd6cf1-ec98-43d1-82d7-1fc3e9a11b8c) |
26-
| **Hippocampus** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/60b98429-2338-4408-a07c-bb60e82ac793) |
27-
| **Intestine** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/e0a2ca37-872f-489c-8de1-d84434d409fe) |
28-
| **Kidney** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/7dd1f0ea-7eec-4968-b353-8b52707de5ac) |
29-
| **Liver** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/a429348c-530a-486c-8980-3349a583b8c4) |
30-
| **Lung** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/75e41a21-f771-4ebc-829a-82f93529a147) |
31-
| **Lymph Node** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/b911e212-fe37-4bdc-a7f3-51e9146bf8cc) |
32-
| **Pancreas** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/b620245a-1ae0-4025-aab7-52ada6dcc6cb) |
33-
| **Skeletal Muscle** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/3f35a45d-aa1b-42cb-92d2-e739623a402b) |
34-
| **Spleen** | [CyteType report](https://nygen-labs-prod--cytetype-api.modal.run/report/4b64ec02-ac01-45b5-84b9-0f16708cbd85) |
23+
| **Blood** | [CyteType report](https://prod.cytetype.nygen.io/report/d0c219b4-2b4a-4b27-bac9-aea280a972f1) |
24+
| **Bone Marrow** | [CyteType report](https://prod.cytetype.nygen.io/report/bc5099b5-42c2-4ba7-8fdd-bc7b5dd3e84d) |
25+
| **Heart** | [CyteType report](https://prod.cytetype.nygen.io/report/2ffd6cf1-ec98-43d1-82d7-1fc3e9a11b8c) |
26+
| **Hippocampus** | [CyteType report](https://prod.cytetype.nygen.io/report/60b98429-2338-4408-a07c-bb60e82ac793) |
27+
| **Intestine** | [CyteType report](https://prod.cytetype.nygen.io/report/e0a2ca37-872f-489c-8de1-d84434d409fe) |
28+
| **Kidney** | [CyteType report](https://prod.cytetype.nygen.io/report/7dd1f0ea-7eec-4968-b353-8b52707de5ac) |
29+
| **Liver** | [CyteType report](https://prod.cytetype.nygen.io/report/a429348c-530a-486c-8980-3349a583b8c4) |
30+
| **Lung** | [CyteType report](https://prod.cytetype.nygen.io/report/75e41a21-f771-4ebc-829a-82f93529a147) |
31+
| **Lymph Node** | [CyteType report](https://prod.cytetype.nygen.io/report/b911e212-fe37-4bdc-a7f3-51e9146bf8cc) |
32+
| **Pancreas** | [CyteType report](https://prod.cytetype.nygen.io/report/b620245a-1ae0-4025-aab7-52ada6dcc6cb) |
33+
| **Skeletal Muscle** | [CyteType report](https://prod.cytetype.nygen.io/report/3f35a45d-aa1b-42cb-92d2-e739623a402b) |
34+
| **Spleen** | [CyteType report](https://prod.cytetype.nygen.io/report/4b64ec02-ac01-45b5-84b9-0f16708cbd85) |
3535

3636
## Cell Landscapes from BIS
3737
Cell atlases hosted by [BIS](https://bis.zju.edu.cn/) from various organims and specific tissues
3838

3939
| Tissue | Links |
4040
| --- | --- |
41-
| Human Cell Landscape | [Colab](https://colab.research.google.com/drive/1czLW33FYbnPOmPvnfddsvehXM491UDGq?usp=sharing) - [CyteType Report](https://nygen-labs-prod--cytetype-api.modal.run/report/581616bf-3c96-4e58-a290-881b40378309) - [Homepage](https://bis.zju.edu.cn/HCL/) |
41+
| Human Cell Landscape | [Colab](https://colab.research.google.com/drive/1czLW33FYbnPOmPvnfddsvehXM491UDGq?usp=sharing) - [CyteType Report](https://prod.cytetype.nygen.io/report/581616bf-3c96-4e58-a290-881b40378309) - [Homepage](https://bis.zju.edu.cn/HCL/) |

tests/test_main.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,19 @@ def test_cytetype_success(
9393
"clusterId": "1",
9494
"annotation": "Cell Type A",
9595
"ontologyTerm": "CL:0000001",
96+
"ontologyTermID": "CL:0000001",
9697
}, # Corresponds to '0'
9798
{
9899
"clusterId": "2",
99100
"annotation": "Cell Type B",
100101
"ontologyTerm": "CL:0000002",
102+
"ontologyTermID": "CL:0000002",
101103
}, # Corresponds to '1'
102104
{
103105
"clusterId": "3",
104106
"annotation": "Cell Type C",
105107
"ontologyTerm": "CL:0000003",
108+
"ontologyTermID": "CL:0000003",
106109
}, # Corresponds to '2'
107110
]
108111
}
@@ -265,16 +268,19 @@ def test_cytetype_with_auth_token(
265268
"clusterId": "1",
266269
"annotation": "Cell Type A",
267270
"ontologyTerm": "CL:0000001",
271+
"ontologyTermID": "CL:0000001",
268272
},
269273
{
270274
"clusterId": "2",
271275
"annotation": "Cell Type B",
272276
"ontologyTerm": "CL:0000002",
277+
"ontologyTermID": "CL:0000002",
273278
},
274279
{
275280
"clusterId": "3",
276281
"annotation": "Cell Type C",
277282
"ontologyTerm": "CL:0000003",
283+
"ontologyTermID": "CL:0000003",
278284
},
279285
]
280286
}
@@ -312,6 +318,7 @@ def test_cytetype_get_results_helper(
312318
"clusterId": "1",
313319
"annotation": "Cell Type A",
314320
"ontologyTerm": "CL:0000001",
321+
"ontologyTermID": "CL:0000001",
315322
},
316323
]
317324
}
@@ -362,6 +369,7 @@ def test_cytetype_with_metadata(
362369
"clusterId": "1",
363370
"annotation": "Cell Type A",
364371
"ontologyTerm": "CL:0000001",
372+
"ontologyTermID": "CL:0000001",
365373
},
366374
]
367375
}
@@ -407,6 +415,7 @@ def test_cytetype_without_metadata(
407415
"clusterId": "1",
408416
"annotation": "Cell Type A",
409417
"ontologyTerm": "CL:0000001",
418+
"ontologyTermID": "CL:0000001",
410419
},
411420
]
412421
}
@@ -421,6 +430,113 @@ def test_cytetype_without_metadata(
421430
assert "metadata" not in query_arg
422431

423432

433+
@patch("cytetype.main.submit_job")
434+
@patch("cytetype.main.poll_for_results")
435+
def test_cytetype_obs_columns(
436+
mock_poll: MagicMock, mock_submit: MagicMock, mock_adata: anndata.AnnData
437+
) -> None:
438+
"""Test that all expected obs columns are created with correct names and values."""
439+
job_id = "mock_job_obs_columns"
440+
mock_submit.return_value = job_id
441+
mock_result: dict[str, list[dict[str, str]]] = {
442+
"annotations": [
443+
{
444+
"clusterId": "1",
445+
"annotation": "T cell",
446+
"ontologyTerm": "T cell",
447+
"ontologyTermID": "CL:0000084",
448+
"cellState": "activated",
449+
},
450+
{
451+
"clusterId": "2",
452+
"annotation": "B cell",
453+
"ontologyTerm": "B cell",
454+
"ontologyTermID": "CL:0000236",
455+
"cellState": "naive",
456+
},
457+
{
458+
"clusterId": "3",
459+
"annotation": "Monocyte",
460+
"ontologyTerm": "monocyte",
461+
"ontologyTermID": "CL:0000576",
462+
"cellState": "", # Empty cell state
463+
},
464+
]
465+
}
466+
mock_poll.return_value = mock_result
467+
468+
group_key = "leiden"
469+
results_prefix = "cytetype"
470+
471+
cytetype = CyteType(mock_adata, group_key=group_key)
472+
adata_result = cytetype.run(study_context="Test study context")
473+
474+
# Check all expected obs columns exist
475+
expected_columns = [
476+
f"{results_prefix}_annotation_{group_key}",
477+
f"{results_prefix}_cellOntologyTerm_{group_key}",
478+
f"{results_prefix}_cellOntologyTermID_{group_key}",
479+
f"{results_prefix}_cellState_{group_key}",
480+
]
481+
482+
for col in expected_columns:
483+
assert col in adata_result.obs, f"Column {col} not found in obs"
484+
assert isinstance(adata_result.obs[col].dtype, pd.CategoricalDtype), (
485+
f"Column {col} is not categorical"
486+
)
487+
488+
# Check annotation values are correctly mapped
489+
anno_col = f"{results_prefix}_annotation_{group_key}"
490+
ct_map = {"0": "1", "1": "2", "2": "3"} # cluster label -> cluster ID mapping
491+
anno_map = {"1": "T cell", "2": "B cell", "3": "Monocyte"}
492+
expected_annotations = [
493+
anno_map[ct_map[str(label)]] for label in mock_adata.obs[group_key]
494+
]
495+
pd.testing.assert_series_equal(
496+
adata_result.obs[anno_col],
497+
pd.Series(expected_annotations, index=mock_adata.obs.index, dtype="category"),
498+
check_names=False,
499+
)
500+
501+
# Check ontologyTerm values are correctly mapped
502+
ontology_term_col = f"{results_prefix}_cellOntologyTerm_{group_key}"
503+
ontology_term_map = {"1": "T cell", "2": "B cell", "3": "monocyte"}
504+
expected_ontology_terms = [
505+
ontology_term_map[ct_map[str(label)]] for label in mock_adata.obs[group_key]
506+
]
507+
pd.testing.assert_series_equal(
508+
adata_result.obs[ontology_term_col],
509+
pd.Series(
510+
expected_ontology_terms, index=mock_adata.obs.index, dtype="category"
511+
),
512+
check_names=False,
513+
)
514+
515+
# Check ontologyTermID values are correctly mapped
516+
ontology_id_col = f"{results_prefix}_cellOntologyTermID_{group_key}"
517+
ontology_id_map = {"1": "CL:0000084", "2": "CL:0000236", "3": "CL:0000576"}
518+
expected_ontology_ids = [
519+
ontology_id_map[ct_map[str(label)]] for label in mock_adata.obs[group_key]
520+
]
521+
pd.testing.assert_series_equal(
522+
adata_result.obs[ontology_id_col],
523+
pd.Series(expected_ontology_ids, index=mock_adata.obs.index, dtype="category"),
524+
check_names=False,
525+
)
526+
527+
# Check cellState values are correctly mapped (including empty string)
528+
cell_state_col = f"{results_prefix}_cellState_{group_key}"
529+
cell_state_map = {"1": "activated", "2": "naive", "3": ""}
530+
expected_cell_states = [
531+
cell_state_map[ct_map[str(label)]] for label in mock_adata.obs[group_key]
532+
]
533+
pd.testing.assert_series_equal(
534+
adata_result.obs[cell_state_col],
535+
pd.Series(expected_cell_states, index=mock_adata.obs.index, dtype="category"),
536+
check_names=False,
537+
)
538+
539+
424540
# --- TODO ---
425541
# - Add tests specifically for cytetype/anndata_helpers.py
426542
# - Add tests specifically for cytetype/client.py (e.g., more nuanced API responses)

0 commit comments

Comments
 (0)