annotuneagent 0.1.8__tar.gz → 0.1.9__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.
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/.github/workflows/tests.yml +2 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/CHANGELOG.md +17 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/CITATION.cff +2 -2
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/PKG-INFO +4 -3
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/README.md +2 -2
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/api/index.md +8 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/conf.py +2 -2
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/installation.md +1 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/quickstart.md +1 -2
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/tutorials/gse266598_annotation.ipynb +0 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/tutorials/load_model.ipynb +1 -2
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/tutorials/pbmc8k_annotation.ipynb +0 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/pyproject.toml +7 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/__init__.py +0 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/_version.py +1 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/annotate.py +2 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/arbitrate.py +1 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/cli.py +32 -36
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/decide.py +14 -192
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/evaluate.py +1 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/evidence.py +3 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/geo.py +17 -10
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/local_lora.py +19 -13
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/marker_plot.py +20 -3
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/markers.py +6 -5
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/prepare.py +16 -9
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/read.py +4 -1
- annotuneagent-0.1.9/src/annotuneagent/workflow/__init__.py +512 -0
- annotuneagent-0.1.9/src/annotuneagent/workflow/models.py +404 -0
- annotuneagent-0.1.9/src/annotuneagent/workflow/neighbors.py +569 -0
- annotuneagent-0.1.9/src/annotuneagent/workflow/reporting.py +511 -0
- annotuneagent-0.1.9/src/annotuneagent/workflow/rules.py +1096 -0
- annotuneagent-0.1.9/src/annotuneagent/workflow/subcluster.py +522 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent.egg-info/SOURCES.txt +6 -1
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_bugfixes_1111.py +5 -12
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_cli.py +73 -9
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_decide.py +4 -57
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_geo.py +8 -6
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_version.py +2 -2
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_workflow.py +11 -14
- annotuneagent-0.1.8/src/annotuneagent/workflow.py +0 -3343
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/.github/workflows/downloads-badge.yml +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/.github/workflows/publish.yml +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/.gitignore +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/.readthedocs.yaml +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/LICENSE +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/MANIFEST.in +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/SECURITY.md +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/_static/css/custom.css +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/_templates/README.md +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/index.md +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/marker_sources.md +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/requirements.txt +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/tutorials/index.md +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/docs/tutorials/report.md +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/setup.cfg +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/__main__.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/granularity/__init__.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/granularity/cl_dag.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/granularity/ontology_map.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/granularity/relations.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/hypotheses.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/markers.tsv +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/mltools.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/ontology/cl_isa.json +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/ontology/granularity_policy.yaml +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/ontology/ontology_map.jsonl +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/py.typed +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/tokenizer/LICENSE +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/tokenizer/merges.txt +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/tokenizer/tokenizer.json +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/tokenizer/tokenizer_config.json +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/tokenizer/vocab.json +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/src/annotuneagent/votes.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_annotate.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_evaluate.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_evidence.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_granularity.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_local_lora.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_markers.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_mltools.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_prepare.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_read.py +0 -0
- {annotuneagent-0.1.8 → annotuneagent-0.1.9}/tests/test_votes.py +0 -0
|
@@ -62,9 +62,10 @@ jobs:
|
|
|
62
62
|
python-version: "3.12"
|
|
63
63
|
cache: pip
|
|
64
64
|
cache-dependency-path: pyproject.toml
|
|
65
|
-
- run: pip install "ruff>=0.4.0,<0.17"
|
|
65
|
+
- run: pip install "ruff>=0.4.0,<0.17" "mypy>=1.10"
|
|
66
66
|
- run: ruff check src tests
|
|
67
67
|
- run: ruff format --check src tests
|
|
68
|
+
- run: mypy
|
|
68
69
|
|
|
69
70
|
package:
|
|
70
71
|
runs-on: ubuntu-latest
|
|
@@ -4,6 +4,23 @@ All notable changes to this project are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.1.9] - 2026-12-01
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- `ModelChain` holds the name endpoint only. `--ml-url` and `--ml-adapter`
|
|
12
|
+
are removed. The check rule still keeps, replaces, or drops the name.
|
|
13
|
+
- A CLI run with `--species` and neither `--types` nor `--hypotheses` uses
|
|
14
|
+
the built-in dictionary. `--cluster-key` is checked before the input is
|
|
15
|
+
read. A missing optional package exits 2.
|
|
16
|
+
- Samples that share one GEO condition are reported with a warning.
|
|
17
|
+
A saved marker dot plot closes its figure.
|
|
18
|
+
- The cluster workflow is the `annotuneagent.workflow` package. The public
|
|
19
|
+
names also include `attach`, `dictionary_hypotheses`,
|
|
20
|
+
`hypotheses_from_names`, `marker_names`, `suggest_tissues`,
|
|
21
|
+
`tissue_pages`, `fit_ranker`, and `conformal_quantile`.
|
|
22
|
+
- Lint runs mypy, and ruff also checks bugbear and pyupgrade.
|
|
23
|
+
|
|
7
24
|
## [0.1.8] - 2026-11-20
|
|
8
25
|
|
|
9
26
|
### Changed
|
|
@@ -15,8 +15,8 @@ authors:
|
|
|
15
15
|
orcid: "https://orcid.org/0000-0002-9276-9129"
|
|
16
16
|
repository-code: "https://github.com/leelieber2025/AnnoTuneAgent"
|
|
17
17
|
license: Apache-2.0
|
|
18
|
-
version: 0.1.
|
|
19
|
-
date-released: "2026-
|
|
18
|
+
version: 0.1.9
|
|
19
|
+
date-released: "2026-12-01"
|
|
20
20
|
keywords:
|
|
21
21
|
- single-cell
|
|
22
22
|
- RNA-seq
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: annotuneagent
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.9
|
|
4
4
|
Summary: Cluster-level cell-type annotation from a marker score and a name model
|
|
5
5
|
Author-email: "Zhao Li (李钊)" <leelieber@gmail.com>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -41,6 +41,7 @@ Requires-Dist: jinja2>=3.1; extra == "models"
|
|
|
41
41
|
Provides-Extra: scfair
|
|
42
42
|
Requires-Dist: scfair>=0.8; extra == "scfair"
|
|
43
43
|
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: mypy>=1.10; extra == "dev"
|
|
44
45
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
45
46
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
46
47
|
Requires-Dist: ruff<0.17,>=0.4.0; extra == "dev"
|
|
@@ -227,12 +228,12 @@ The tokenizer is installed with the package. See
|
|
|
227
228
|
|
|
228
229
|
## Status
|
|
229
230
|
|
|
230
|
-
**0.1.
|
|
231
|
+
**0.1.9 (Alpha).** Import as `import annotuneagent as ata`.
|
|
231
232
|
|
|
232
233
|
## Citation
|
|
233
234
|
|
|
234
235
|
For the software record, cite the [Zenodo DOI](https://doi.org/10.5281/zenodo.24092828).
|
|
235
|
-
Pin the package version used in the analysis, for example `annotuneagent==0.1.
|
|
236
|
+
Pin the package version used in the analysis, for example `annotuneagent==0.1.9`.
|
|
236
237
|
|
|
237
238
|
## License
|
|
238
239
|
|
|
@@ -173,12 +173,12 @@ The tokenizer is installed with the package. See
|
|
|
173
173
|
|
|
174
174
|
## Status
|
|
175
175
|
|
|
176
|
-
**0.1.
|
|
176
|
+
**0.1.9 (Alpha).** Import as `import annotuneagent as ata`.
|
|
177
177
|
|
|
178
178
|
## Citation
|
|
179
179
|
|
|
180
180
|
For the software record, cite the [Zenodo DOI](https://doi.org/10.5281/zenodo.24092828).
|
|
181
|
-
Pin the package version used in the analysis, for example `annotuneagent==0.1.
|
|
181
|
+
Pin the package version used in the analysis, for example `annotuneagent==0.1.9`.
|
|
182
182
|
|
|
183
183
|
## License
|
|
184
184
|
|
|
@@ -23,8 +23,16 @@ The public API is the names below and `annotuneagent.__version__`.
|
|
|
23
23
|
annotate
|
|
24
24
|
evaluate
|
|
25
25
|
Hypothesis
|
|
26
|
+
dictionary_hypotheses
|
|
27
|
+
hypotheses_from_names
|
|
28
|
+
marker_names
|
|
29
|
+
suggest_tissues
|
|
30
|
+
tissue_pages
|
|
31
|
+
attach
|
|
26
32
|
local_models
|
|
27
33
|
local_server
|
|
28
34
|
ModelChain
|
|
29
35
|
TaskEndpoint
|
|
36
|
+
fit_ranker
|
|
37
|
+
conformal_quantile
|
|
30
38
|
```
|
|
@@ -85,9 +85,9 @@ intersphinx_mapping = {
|
|
|
85
85
|
"python": ("https://docs.python.org/3", None),
|
|
86
86
|
"numpy": ("https://numpy.org/doc/stable/", None),
|
|
87
87
|
"pandas": ("https://pandas.pydata.org/docs/", None),
|
|
88
|
-
"scipy": ("https://docs.scipy.org/doc/scipy/
|
|
88
|
+
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
|
|
89
89
|
"scanpy": ("https://scanpy.readthedocs.io/en/stable/", None),
|
|
90
|
-
"anndata": ("https://anndata.readthedocs.io/en/
|
|
90
|
+
"anndata": ("https://anndata.readthedocs.io/en/latest/", None),
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
html_theme = "sphinx_book_theme"
|
|
@@ -68,7 +68,6 @@ token.
|
|
|
68
68
|
model = "/path/to/Qwen3.5-4B-annotune-v9k-name.Q6_K.gguf"
|
|
69
69
|
models = ata.ModelChain(
|
|
70
70
|
name=ata.TaskEndpoint(base=model, maxlen=2048, server="http://127.0.0.1:8080"),
|
|
71
|
-
ml=ata.TaskEndpoint(),
|
|
72
71
|
)
|
|
73
72
|
report = ata.run(adata, "leiden", species="human", models=models)
|
|
74
73
|
```
|
|
@@ -286,7 +285,7 @@ written or withheld. Those fields stay on the report.
|
|
|
286
285
|
passed is written, and an unchecked marker call is tried once.
|
|
287
286
|
- A name the check rule accepted stays when no dictionary panel is detected
|
|
288
287
|
in the majority of the cluster. The same is true when the name model and
|
|
289
|
-
the marker score already agree
|
|
288
|
+
the marker score already agree.
|
|
290
289
|
The hint lists the enriched genes that are not in those panels. A
|
|
291
290
|
check-accepted fibroblast, smooth muscle cell, macrophage, or monocyte
|
|
292
291
|
yields to a program-specific descendant. Any check-accepted name yields
|
|
@@ -1997,7 +1997,6 @@
|
|
|
1997
1997
|
"model = Path(\"data/model/Qwen3.5-4B-annotune-v9k-name.Q6_K.gguf\")\n",
|
|
1998
1998
|
"models = ata.ModelChain(\n",
|
|
1999
1999
|
" name=ata.TaskEndpoint(base=str(model), maxlen=2048, server=\"http://127.0.0.1:8080\"),\n",
|
|
2000
|
-
" ml=ata.TaskEndpoint(),\n",
|
|
2001
2000
|
")\n",
|
|
2002
2001
|
"report = ata.run(\n",
|
|
2003
2002
|
" adata,\n",
|
|
@@ -79,7 +79,6 @@
|
|
|
79
79
|
"model = \"/path/to/Qwen3.5-4B-annotune-v9k-name.Q6_K.gguf\"\n",
|
|
80
80
|
"models = ata.ModelChain(\n",
|
|
81
81
|
" name=ata.TaskEndpoint(base=model, maxlen=2048, server=\"http://127.0.0.1:8080\"),\n",
|
|
82
|
-
" ml=ata.TaskEndpoint(),\n",
|
|
83
82
|
")\n",
|
|
84
83
|
"print(\"server:\", models.name.server)"
|
|
85
84
|
]
|
|
@@ -107,7 +106,7 @@
|
|
|
107
106
|
"execution_count": null,
|
|
108
107
|
"outputs": [],
|
|
109
108
|
"source": [
|
|
110
|
-
"import annotuneagent as ata\n\nserver = \"http://SERVER:8080\"\nmodels = ata.ModelChain(\n name=ata.TaskEndpoint(url=server, maxlen=2048),\n
|
|
109
|
+
"import annotuneagent as ata\n\nserver = \"http://SERVER:8080\"\nmodels = ata.ModelChain(\n name=ata.TaskEndpoint(url=server, maxlen=2048),\n)\n"
|
|
111
110
|
]
|
|
112
111
|
},
|
|
113
112
|
{
|
|
@@ -1222,7 +1222,6 @@
|
|
|
1222
1222
|
"model = Path(\"data/model/Qwen3.5-4B-annotune-v9k-name.Q6_K.gguf\")\n",
|
|
1223
1223
|
"models = ata.ModelChain(\n",
|
|
1224
1224
|
" name=ata.TaskEndpoint(base=str(model), maxlen=2048, server=\"http://127.0.0.1:8080\"),\n",
|
|
1225
|
-
" ml=ata.TaskEndpoint(),\n",
|
|
1226
1225
|
")\n",
|
|
1227
1226
|
"report = ata.run(\n",
|
|
1228
1227
|
" adata,\n",
|
|
@@ -55,6 +55,7 @@ scfair = [
|
|
|
55
55
|
"scfair>=0.8",
|
|
56
56
|
]
|
|
57
57
|
dev = [
|
|
58
|
+
"mypy>=1.10",
|
|
58
59
|
"pytest>=7.0",
|
|
59
60
|
"pytest-cov>=4.0",
|
|
60
61
|
"ruff>=0.4.0,<0.17",
|
|
@@ -94,7 +95,7 @@ target-version = "py310"
|
|
|
94
95
|
extend-exclude = ["scripts", "data", "docs"]
|
|
95
96
|
|
|
96
97
|
[tool.ruff.lint]
|
|
97
|
-
select = ["E4", "E7", "E9", "F", "I"]
|
|
98
|
+
select = ["E4", "E7", "E9", "F", "I", "B", "UP"]
|
|
98
99
|
ignore = ["E501"]
|
|
99
100
|
|
|
100
101
|
[tool.ruff.lint.isort]
|
|
@@ -104,6 +105,11 @@ known-first-party = ["annotuneagent"]
|
|
|
104
105
|
quote-style = "double"
|
|
105
106
|
indent-style = "space"
|
|
106
107
|
|
|
108
|
+
[tool.mypy]
|
|
109
|
+
python_version = "3.10"
|
|
110
|
+
ignore_missing_imports = true
|
|
111
|
+
files = ["src/annotuneagent"]
|
|
112
|
+
|
|
107
113
|
[tool.pytest.ini_options]
|
|
108
114
|
minversion = "7.0"
|
|
109
115
|
testpaths = ["tests"]
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
from collections.abc import Collection
|
|
9
|
+
from typing import Any
|
|
9
10
|
|
|
10
11
|
from anndata import AnnData
|
|
11
12
|
|
|
@@ -32,7 +33,7 @@ def annotate(
|
|
|
32
33
|
hypotheses: list[Hypothesis],
|
|
33
34
|
*,
|
|
34
35
|
min_margin: float = DEFAULT_MIN_MARGIN,
|
|
35
|
-
ranker:
|
|
36
|
+
ranker: Any = None,
|
|
36
37
|
conformal_q: float | None = None,
|
|
37
38
|
clusters: Collection[str] | None = None,
|
|
38
39
|
) -> list[dict[str, object]]:
|
|
@@ -164,7 +164,7 @@ def arbitrate(
|
|
|
164
164
|
# so it cannot be the positive enrichment a label needs.
|
|
165
165
|
if top is not None:
|
|
166
166
|
blocked = blocked or not any(counted_positive(gene) for gene in top.positive)
|
|
167
|
-
if blocked:
|
|
167
|
+
if blocked or top is None:
|
|
168
168
|
status = "uncertain"
|
|
169
169
|
elif accepted is not None:
|
|
170
170
|
status = "label" if accepted == [top.hypothesis.name] else "uncertain"
|
|
@@ -7,6 +7,7 @@ from __future__ import annotations
|
|
|
7
7
|
|
|
8
8
|
import argparse
|
|
9
9
|
import json
|
|
10
|
+
import logging
|
|
10
11
|
import os
|
|
11
12
|
import sys
|
|
12
13
|
from pathlib import Path
|
|
@@ -16,7 +17,7 @@ import scanpy as sc
|
|
|
16
17
|
from .evaluate import evaluate
|
|
17
18
|
from .hypotheses import Hypothesis
|
|
18
19
|
from .local_lora import packaged_tokenizer
|
|
19
|
-
from .markers import hypotheses_from_names, parents_for, suggest_tissues, tissue_pages
|
|
20
|
+
from .markers import hypotheses_from_names, marker_names, parents_for, suggest_tissues, tissue_pages
|
|
20
21
|
from .prepare import install_hint, prepare, write_h5ad
|
|
21
22
|
from .workflow import ModelChain, TaskEndpoint, dictionary_hypotheses, run
|
|
22
23
|
|
|
@@ -37,24 +38,17 @@ def _endpoint(
|
|
|
37
38
|
def _models(args, parser) -> ModelChain | None:
|
|
38
39
|
specified = [
|
|
39
40
|
args.name_url,
|
|
40
|
-
args.ml_url,
|
|
41
41
|
args.name_adapter,
|
|
42
|
-
args.ml_adapter,
|
|
43
42
|
]
|
|
44
43
|
if not any(specified) and not args.base:
|
|
45
44
|
return None
|
|
46
45
|
if args.base and not any(specified):
|
|
47
46
|
return ModelChain(
|
|
48
47
|
name=_endpoint(None, None, args.base, 2048, packaged_tokenizer(), args.server),
|
|
49
|
-
ml=TaskEndpoint(),
|
|
50
48
|
)
|
|
51
|
-
if
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if args.name_url or args.ml_url:
|
|
55
|
-
parser.error("local adapters cannot be combined with --name-url or --ml-url")
|
|
56
|
-
if not args.name_adapter:
|
|
57
|
-
parser.error("a local server needs --name-adapter")
|
|
49
|
+
if args.name_adapter:
|
|
50
|
+
if args.name_url:
|
|
51
|
+
parser.error("local adapters cannot be combined with --name-url")
|
|
58
52
|
if args.base is None:
|
|
59
53
|
parser.error("local adapters require --base GGUF")
|
|
60
54
|
return ModelChain(
|
|
@@ -66,9 +60,6 @@ def _models(args, parser) -> ModelChain | None:
|
|
|
66
60
|
packaged_tokenizer(),
|
|
67
61
|
args.server,
|
|
68
62
|
),
|
|
69
|
-
ml=_endpoint(
|
|
70
|
-
args.ml_url, args.ml_adapter, args.base or "", 10240, packaged_tokenizer(), args.server
|
|
71
|
-
),
|
|
72
63
|
)
|
|
73
64
|
|
|
74
65
|
|
|
@@ -131,6 +122,7 @@ def _hypotheses_from_file(path: Path) -> list[Hypothesis]:
|
|
|
131
122
|
|
|
132
123
|
|
|
133
124
|
def main(argv: list[str] | None = None) -> int:
|
|
125
|
+
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
|
134
126
|
parser = argparse.ArgumentParser(prog="annotuneagent")
|
|
135
127
|
parser.add_argument("--input", type=Path, help="count or clustered .h5ad")
|
|
136
128
|
parser.add_argument(
|
|
@@ -240,13 +232,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
240
232
|
help="server root, default http://127.0.0.1:8080; reuse requires matching GGUF and adapters",
|
|
241
233
|
)
|
|
242
234
|
parser.add_argument("--name-url", help="name adapter server root")
|
|
243
|
-
parser.add_argument(
|
|
244
|
-
"--ml-url", help="accepted and not called; the check rule replaces the ML request"
|
|
245
|
-
)
|
|
246
235
|
parser.add_argument("--name-adapter", help="name LoRA GGUF loaded on the base")
|
|
247
|
-
parser.add_argument(
|
|
248
|
-
"--ml-adapter", help="accepted and not loaded; the check rule replaces the ML request"
|
|
249
|
-
)
|
|
250
236
|
parser.add_argument(
|
|
251
237
|
"--base",
|
|
252
238
|
help="merged name GGUF, or the base used with --name-adapter",
|
|
@@ -308,8 +294,20 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
308
294
|
file=sys.stderr,
|
|
309
295
|
)
|
|
310
296
|
|
|
311
|
-
if
|
|
312
|
-
parser.error("
|
|
297
|
+
if args.types is not None and args.hypotheses is not None:
|
|
298
|
+
parser.error("cannot combine --types and --hypotheses")
|
|
299
|
+
if args.types is None and args.hypotheses is None and args.species is None:
|
|
300
|
+
parser.error("pass --species, --types, or --hypotheses")
|
|
301
|
+
if args.prepare:
|
|
302
|
+
if args.species is None:
|
|
303
|
+
parser.error("--prepare requires --species")
|
|
304
|
+
if args.denoise and args.raw is None:
|
|
305
|
+
parser.error("No unfiltered droplet matrix. Pass --raw, or omit --denoise.")
|
|
306
|
+
cluster_key = args.cluster_key or "leiden"
|
|
307
|
+
elif args.cluster_key is None:
|
|
308
|
+
parser.error("--cluster-key is required")
|
|
309
|
+
else:
|
|
310
|
+
cluster_key = args.cluster_key
|
|
313
311
|
models = _models(args, parser)
|
|
314
312
|
if models is not None and args.output_h5ad is None:
|
|
315
313
|
parser.error("model endpoints require --output-h5ad")
|
|
@@ -331,9 +329,14 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
331
329
|
names = [part.strip() for part in args.types if part.strip()]
|
|
332
330
|
hypotheses = hypotheses_from_names(names, args.species, args.tissue)
|
|
333
331
|
parents = parents_for(names, species=args.species, tissue=args.tissue)
|
|
334
|
-
|
|
332
|
+
elif args.hypotheses is not None:
|
|
335
333
|
hypotheses = _hypotheses_from_file(args.hypotheses)
|
|
336
334
|
parents = {}
|
|
335
|
+
else:
|
|
336
|
+
hypotheses = dictionary_hypotheses(args.species, args.tissue)
|
|
337
|
+
parents = parents_for(
|
|
338
|
+
marker_names(args.species, args.tissue), species=args.species, tissue=args.tissue
|
|
339
|
+
)
|
|
337
340
|
if args.catalog is not None:
|
|
338
341
|
catalog = _hypotheses_from_file(args.catalog)
|
|
339
342
|
elif args.species is not None:
|
|
@@ -341,24 +344,22 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
341
344
|
else:
|
|
342
345
|
catalog = None
|
|
343
346
|
|
|
344
|
-
|
|
347
|
+
rates = None
|
|
345
348
|
if args.prepare:
|
|
346
|
-
if args.species is None:
|
|
347
|
-
parser.error("--prepare requires --species")
|
|
348
|
-
if args.denoise and args.raw is None:
|
|
349
|
-
parser.error("No unfiltered droplet matrix. Pass --raw, or omit --denoise.")
|
|
350
349
|
if install_hint(
|
|
351
350
|
batch_correction=args.batch_correction,
|
|
352
351
|
doublet_method=args.doublet_method,
|
|
353
352
|
scfair=args.scfair,
|
|
354
353
|
denoise=args.denoise,
|
|
355
354
|
):
|
|
356
|
-
return
|
|
357
|
-
rates = None
|
|
355
|
+
return 2
|
|
358
356
|
if args.solo_expected_rates is not None:
|
|
359
357
|
rates = json.loads(args.solo_expected_rates.read_text(encoding="utf-8-sig"))
|
|
360
358
|
if not isinstance(rates, dict):
|
|
361
359
|
parser.error("--solo-expected-rates must contain a JSON object")
|
|
360
|
+
|
|
361
|
+
adata = sc.read_h5ad(args.input)
|
|
362
|
+
if args.prepare:
|
|
362
363
|
adata = prepare(
|
|
363
364
|
adata,
|
|
364
365
|
species=args.species,
|
|
@@ -376,13 +377,8 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
376
377
|
norm=args.norm,
|
|
377
378
|
scfair=args.scfair,
|
|
378
379
|
max_pct_mt=args.max_pct_mt,
|
|
379
|
-
cluster_key=
|
|
380
|
+
cluster_key=cluster_key,
|
|
380
381
|
)
|
|
381
|
-
cluster_key = args.cluster_key or "leiden"
|
|
382
|
-
elif args.cluster_key is None:
|
|
383
|
-
parser.error("--cluster-key is required")
|
|
384
|
-
else:
|
|
385
|
-
cluster_key = args.cluster_key
|
|
386
382
|
kwargs = {}
|
|
387
383
|
if args.min_margin is not None:
|
|
388
384
|
kwargs["min_margin"] = args.min_margin
|