clacell 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
1
+ # Other Github Repos
2
+ python_marker_based_annotation
3
+ scumi-dev
4
+ # pixi environments
5
+ .pixi/*
6
+ !.pixi/config.toml
7
+ # data
8
+ data/*
9
+ blood.tar.gz
10
+ # trained models
11
+ evaluation/models/*
12
+ models/*
13
+ training/models/*
14
+ training/results/*.pkl
15
+ # pycache
16
+ evaluation/__pycache__/*
17
+ clacell/__pycache__/*
18
+ clacell/_marker_based_annotation/__pycache__/*
19
+ training/__pycache__/*
20
+ # Latex compile files
21
+ Paper/main.*
22
+ # Include main.tex
23
+ !Paper/main.tex
24
+ # checkpoints
25
+ */.ipynb_checkpoints/*
26
+ *.pkl
27
+ pypi_token.md
clacell-0.1.0/LICENSE ADDED
@@ -0,0 +1,39 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Julian Kraus
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ Third-Party Components:
26
+ The marker-based annotation module contains code adapted or translated from scumi-dev, which is licensed under the BSD 3-Clause License:
27
+
28
+ Copyright (c) 2019 The Broad Institute, Inc.
29
+ All Rights Reserved.
30
+
31
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
32
+
33
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
34
+
35
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
36
+
37
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
38
+
39
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
clacell-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,77 @@
1
+ Metadata-Version: 2.4
2
+ Name: clacell
3
+ Version: 0.1.0
4
+ Summary: robust cell type classifier for immune cells
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.13
8
+ Requires-Dist: anndata>=0.12.16
9
+ Requires-Dist: numpy>=2.4.6
10
+ Requires-Dist: pandas>=2.3.3
11
+ Requires-Dist: scanpy>=1.12.1
12
+ Requires-Dist: scikit-learn>=1.8.0
13
+ Requires-Dist: scipy>=1.17.1
14
+ Description-Content-Type: text/markdown
15
+
16
+ # CLACELL
17
+
18
+ Robust cell type classifier for immune cells
19
+
20
+ ## Usage
21
+
22
+ ### MarkerAnnotator
23
+
24
+ The MarkerAnnotator can be used to annotate an Anndata dataset. It uses a marker based annotation strategy to annotate the dataset. You can either use an own marker dictionary or use the default dictionary.
25
+
26
+ ```py
27
+ from clacell import MarkerAnnotator
28
+
29
+ annotator = MarkerAnnotator(marker_dict=marker_dict)
30
+ adata = annotator.annotate(adata)
31
+ # Now adata.obs['scumi-annotation'] contains the annotations
32
+ ```
33
+
34
+ ### BloodCellClassifier
35
+
36
+ The cell type classifier has four different methods:
37
+ 1. **grid_search**: Makes a search over the hyperparameters of the model, evaluates the best model and retrains it on the whole dataset using 'train'.
38
+ 2. **train**: Trains the model with the given hyperparameters.
39
+ 3. **evaluate**: Evaluates the current model with robustness tests. The model needs to be trained before this method is called.
40
+ 4. **predict**: Predicts new samples. The model needs to be trained before this method is called.
41
+
42
+ All methods can be called with Dataframes or with an Anndata object. If an Anndata object is provided, it will be automatically preprocessed.
43
+
44
+ ```py
45
+ from clacell import BloodCellClassifier
46
+
47
+ classifier = BloodCellClassifier()
48
+
49
+ # 1. GridSearch
50
+ print("\n1. grid_search")
51
+ classifier.grid_search(X_train, y_train, X_test, y_test, n_jobs=3)
52
+
53
+ # 2. Train
54
+ print("\n2. train")
55
+ classifier.train(X_train, y_train, C=0.001)
56
+
57
+ # 3. Evaluate
58
+ print("\n3. evaluate")
59
+ classifier.evaluate(X_test, y_test)
60
+
61
+ # 4. Predict
62
+ print("\n4. predict")
63
+ predictions = classifier.predict(X_test)
64
+ print(f"Macro F1: {f1_score(y_test, predictions, average="macro")}")
65
+ ```
66
+
67
+
68
+ ## Acknowledgments & Data Sources
69
+
70
+ The marker based annotation strategy is a reimplementation of the existing R package scumi-dev (licensed under BSD 3-Clause License). Link to the repository: https://bitbucket.org/jerry00/scumi-dev/src/master/
71
+ - **Citation:** Ding, J., Adiconis, X., Simmons, S.K. et al. Systematic comparison of single-cell and single-nucleus RNA-sequencing methods. Nat Biotechnol 38, 737–746 (2020). https://doi.org/10.1038/s41587-020-0465-8
72
+
73
+ This repository contains reference datasets used for training and validation:
74
+ - **CellTypist:** The Cross-tissue Immune Cell Atlas was provided by the **Teichmann Group at the Wellcome Sanger Institute** and were hosted by **Genome Research Limited** (licensed under CC BY-NC-ND 4.0). Link: https://www.tissueimmunecellatlas.org/
75
+ - **Citation:** C. Domínguez Conde et al., Cross-tissue immune cell analysis reveals tissue-specific features in humans. Science376, eabl5197(2022).DOI: [10.1126/science.abl5197](https://doi.org/10.1126/science.abl5197)
76
+ - **Human Cell Atlas (HCA):** HematopoieticImmuneCellAtlas (licensed under CC-BY 4.0). Project Link: https://explore.data.humancellatlas.org/projects/cc95ff89-2e68-4a08-a234-480eca21ce79
77
+ - **Citation:** Li, B., Kowalczyk, M.S. et al. Hematopoietic Immune Cell Atlas. *Human Cell Atlas Data Portal* (2026).
@@ -0,0 +1,62 @@
1
+ # CLACELL
2
+
3
+ Robust cell type classifier for immune cells
4
+
5
+ ## Usage
6
+
7
+ ### MarkerAnnotator
8
+
9
+ The MarkerAnnotator can be used to annotate an Anndata dataset. It uses a marker based annotation strategy to annotate the dataset. You can either use an own marker dictionary or use the default dictionary.
10
+
11
+ ```py
12
+ from clacell import MarkerAnnotator
13
+
14
+ annotator = MarkerAnnotator(marker_dict=marker_dict)
15
+ adata = annotator.annotate(adata)
16
+ # Now adata.obs['scumi-annotation'] contains the annotations
17
+ ```
18
+
19
+ ### BloodCellClassifier
20
+
21
+ The cell type classifier has four different methods:
22
+ 1. **grid_search**: Makes a search over the hyperparameters of the model, evaluates the best model and retrains it on the whole dataset using 'train'.
23
+ 2. **train**: Trains the model with the given hyperparameters.
24
+ 3. **evaluate**: Evaluates the current model with robustness tests. The model needs to be trained before this method is called.
25
+ 4. **predict**: Predicts new samples. The model needs to be trained before this method is called.
26
+
27
+ All methods can be called with Dataframes or with an Anndata object. If an Anndata object is provided, it will be automatically preprocessed.
28
+
29
+ ```py
30
+ from clacell import BloodCellClassifier
31
+
32
+ classifier = BloodCellClassifier()
33
+
34
+ # 1. GridSearch
35
+ print("\n1. grid_search")
36
+ classifier.grid_search(X_train, y_train, X_test, y_test, n_jobs=3)
37
+
38
+ # 2. Train
39
+ print("\n2. train")
40
+ classifier.train(X_train, y_train, C=0.001)
41
+
42
+ # 3. Evaluate
43
+ print("\n3. evaluate")
44
+ classifier.evaluate(X_test, y_test)
45
+
46
+ # 4. Predict
47
+ print("\n4. predict")
48
+ predictions = classifier.predict(X_test)
49
+ print(f"Macro F1: {f1_score(y_test, predictions, average="macro")}")
50
+ ```
51
+
52
+
53
+ ## Acknowledgments & Data Sources
54
+
55
+ The marker based annotation strategy is a reimplementation of the existing R package scumi-dev (licensed under BSD 3-Clause License). Link to the repository: https://bitbucket.org/jerry00/scumi-dev/src/master/
56
+ - **Citation:** Ding, J., Adiconis, X., Simmons, S.K. et al. Systematic comparison of single-cell and single-nucleus RNA-sequencing methods. Nat Biotechnol 38, 737–746 (2020). https://doi.org/10.1038/s41587-020-0465-8
57
+
58
+ This repository contains reference datasets used for training and validation:
59
+ - **CellTypist:** The Cross-tissue Immune Cell Atlas was provided by the **Teichmann Group at the Wellcome Sanger Institute** and were hosted by **Genome Research Limited** (licensed under CC BY-NC-ND 4.0). Link: https://www.tissueimmunecellatlas.org/
60
+ - **Citation:** C. Domínguez Conde et al., Cross-tissue immune cell analysis reveals tissue-specific features in humans. Science376, eabl5197(2022).DOI: [10.1126/science.abl5197](https://doi.org/10.1126/science.abl5197)
61
+ - **Human Cell Atlas (HCA):** HematopoieticImmuneCellAtlas (licensed under CC-BY 4.0). Project Link: https://explore.data.humancellatlas.org/projects/cc95ff89-2e68-4a08-a234-480eca21ce79
62
+ - **Citation:** Li, B., Kowalczyk, M.S. et al. Hematopoietic Immune Cell Atlas. *Human Cell Atlas Data Portal* (2026).
@@ -0,0 +1,4 @@
1
+ from .classifier import BloodCellClassifier
2
+ from .marker_annotator import MarkerAnnotator
3
+
4
+ __all__ = ["BloodCellClassifier", "MarkerAnnotator"]
@@ -0,0 +1,10 @@
1
+ from .clustering import cluster_scanpy
2
+ from .markers import calculate_auc, compute_cluster_auc
3
+ from .model_selection import select_cluster_model
4
+
5
+ __all__ = [
6
+ "calculate_auc",
7
+ "cluster_scanpy",
8
+ "compute_cluster_auc",
9
+ "select_cluster_model",
10
+ ]
@@ -0,0 +1,73 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+
7
+ import pandas as pd
8
+
9
+ from .io import read_count_matrix, read_markers
10
+ from .model_selection import select_cluster_model
11
+
12
+
13
+ def _build_parser() -> argparse.ArgumentParser:
14
+ p = argparse.ArgumentParser(description="Marker-based annotation pipeline")
15
+ p.add_argument(
16
+ "--matrix", required=True, help="Gene x cell count matrix CSV (index=gene)"
17
+ )
18
+ p.add_argument("--markers", required=True, help="Markers as JSON or CSV/TSV")
19
+ p.add_argument("--outdir", required=True, help="Output directory")
20
+ p.add_argument("--species", default="human", choices=["human", "mouse"])
21
+ p.add_argument("--min-cluster", type=int, default=3)
22
+ p.add_argument("--max-cluster", type=int, default=20)
23
+ p.add_argument("--seed", type=int, default=0)
24
+ return p
25
+
26
+
27
+ def main() -> None:
28
+ args = _build_parser().parse_args()
29
+
30
+ matrix = read_count_matrix(args.matrix)
31
+ markers = read_markers(args.markers)
32
+
33
+ result = select_cluster_model(
34
+ matrix,
35
+ markers,
36
+ min_cluster=args.min_cluster,
37
+ max_cluster=args.max_cluster,
38
+ species=args.species,
39
+ random_state=args.seed,
40
+ )
41
+
42
+ outdir = Path(args.outdir)
43
+ outdir.mkdir(parents=True, exist_ok=True)
44
+
45
+ params_file = outdir / "best_params.json"
46
+ with params_file.open("w", encoding="utf-8") as f:
47
+ json.dump(result.params_final, f, indent=2)
48
+
49
+ auc_file = outdir / "final_auc.json"
50
+ with auc_file.open("w", encoding="utf-8") as f:
51
+ json.dump(result.auc_final, f, indent=2)
52
+
53
+ clusters = result.model_final.clusters.rename("cluster")
54
+ cluster_labels = pd.DataFrame({"cell": clusters.index, "cluster": clusters.values})
55
+ cluster_labels.to_csv(outdir / "clusters.csv", index=False)
56
+
57
+ labels = pd.DataFrame(
58
+ {
59
+ "cell": result.label_final.index,
60
+ "cell_type_label": result.label_final.values,
61
+ }
62
+ )
63
+ labels.to_csv(outdir / "cell_type_labels.csv", index=False)
64
+
65
+ result.auc_table.to_csv(outdir / "model_grid_auc.csv", index=False)
66
+ result.silhouette_table.to_csv(outdir / "model_grid_silhouette.csv", index=False)
67
+ result.cluster_table.to_csv(outdir / "model_grid_cluster_counts.csv", index=False)
68
+
69
+ print(f"Done. Results written to: {outdir}")
70
+
71
+
72
+ if __name__ == "__main__":
73
+ main()
@@ -0,0 +1,121 @@
1
+ from __future__ import annotations
2
+
3
+ import anndata as ad
4
+ import numpy as np
5
+ import pandas as pd
6
+ import scanpy as sc
7
+
8
+ from .types import ClusterResult
9
+
10
+
11
+ def _to_anndata(umi_count: pd.DataFrame) -> ad.AnnData:
12
+ if not isinstance(umi_count, pd.DataFrame):
13
+ raise TypeError(
14
+ "umi_count must be a pandas DataFrame with genes as index and cells as columns"
15
+ )
16
+ adata = ad.AnnData(X=umi_count.T.copy())
17
+ adata.var_names = umi_count.index.astype(str)
18
+ adata.obs_names = umi_count.columns.astype(str)
19
+ return adata
20
+
21
+
22
+ def cluster_scanpy(
23
+ umi_count: pd.DataFrame,
24
+ number_neighbor: int = 30,
25
+ variable_gene: bool = False,
26
+ resolution: float = 1.0,
27
+ num_pc: int = 50,
28
+ species: str = "human",
29
+ normalize: bool = True,
30
+ min_cells: int = 3,
31
+ min_genes: int = 1,
32
+ random_state: int = 0,
33
+ ) -> ClusterResult:
34
+ adata = _to_anndata(umi_count)
35
+
36
+ sc.pp.filter_cells(adata, min_genes=min_genes)
37
+ sc.pp.filter_genes(adata, min_cells=min_cells)
38
+
39
+ if species == "human":
40
+ adata.var["mito"] = adata.var_names.str.startswith("MT-")
41
+ elif species == "mouse":
42
+ adata.var["mito"] = adata.var_names.str.startswith("mt-")
43
+ else:
44
+ raise ValueError("species must be 'human' or 'mouse'")
45
+
46
+ sc.pp.calculate_qc_metrics(
47
+ adata, qc_vars=["mito"], percent_top=None, log1p=False, inplace=True
48
+ )
49
+
50
+ if normalize:
51
+ sc.pp.normalize_total(adata, target_sum=10000)
52
+ sc.pp.log1p(adata)
53
+ else:
54
+ adata.X = np.log1p(adata.X)
55
+
56
+ if variable_gene:
57
+ sc.pp.highly_variable_genes(adata, min_mean=0.0125, max_mean=3, min_disp=0.5)
58
+ hvg_mask = adata.var["highly_variable"].to_numpy()
59
+ if int(hvg_mask.sum()) == 0:
60
+ adata_use = adata.copy()
61
+ else:
62
+ adata_use = adata[:, hvg_mask].copy()
63
+ else:
64
+ if species == "human":
65
+ mt_rb = adata.var_names.str.contains(
66
+ r"^MT-|^RPL|^RPS|^MRPS|^MRPL", regex=True
67
+ )
68
+ else:
69
+ mt_rb = adata.var_names.str.contains(
70
+ r"^mt-|^Rpl|^Rps|^Mrps|^Mrpl", regex=True
71
+ )
72
+ adata_use = adata[:, ~mt_rb].copy()
73
+
74
+ if adata_use.n_vars == 0:
75
+ adata_use = adata.copy()
76
+
77
+ sc.pp.scale(adata_use)
78
+
79
+ n_pc_eff = min(num_pc, adata_use.n_vars - 1, adata_use.n_obs - 1)
80
+ n_pc_eff = max(n_pc_eff, 2)
81
+
82
+ sc.tl.pca(
83
+ adata_use,
84
+ n_comps=n_pc_eff,
85
+ random_state=random_state,
86
+ mask_var=None,
87
+ )
88
+ sc.pp.neighbors(
89
+ adata_use,
90
+ n_neighbors=number_neighbor,
91
+ n_pcs=n_pc_eff,
92
+ random_state=random_state,
93
+ )
94
+ sc.tl.leiden(
95
+ adata_use,
96
+ resolution=resolution,
97
+ random_state=random_state,
98
+ key_added="cluster",
99
+ flavor="igraph",
100
+ n_iterations=2,
101
+ directed=False,
102
+ )
103
+ sc.tl.tsne(adata_use, n_pcs=n_pc_eff, random_state=random_state)
104
+
105
+ adata.obsm["X_pca"] = adata_use.obsm["X_pca"]
106
+ adata.obsm["X_tsne"] = adata_use.obsm["X_tsne"]
107
+ adata.obs["cluster"] = adata_use.obs["cluster"].astype(str)
108
+
109
+ params = {
110
+ "number_neighbor": number_neighbor,
111
+ "variable_gene": variable_gene,
112
+ "resolution": resolution,
113
+ "num_pc": num_pc,
114
+ "normalize": normalize,
115
+ "min_cells": min_cells,
116
+ "min_genes": min_genes,
117
+ "species": species,
118
+ }
119
+ return ClusterResult(
120
+ adata=adata, clusters=adata.obs["cluster"].copy(), params=params
121
+ )
@@ -0,0 +1 @@
1
+ {"CD4+ T cell":["CD3D+","CD3E+","CD3G+","TRAC+","CD4+","TCF7+","CD27+","IL7R+","CD8A-","CD8B-","GNLY-","NKG7-","CST7-"],"Cytotoxic T cell":["CD3D+","CD3E+","CD3G+","TRAC+","CD8A+","CD8B+","GZMK+","CCL5+","NKG7+","CD4-","FCER1G-"],"B cell":["CD19+","MS4A1+","CD79A+","CD79B+","MZB1+","IGHD+","IGHM+"],"Natural killer cell":["NCAM1+","NKG7+","KLRB1+","KLRD1+","KLRF1+","KLRC1+","KLRC2+","KLRC3+","KLRC4+","CD3D-","CD3E-","CD3G-","CD14-","FCGR3A+","FCGR3B+","ITGAL+","ITGAM+","FCER1G+","TRAC-"],"CD14+ monocyte":["VCAN+","FCN1+","S100A8+","S100A9+","CD14+","ITGAL+","ITGAM+","CSF3R+","CSF1R+","CX3CR1+","FCGR3A-","FCGR3B-","TYROBP+","LYZ+","S100A12+","CD3D-","CD3E-","CD3G-","TRAC-","NKG7-","KLRB1-","KLRD1-"],"CD16+ monocyte":["FCN1+","FCGR3A+","FCGR3B+","ITGAL+","ITGAM+","CSF3R+","CSF1R+","CX3CR1+","CDKN1C+","MS4A7+","S100A8-","S100A9-","S100A12-","CD14-","CD3D-","CD3E-","CD3G-","TRAC-","NKG7-","KLRB1-","KLRD1-"],"Dendritic cell":["HLA-DPB1+","HLA-DPA1+","HLA-DQA1+","ITGAX+","CD3D-","CD3E-","CD3G-","NCAM1-","CD19-","CD14-","CD1C+","CD1E+","FCER1A+","CLEC10A+","FCGR2B+","MS4A1-","CD79A-","CD79B-"],"Plasmacytoid dendritic cell":["IL3RA+","GZMB+","JCHAIN+","IRF7+","TCF4+","LILRA4+","CLEC4C+","ITGAX-","CD3D-","CD3E-","CD3G-","NCAM1-","CD19-","CD14-","MS4A1-","CD79A-","CD79B-"],"Plasma cell":["CD38+","XBP1+","CD27+","SLAMF7+","CD19-","MS4A1-","CD3D-","CD3E-","CD3G-","IGHA1+","IGHA2+","IGHG1+","IGHG2+","IGHG3+","IGHG4+"],"Megakaryocyte":["PF4+","PPBP+","GP5+","ITGA2B+","NRGN+","TUBB1+","SPARC+","RGS18+","MYL9+","GNG11+"]}
@@ -0,0 +1,34 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from pathlib import Path
5
+
6
+ import pandas as pd
7
+
8
+ from .types import MarkerDict
9
+
10
+
11
+ def read_count_matrix(path: str | Path) -> pd.DataFrame:
12
+ matrix = pd.read_csv(path, index_col=0)
13
+ return matrix
14
+
15
+
16
+ def read_markers(path: str | Path) -> MarkerDict:
17
+ p = Path(path)
18
+ if p.suffix.lower() == ".json":
19
+ with p.open("r", encoding="utf-8") as f:
20
+ obj = json.load(f)
21
+ return {str(k): [str(x) for x in v] for k, v in obj.items()}
22
+
23
+ if p.suffix.lower() in {".csv", ".tsv"}:
24
+ sep = "\t" if p.suffix.lower() == ".tsv" else ","
25
+ df = pd.read_csv(p, sep=sep)
26
+ required = {"cell_type", "marker"}
27
+ if not required.issubset(set(df.columns)):
28
+ raise ValueError("Marker table must contain columns: cell_type, marker")
29
+ out: MarkerDict = {}
30
+ for ct, grp in df.groupby("cell_type"):
31
+ out[str(ct)] = [str(x) for x in grp["marker"].tolist()]
32
+ return out
33
+
34
+ raise ValueError("Unsupported marker format. Use .json, .csv, or .tsv")