annotuneagent 0.1.3__tar.gz → 0.1.5__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.
Files changed (77) hide show
  1. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/CHANGELOG.md +100 -0
  2. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/CITATION.cff +2 -2
  3. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/PKG-INFO +9 -5
  4. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/README.md +8 -4
  5. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/installation.md +3 -2
  6. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/quickstart.md +48 -20
  7. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/tutorials/load_model.ipynb +1 -1
  8. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/tutorials/report.md +27 -12
  9. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/__init__.py +13 -4
  10. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/_version.py +1 -1
  11. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/annotate.py +1 -0
  12. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/arbitrate.py +13 -0
  13. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/evaluate.py +8 -0
  14. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/geo.py +113 -6
  15. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/local_lora.py +23 -18
  16. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/markers.tsv +2 -2
  17. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/prepare.py +10 -19
  18. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/workflow.py +784 -67
  19. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_annotate.py +61 -0
  20. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_bugfixes_1111.py +57 -0
  21. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_cli.py +8 -5
  22. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_evaluate.py +34 -0
  23. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_geo.py +67 -0
  24. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_markers.py +9 -0
  25. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_prepare.py +11 -9
  26. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_version.py +2 -2
  27. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_workflow.py +967 -25
  28. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/.github/workflows/publish.yml +0 -0
  29. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/.github/workflows/tests.yml +0 -0
  30. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/.gitignore +0 -0
  31. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/.readthedocs.yaml +0 -0
  32. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/LICENSE +0 -0
  33. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/MANIFEST.in +0 -0
  34. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/SECURITY.md +0 -0
  35. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/_static/css/custom.css +0 -0
  36. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/_templates/README.md +0 -0
  37. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/api/index.md +0 -0
  38. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/conf.py +0 -0
  39. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/index.md +0 -0
  40. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/marker_sources.md +0 -0
  41. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/requirements.txt +0 -0
  42. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/tutorials/gse266598_annotation.ipynb +0 -0
  43. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/tutorials/index.md +0 -0
  44. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/docs/tutorials/pbmc8k_annotation.ipynb +0 -0
  45. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/pyproject.toml +0 -0
  46. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/setup.cfg +0 -0
  47. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/__main__.py +0 -0
  48. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/cli.py +0 -0
  49. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/decide.py +0 -0
  50. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/evidence.py +0 -0
  51. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/granularity/__init__.py +0 -0
  52. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/granularity/cl_dag.py +0 -0
  53. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/granularity/ontology_map.py +0 -0
  54. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/granularity/relations.py +0 -0
  55. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/hypotheses.py +0 -0
  56. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/marker_plot.py +0 -0
  57. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/markers.py +0 -0
  58. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/mltools.py +0 -0
  59. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/ontology/cl_isa.json +0 -0
  60. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/ontology/granularity_policy.yaml +0 -0
  61. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/ontology/ontology_map.jsonl +0 -0
  62. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/py.typed +0 -0
  63. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/read.py +0 -0
  64. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/tokenizer/LICENSE +0 -0
  65. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/tokenizer/merges.txt +0 -0
  66. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/tokenizer/tokenizer.json +0 -0
  67. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/tokenizer/tokenizer_config.json +0 -0
  68. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/tokenizer/vocab.json +0 -0
  69. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent/votes.py +0 -0
  70. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/src/annotuneagent.egg-info/SOURCES.txt +0 -0
  71. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_decide.py +0 -0
  72. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_evidence.py +0 -0
  73. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_granularity.py +0 -0
  74. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_local_lora.py +0 -0
  75. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_mltools.py +0 -0
  76. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_read.py +0 -0
  77. {annotuneagent-0.1.3 → annotuneagent-0.1.5}/tests/test_votes.py +0 -0
@@ -2,6 +2,106 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [0.1.5] - 2026-11-17
6
+
7
+ ### Changed
8
+
9
+ - Mitochondrial QC uses 3 median absolute deviations on the upper side of
10
+ log1p(percent), fit inside each sample. A cell is removed only when its
11
+ mitochondrial share also exceeds 8%. `max_pct_mt` is still an optional
12
+ hard cap.
13
+ - A title that the name model and the ML model already agree on stays written
14
+ when its cited markers fail the expression check. A different marker call
15
+ does not replace it, unless that marker program is specific and the agreed
16
+ program is not on. Otherwise the hint stays `no marker passed`.
17
+ - The cluster query lists up to 20 enriched genes. It listed 10.
18
+ - A cluster is removed only when it has no title of its own and at least
19
+ half of its 20 leading enriched genes are ribosomal proteins
20
+ detected in at least 70% of the other cells. A missing title alone does
21
+ not remove it. A cluster that already has a title stays. The hint is
22
+ `ribosomal genes only`.
23
+ - `prepare` with `show=True` no longer draws the highly variable gene plot
24
+ or the two scatters of total counts against gene count and mitochondrial
25
+ percent.
26
+ - `run` no longer draws a UMAP colored by `annotune_cluster`. The merged ids
27
+ stay in `obs["annotune_cluster"]`. The label UMAP is unchanged.
28
+ - `annotation_code` includes `drop_clusters`. The list starts empty. Cluster
29
+ ids placed there are removed before the labels and plots. An empty Leiden
30
+ category left by that removal is dropped. A cell type with no remaining
31
+ cells is left out of the UMAP legend and the dotplot.
32
+ - A cluster whose cells were removed is not split afterwards.
33
+ - A split prints one Queries block for each remaining child, and adds that
34
+ child to `report["clusters"]`. The paragraph gives the marker judgment and
35
+ the genes enriched against the other cells.
36
+ - A cluster whose name and ML calls are endothelial cell and pericyte is
37
+ split even when a child stays unlabeled. A labeled child names every
38
+ cell in that child. Children of a lineage split are scored against every
39
+ other cell. When pericyte and smooth muscle cell are both specific, neither
40
+ name is written. The hint is `pericyte or smooth muscle cell`. When only
41
+ one of those programs is specific, that name is written.
42
+ - Subclustering a cluster of fewer than 200 cells tries resolutions 0.1
43
+ and 0.2. A cluster of 200 to 499 cells tries 0.2 and 0.4. Larger
44
+ clusters still try 0.6, 1.0, and 1.4. Silhouette chooses. On 141 cells,
45
+ 0.2 keeps two groups.
46
+ - A split between two names keeps at most two child clusters. Resolutions
47
+ that make more groups are skipped, and 0.05 and 0.1 are tried first.
48
+ Every cell in a labeled child takes that child's name.
49
+
50
+ ## [0.1.4] - 2026-11-16
51
+
52
+ ### Fixed
53
+
54
+ - A cytotoxic mixture that is not fully split stays `review`, with reason
55
+ `cytotoxic_mixture` and a hint that NK and T programs are both enriched.
56
+ `evaluate` scores a workflow record by `written_label`, so that cluster is
57
+ not counted as a marker hit. Pass `prediction_key="annotune_label"` to score
58
+ the labels written on the cells.
59
+ - Child labels of a cytotoxic mixture are written only when every child has a
60
+ label.
61
+ - `annotate` skips a support gene that is absent from the matrix.
62
+ - Adapter ids from `/lora-adapters` are cached only after the name file and
63
+ the ml file are both parsed. A failed read, or a list that does not name
64
+ both adapters, is tried again on the next request. Until then the load
65
+ order is name 0 and ml 1.
66
+
67
+ ### Changed
68
+
69
+ - `evidence_agreement` that is not program-specific stays written. The hint
70
+ is `weak agreement on {label}` and the cluster stays in the review list.
71
+ A one-gene panel cannot meet the specific test, so that agreement is left
72
+ unchanged. When no candidate panel is detected in the majority, the status
73
+ is `out_of_dictionary`, no name is written, and the hint lists genes that
74
+ are high and not in the dictionary panels.
75
+ - A cluster with no title takes a name that is already written on a cluster
76
+ it touches on the UMAP. Connection is the distance between the closest
77
+ cells, within two typical neighbor spacings. The shorter distance wins.
78
+ A name withheld as `out_of_dictionary` is not copied. The hint records the
79
+ neighbor and the distance.
80
+ - A subcluster whose cells all receive one title is dropped. The parent
81
+ keeps that title, and the child ids are not left as unresolved clusters.
82
+ A cytotoxic mixture is left split.
83
+ - A cluster is split when the name model and the ML model name different
84
+ lineages, including one the marker score already named. The split is kept
85
+ only when the children receive more than one title.
86
+ - When no panel is detected and the calls are endothelial cell and pericyte,
87
+ endothelial cell is written if an endothelial gene is enriched and no
88
+ pericyte program gene is. The hint is `endothelial cell rather than pericyte`.
89
+ - Each ranking row records `presence`, the mean fraction of cluster cells
90
+ that express the positive markers. Presence does not choose the name.
91
+ - Every cluster gets an enriched-gene query.
92
+ - `read_geo` stores each GEO characteristic on `obs`. A time point is also
93
+ `obs["day"]`, and a treatment or stimulus is also `obs["treatment"]`. Those
94
+ words are read from the sample title when the record does not name them.
95
+ `obs={...}` adds or replaces sample-level columns with the same syntax as
96
+ `groups`.
97
+ - The docs state that one missing positive gene stays in the panel and scores
98
+ 0. `ANNOTUNE_API_KEY` is documented for a server started with `--api-key`.
99
+ - A cluster whose top marker panel is a specific `mature NK T cell` is named
100
+ as that type. NK and T programs that are both specific still withhold a
101
+ title when another type ranks first.
102
+ - Limb `Schwann cell` uses `MOG`/`Mog` as the oligodendrocyte negative marker.
103
+ `PLP1`/`Plp1` stays off that negative list because Schwann cells express it.
104
+
5
105
  ## [0.1.3] - 2026-11-11
6
106
 
7
107
  ### Added
@@ -17,8 +17,8 @@ authors:
17
17
  orcid: "https://orcid.org/0000-0002-9276-9129"
18
18
  repository-code: "https://github.com/leelieber2025/AnnoTuneAgent"
19
19
  license: Apache-2.0
20
- version: 0.1.3
21
- date-released: "2026-11-11"
20
+ version: 0.1.5
21
+ date-released: "2026-11-17"
22
22
  keywords:
23
23
  - single-cell
24
24
  - RNA-seq
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: annotuneagent
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: Cluster-level cell-type annotation from marker, name, and ML results
5
5
  Author-email: "Zhao Li (李钊)" <leelieber@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -75,7 +75,9 @@ call stays auditable.
75
75
 
76
76
  One Qwen3.5-4B base (Q6_K GGUF) is shared by two independent LoRA adapters.
77
77
  The adapters are not merged into the base, so they load together on a single
78
- local `llama-server` and can be replaced without touching the base.
78
+ local `llama-server` and can be replaced without touching the base. If that
79
+ server was started with `--api-key`, set `ANNOTUNE_API_KEY`. The same value
80
+ is sent as a bearer token.
79
81
 
80
82
  | Model | Task it was fine-tuned for | Input | Output |
81
83
  | --- | --- | --- | --- |
@@ -162,7 +164,9 @@ filtered counts. `doublet_chip="10k"` (default) uses 0.8% multiplets per
162
164
  1,000 recovered cells, and `"20k"` uses 0.4%.
163
165
 
164
166
  `geo_info("GSE341410")` lists the samples in a GEO series. `read_geo` then
165
- downloads the ones you name, and `groups` sets the condition in `obs["group"]`.
167
+ downloads the ones you name. `groups` sets `obs["group"]`. Characteristics
168
+ such as day and treatment are stored on `obs`, and `obs={...}` adds columns
169
+ the record does not name.
166
170
  [docs/tutorials/gse266598_annotation.ipynb](docs/tutorials/gse266598_annotation.ipynb)
167
171
  follows one series from the GEO page through annotation.
168
172
 
@@ -214,12 +218,12 @@ The tokenizer is installed with the package. See
214
218
 
215
219
  ## Status
216
220
 
217
- **0.1.3 (Alpha).** Import as `import annotuneagent as ata`.
221
+ **0.1.5 (Alpha).** Import as `import annotuneagent as ata`.
218
222
 
219
223
  ## Citation
220
224
 
221
225
  For the software record, cite the [Zenodo DOI](https://doi.org/10.5281/zenodo.24092828).
222
- Pin the package version used in the analysis, for example `annotuneagent==0.1.3`.
226
+ Pin the package version used in the analysis, for example `annotuneagent==0.1.5`.
223
227
 
224
228
  ## License
225
229
 
@@ -21,7 +21,9 @@ call stays auditable.
21
21
 
22
22
  One Qwen3.5-4B base (Q6_K GGUF) is shared by two independent LoRA adapters.
23
23
  The adapters are not merged into the base, so they load together on a single
24
- local `llama-server` and can be replaced without touching the base.
24
+ local `llama-server` and can be replaced without touching the base. If that
25
+ server was started with `--api-key`, set `ANNOTUNE_API_KEY`. The same value
26
+ is sent as a bearer token.
25
27
 
26
28
  | Model | Task it was fine-tuned for | Input | Output |
27
29
  | --- | --- | --- | --- |
@@ -108,7 +110,9 @@ filtered counts. `doublet_chip="10k"` (default) uses 0.8% multiplets per
108
110
  1,000 recovered cells, and `"20k"` uses 0.4%.
109
111
 
110
112
  `geo_info("GSE341410")` lists the samples in a GEO series. `read_geo` then
111
- downloads the ones you name, and `groups` sets the condition in `obs["group"]`.
113
+ downloads the ones you name. `groups` sets `obs["group"]`. Characteristics
114
+ such as day and treatment are stored on `obs`, and `obs={...}` adds columns
115
+ the record does not name.
112
116
  [docs/tutorials/gse266598_annotation.ipynb](docs/tutorials/gse266598_annotation.ipynb)
113
117
  follows one series from the GEO page through annotation.
114
118
 
@@ -160,12 +164,12 @@ The tokenizer is installed with the package. See
160
164
 
161
165
  ## Status
162
166
 
163
- **0.1.3 (Alpha).** Import as `import annotuneagent as ata`.
167
+ **0.1.5 (Alpha).** Import as `import annotuneagent as ata`.
164
168
 
165
169
  ## Citation
166
170
 
167
171
  For the software record, cite the [Zenodo DOI](https://doi.org/10.5281/zenodo.24092828).
168
- Pin the package version used in the analysis, for example `annotuneagent==0.1.3`.
172
+ Pin the package version used in the analysis, for example `annotuneagent==0.1.5`.
169
173
 
170
174
  ## License
171
175
 
@@ -11,7 +11,7 @@ import annotuneagent as ata
11
11
  print(ata.__version__)
12
12
  ```
13
13
 
14
- The version is set in `src/annotuneagent/_version.py` (currently **0.1.3**).
14
+ The version is set in `src/annotuneagent/_version.py` (currently **0.1.5**).
15
15
 
16
16
  From a checkout:
17
17
 
@@ -45,7 +45,8 @@ The GGUF weights are not in the Python package. Download them from the
45
45
  Hugging Face Hub:
46
46
  [lieberlee/annotune-qwen3.5-4b-gguf](https://huggingface.co/lieberlee/annotune-qwen3.5-4b-gguf).
47
47
  {doc}`tutorials/load_model` shows the download and passes the folder to
48
- `local_models(root)`.
48
+ `local_models(root)`. If the server was started with `--api-key`, set
49
+ `ANNOTUNE_API_KEY` to the same value. It is sent as a bearer token.
49
50
 
50
51
  The package includes the Qwen tokenizer files, the Cell Ontology snapshot, and
51
52
  the reviewed name map. The tokenizer files come from `Qwen/Qwen3.5-4B`
@@ -32,11 +32,19 @@ To start from a GEO series, `ata.geo_info` reads the series record and lists
32
32
  each sample title, accession, and characteristics. It does not download
33
33
  counts. Print that result, choose the samples, and pass the names you want
34
34
  to `ata.read_geo`. `obs["sample"]` stays the GEO title. `obs["group"]` is the
35
- name you pass. Use either column as `batch_key`.
35
+ name you pass. Each characteristic in the GEO record becomes an obs column.
36
+ A time point is also stored in `obs["day"]`, and a treatment or stimulus in
37
+ `obs["treatment"]`. `obs` adds or replaces those columns when the record does
38
+ not name them. Use `sample` or `group` as `batch_key`.
36
39
 
37
40
  ```python
38
41
  info = ata.geo_info("GSE341410")
39
- adata = ata.read_geo(info, samples=["B1", "B3"], groups="B1: control B3: Day7")
42
+ adata = ata.read_geo(
43
+ info,
44
+ samples=["B1", "B3"],
45
+ groups="B1: control B3: Day7",
46
+ obs={"day": "B1: 0 B3: 7", "treatment": "B1: none B3: C&AIA"},
47
+ )
40
48
  adata = ata.prepare(adata, species="mouse", batch_key="sample")
41
49
  ```
42
50
 
@@ -51,7 +59,9 @@ The call above collects the marker score only. To also run the name and ML
51
59
  models, download the weights from the Hub
52
60
  ([lieberlee/annotune-qwen3.5-4b-gguf](https://huggingface.co/lieberlee/annotune-qwen3.5-4b-gguf))
53
61
  and pass them to `run`. {doc}`tutorials/load_model` covers the download, the
54
- `llama-server` install, and remote servers.
62
+ `llama-server` install, and remote servers. If that server was started with
63
+ `--api-key`, set `ANNOTUNE_API_KEY` to the same value. It is sent as a bearer
64
+ token.
55
65
 
56
66
  ```python
57
67
  models = ata.local_models("/path/to/annotune-models")
@@ -71,9 +81,9 @@ records the gene count, the principal-component elbow, and the resolution.
71
81
  Thresholds are fit within each sample (`batch_key`, or `obs["sample"]` when
72
82
  that column exists). For log1p total counts, log1p gene count, and the share of
73
83
  counts in the top 20 genes, the cutoff is 5 median absolute deviations on both
74
- sides (`nmads`). For mitochondrial share it is 3 on the upper side of the
75
- logit, and the share must also exceed 8%. Ribosomal and hemoglobin shares are
76
- recorded and not used to filter. `max_pct_mt` adds a hard cap in percent (10
84
+ sides (`nmads`). For mitochondrial share it is 3 on the upper side of
85
+ log1p(percent), and the share must also exceed 8%. Ribosomal and hemoglobin
86
+ shares are recorded and not used to filter. `max_pct_mt` adds a hard cap in percent (10
77
87
  means 10%). With `show=True`, `prepare` prints each sample's cutoffs in counts
78
88
  and percent.
79
89
 
@@ -196,17 +206,21 @@ panel, not to each gene separately.
196
206
  ### Report fields
197
207
 
198
208
  - `dropped_hypotheses`: each dictionary type left out because none of its
199
- positive markers are in the matrix. One missing positive gene is omitted
200
- and the type stays.
209
+ positive markers are in the matrix. One missing positive gene stays in the
210
+ panel and scores 0, and the type stays. A missing support gene is omitted.
211
+ A missing negative gene stays on the panel, is not scored, and is counted
212
+ as unmeasured for the ML call.
201
213
  - `review`: clusters that still need a look. The order is not an accuracy
202
214
  score.
203
215
  - `annotation_code`: an editable cluster mapping, `fine_order`, a `marker_dict`,
204
- and UMAP and dotplot calls. Edit the order or labels and rerun the snippet to
205
- regenerate the plots.
216
+ and UMAP and dotplot calls. `drop_clusters` removes one or more clusters
217
+ before those plots. Edit the order, the labels, or that list and rerun the
218
+ snippet to regenerate the plots.
206
219
 
207
220
  {doc}`tutorials/report` explains every report field. The printed `Queries`
208
221
  block is text to paste into another model. The heading is the local note.
209
- The paragraph under it is the question.
222
+ The paragraph under it is the question. A split adds one block per child,
223
+ with the marker judgment and the genes enriched against the other cells.
210
224
 
211
225
  A Cell Ontology id is the exact map row for the written label. An unreviewed id
212
226
  is marked pending.
@@ -250,15 +264,22 @@ same way when it has the `batch_key` column.
250
264
  ## How a cluster gets its name
251
265
 
252
266
  A judgment reads the marker score, the name-model result, and the ML-model
253
- result, and writes the title. Doubt is recorded in `annotune_hint` and in
254
- `final_reason` on the record. The title is still written.
267
+ result. It writes a dictionary name, or it leaves the cluster unnamed and
268
+ records why. A hint, when there is one, is stored on `annotune_hint`. The
269
+ record's `final_reason` says why the title was written or withheld.
270
+
271
+ - `cytotoxic_mixture`: the NK panel and the T panel are both specific. The
272
+ cluster stays unnamed so it can be split. A top-ranked `mature NK T cell`
273
+ whose own panel is specific is written as that type. Labels from the split
274
+ are written only when every child cluster has a label.
255
275
 
256
276
  - `no_marker_passed`: none of the name's cited markers passed the expression
257
277
  check. The name stays, the hint reads `no marker passed`, and the dotplot
258
- shows the best-measured cited genes. If the marker call is a different name
259
- that did pass, that name is written instead. An unchecked marker call is
260
- tried once. If it fails, and the name and ML models agree on another
261
- lineage, that agreed name is written instead.
278
+ shows the best-measured cited genes. When the name and ML models already
279
+ agree on that name, a different marker call does not replace it. Otherwise
280
+ a marker call that passed is written, and an unchecked marker call is tried
281
+ once. If that call fails, and the two models agree on another lineage, that
282
+ agreed name is written instead.
262
283
  - `mixed_programs`: a cluster under 40 cells shows two programs. It is named
263
284
  only when the marker score, name model, and ML model give the same name. The
264
285
  hint lists the programs. Otherwise the cluster stays unnamed.
@@ -268,6 +289,13 @@ result, and writes the title. Doubt is recorded in `annotune_hint` and in
268
289
  when the marker rule wrote it without a hint. A name a model already wrote on
269
290
  the same lineage stays, and the hint names the neighboring cluster. A cluster
270
291
  that touches two lineages is not renamed.
271
-
272
- `report["queue"]` lists only clusters with no written title. To find titled
273
- clusters that still carry a question, filter on `annotune_hint`.
292
+ - `low_quality`: a cluster is removed only when it has no title of its own
293
+ and at least half of its 20 leading enriched genes are ribosomal
294
+ proteins detected in at least 70% of the other cells. The hint is
295
+ `ribosomal genes only`. A missing title does not remove a cluster. A high
296
+ ribosomal count share does not remove a cluster that already has a title.
297
+
298
+ `report["queue"]` lists clusters that still have at least one cell without a
299
+ title. A cluster whose cells are all named, including by a subcluster split,
300
+ is not in `queue`. To find a titled cluster that still carries a question,
301
+ filter on `annotune_hint`.
@@ -204,7 +204,7 @@
204
204
  "source": [
205
205
  "## Remote\n",
206
206
  "\n",
207
- "Use this when one `llama-server` is already running with both adapters, including one started by [AnnoTuneLoader](https://github.com/leelieber2025/AnnoTuneLoader) on another machine. Point both tasks at that server. Each request calls `/completion` and enables one adapter. No local GGUF files are required. Name prompts must fit in 2048 tokens. ML prompts must fit in 8192. Those limits apply when `maxlen` is omitted."
207
+ "Use this when one `llama-server` is already running with both adapters, including one started by [AnnoTuneLoader](https://github.com/leelieber2025/AnnoTuneLoader) on another machine. Point both tasks at that server. Each request calls `/completion` and enables one adapter. The adapter ids come from `/lora-adapters` when one file name contains `name` and another contains `ml`. Until that parse succeeds, name is id 0 and ml is id 1, and the next request asks again. A successful parse is reused for the rest of the process. If the server was started with `--api-key`, set `ANNOTUNE_API_KEY` to the same value. It is sent as a bearer token. No local GGUF files are required. Name prompts must fit in 2048 tokens. ML prompts must fit in 8192. Those limits apply when `maxlen` is omitted."
208
208
  ]
209
209
  },
210
210
  {
@@ -1,8 +1,7 @@
1
1
  # Read the report
2
2
 
3
3
  `run` returns a dictionary and prints a `Queries` block. Each block is one
4
- cluster that still has a question: it has no title, or the title is written
5
- and `hint` is set. AnnoTuneAgent does not send this text to the name model,
4
+ cluster. AnnoTuneAgent does not send this text to the name model,
6
5
  the ML model, or any other service. Copy the paragraph under the heading and
7
6
  paste it into another model.
8
7
 
@@ -42,7 +41,7 @@ The first line is the species, the tissue when `run` was given one, the
42
41
  number of cells, and the question. Paste from this line through `Also
43
42
  detected`.
44
43
 
45
- `Enriched versus other cells` lists up to 10 genes that are higher in this
44
+ `Enriched versus other cells` lists up to 20 genes that are higher in this
46
45
  cluster than in the other cells, in Wilcoxon order. `in` is the fraction of
47
46
  cells in the cluster where the gene is detected. `out` is that fraction in
48
47
  the other cells. `logfc` is the Scanpy log fold change.
@@ -51,6 +50,17 @@ the other cells. `logfc` is the Scanpy log fold change.
51
50
  cluster, detected in at least half of its cells, and not already in the
52
51
  enriched list. The list stops at 16 genes.
53
52
 
53
+ A split adds one block for each child. The id is the child id, for example
54
+ `16.0`. That paragraph has a `Judgment` line before the enriched genes. The
55
+ genes are higher in that child than in the other cells. A child with no
56
+ single name says so in that line.
57
+
58
+ A cluster is removed only when it has no title of its own and at least half
59
+ of those 20 genes are ribosomal proteins that are also detected in
60
+ at least 70% of the other cells. The heading hint is `ribosomal genes only`.
61
+ A missing title alone does not remove it. A high ribosomal count share does
62
+ not remove a cluster that already has a title.
63
+
54
64
  A reply from the other model is not written back into `adata` or the report.
55
65
  Use it when you decide whether to keep or change the title in
56
66
  `annotation_code`.
@@ -65,20 +75,20 @@ title is not a vote count.
65
75
 
66
76
  | Column | What it is |
67
77
  |---|---|
68
- | `cluster` | Leiden id |
78
+ | `cluster` | Leiden id. A remaining child of a split is an extra row, for example `16.0` |
69
79
  | `cells` | Cells in that cluster |
70
80
  | `marker` | Name from the marker score, or none |
71
81
  | `name` | First name copied by the name model. `failed` when the call failed. The action when the reply named nothing |
72
82
  | `ml` | First name copied by the ML model. `escalate` when it abstains. `failed` when the call failed |
73
83
  | `label` | Title written onto the cells. Empty when the cluster stays unnamed |
74
- | `hint` | The question printed after the title. Empty when there is nothing to ask |
75
- | `query` | The paragraph to paste. Present when the cluster is unnamed or `hint` is set |
84
+ | `hint` | The question printed after the title. Empty when there is nothing to ask. Weak agreement keeps its title and puts the doubt here. A name outside the dictionary is not written; this hint lists the unexplained genes. Endothelial cell is written instead of pericyte when an endothelial gene is enriched and no pericyte program gene is; the hint is `endothelial cell rather than pericyte`. When a split child is specific for both pericyte and smooth muscle cell, neither name is written and the hint is `pericyte or smooth muscle cell` |
85
+ | `query` | The paragraph to paste. Present for every cluster that has a Wilcoxon table, including each remaining child. A child paragraph includes the marker judgment |
76
86
  | `reason` | Why the title was written or withheld |
77
87
  | `ontology` | Cell Ontology id for the written title. `pending` means the id is not a reviewed row |
78
88
 
79
89
  `adata.obs["annotune_label"]` is the title. `adata.obs["annotune_hint"]` is
80
90
  the hint on every cell of that cluster. `adata.obs["annotune_final_status"]`
81
- is `named`, `review`, or `escalate`. Clusters that share a title also share
91
+ is `named`, `review`, `escalate`, or `out_of_dictionary`. Clusters that share a title also share
82
92
  one id in `adata.obs["annotune_cluster"]`. The Leiden column is kept.
83
93
 
84
94
  ## What to read first
@@ -89,13 +99,15 @@ order, not an accuracy score.
89
99
  | Priority | Which clusters |
90
100
  |---|---|
91
101
  | 0 | No title |
92
- | 1 | A conflict, or close marker scores |
102
+ | 1 | A conflict, close marker scores, weak agreement, a name outside the dictionary, or endothelial cell rather than pericyte |
93
103
  | 2 | A model call failed |
94
104
  | 3 | Fewer than 20 cells |
95
105
  | 4 | Any other hint |
96
106
 
97
- `report["queue"]` lists only clusters with no title. A titled cluster with a
98
- hint is in `review`, and on `annotune_hint`, and it is not in `queue`.
107
+ `report["queue"]` lists clusters that still have at least one unlabeled cell.
108
+ A cluster whose cells are all named is not in `queue`, even when that cluster
109
+ has no single title of its own. A titled cluster with a hint is in `review`
110
+ and on `annotune_hint`.
99
111
 
100
112
  ## The rest of the report
101
113
 
@@ -103,7 +115,7 @@ hint is in `review`, and on `annotune_hint`, and it is not in `queue`.
103
115
  |---|---|
104
116
  | `records` | The working record for each cluster, including model rounds and the marker ranking |
105
117
  | `dropped_hypotheses` | Dictionary types left out because none of their positive markers are in the matrix |
106
- | `subclusters` | The second split of a cluster that was not settled. Empty when `subcluster=False` |
118
+ | `subclusters` | One split of a cluster the marker score did not label, of a cytotoxic mixture whose top panel is not a specific mature NK T cell, and of a cluster whose name and ML calls are different lineages when the children receive more than one title. Two names produce at most two child clusters, and every cell in a labeled child takes that child's name. Those children are scored against every other cell. A child specific for both pericyte and smooth muscle cell stays unlabeled. A split whose cells all have one title is dropped. Empty when `subcluster=False` or nothing was split |
107
119
  | `arbitration` | Clusters that were not given the status `named` |
108
120
  | `merged` | Titles that were given one `annotune_cluster` id |
109
121
  | `all_labeled` | True when every cell has a title |
@@ -121,6 +133,9 @@ hint is in `review`, and on `annotune_hint`, and it is not in `queue`.
121
133
 
122
134
  `annotation_code` copies the titles into `cluster2celltype`. Clusters with no
123
135
  title are left out of that map and listed under `cluster_choices` when the
124
- record has candidate names. Edit the map or `fine_order`, then run the
136
+ record has candidate names. `drop_clusters` starts empty. Put cluster ids in
137
+ that list, for example `["12"]` or `["12", "15"]`, to remove those cells
138
+ before the labels and plots. A cell type that then has no cells is left out
139
+ of the legend and the dotplot. Edit the map or `fine_order`, then run the
125
140
  snippet on the annotated object. {doc}`../quickstart` records the expression
126
141
  cutoffs used for the dotplot.
@@ -10,7 +10,10 @@ Recommended usage::
10
10
  records = ata.annotate(adata, cluster_key="leiden", hypotheses=[...])
11
11
  adata = ata.read_10x(base_dir, ["sample_a", "sample_b"])
12
12
  info = ata.geo_info("GSE341410")
13
- adata = ata.read_geo(info, samples=["B1", "B3"], groups="B1: control B3: Day7")
13
+ adata = ata.read_geo(
14
+ info, samples=["B1", "B3"], groups="B1: control B3: Day7",
15
+ obs={"day": "B1: 0 B3: 7", "treatment": "B1: none B3: C&AIA"},
16
+ )
14
17
  prepared = ata.prepare(adata, species="human", batch_key="sample")
15
18
  report = ata.run(
16
19
  prepared, "leiden", species="human",
@@ -21,7 +24,9 @@ Recommended usage::
21
24
  collects three results, the marker score, the name model, and the ML model,
22
25
  then a judgment writes the title to ``annotune_label``. The title is a
23
26
  dictionary name. A cluster can stay unnamed. Uncertain clusters are
24
- subclustered once. The name and ML models run when a ``ModelChain`` is
27
+ subclustered once. A cluster whose NK and T panels are both specific is split
28
+ even when the marker score named it, unless the top panel is a specific
29
+ mature NK T cell. The name and ML models run when a ``ModelChain`` is
25
30
  supplied. The name model copies a cell-type name from the marker dictionary.
26
31
  The ML model is trained on machine-learning measurements of the cluster,
27
32
  differential expression and marker-panel statistics, and copies a name from
@@ -31,10 +36,14 @@ ml adapters. The tokenizer is installed with the package. The server is
31
36
  ``http://127.0.0.1:8080`` unless ``url`` or ``ANNOTUNE_URL`` says otherwise.
32
37
  A matching server is reused. When the process list is unavailable, the check
33
38
  reads ``/props`` and ``/lora-adapters``. ``TaskEndpoint(url=...)`` calls
34
- ``/completion`` on that server and enables one adapter per request.
39
+ ``/completion`` on that server and enables one adapter per request. On a
40
+ server this process did not start, those ids come from the adapter file
41
+ names. Name is id 0 and ml is id 1 until that parse succeeds, and only a
42
+ successful parse is reused.
35
43
  ``attach`` connects to an existing service without loading weights.
36
44
  Model requests wait 600 seconds unless ``timeout`` or ``ANNOTUNE_TIMEOUT``
37
- says otherwise.
45
+ says otherwise. ``ANNOTUNE_API_KEY`` is sent as a bearer token when the
46
+ server was started with ``--api-key``.
38
47
  """
39
48
 
40
49
  from __future__ import annotations
@@ -7,7 +7,7 @@ from __future__ import annotations
7
7
 
8
8
  __all__ = ["__version__", "version", "version_tuple"]
9
9
 
10
- __version__ = "0.1.3"
10
+ __version__ = "0.1.5"
11
11
  version = __version__
12
12
 
13
13
  _parts: list[int | str] = []
@@ -92,6 +92,7 @@ def annotate(
92
92
  support = [
93
93
  evidence_from_stats(gene, "positive", cluster_stats[gene])
94
94
  for gene in hypothesis.support
95
+ if gene in cluster_stats
95
96
  ]
96
97
  required = None
97
98
  if hypothesis.requires_any:
@@ -112,6 +112,17 @@ def program_specific(genes: tuple[GeneEvidence, ...] | list[GeneEvidence]) -> bo
112
112
  return _panel_count(genes, specific=True)
113
113
 
114
114
 
115
+ def panel_presence(genes: tuple[GeneEvidence, ...] | list[GeneEvidence]) -> float:
116
+ """Mean fraction of cluster cells that express the positive markers.
117
+
118
+ A gene absent from the matrix is stored with ``pct_in`` 0 and stays in
119
+ the mean. This is not enrichment, and it does not choose the name.
120
+ """
121
+ if not genes:
122
+ return 0.0
123
+ return sum(float(gene.pct_in) for gene in genes) / len(genes)
124
+
125
+
115
126
  def _panel_count(genes: tuple[GeneEvidence, ...] | list[GeneEvidence], *, specific: bool) -> bool:
116
127
  if len(genes) < 2:
117
128
  return False
@@ -179,6 +190,8 @@ def arbitrate(
179
190
  "score": item.score,
180
191
  "program_on": program_detected(item.positive),
181
192
  "program_specific": program_specific(item.positive),
193
+ "presence": panel_presence(item.positive),
194
+ "n_positive": len(item.positive),
182
195
  "eligible": item.eligible,
183
196
  "lead_genes": [
184
197
  gene.gene for gene in item.positive if gene.pct_in >= 0.25 and gene.logfc >= 1.0
@@ -93,6 +93,11 @@ def evaluate(
93
93
  ``parents`` maps a label to the coarser label that still counts as a match.
94
94
  Sibling types that share a parent do not match each other. When a workflow
95
95
  wrote cell labels, ``prediction_key`` evaluates those final labels.
96
+ A workflow record has ``final_status``. Without ``prediction_key``, the
97
+ score uses ``written_label``, the title that was written, instead of the
98
+ marker ``status``. A record with no written title is uncertain, including
99
+ a cytotoxic mixture that was not written. ``prediction_key`` still scores
100
+ the labels on the cells, including a cluster that was split.
96
101
  ``raw_label_key`` is the author string before alias mapping. With it, a
97
102
  mapped name is the reference only when it wins among all author-labeled
98
103
  cells. An unmapped raw majority is not replaced by a mapped minority.
@@ -120,6 +125,9 @@ def evaluate(
120
125
  record = by_cluster.get(cluster, {"status": "uncertain", "cell_type": None})
121
126
  status = str(record["status"])
122
127
  predicted = record["cell_type"]
128
+ if "final_status" in record and prediction_key is None:
129
+ predicted = record.get("written_label")
130
+ status = "label" if predicted else "uncertain"
123
131
  if prediction_key is not None:
124
132
  labels = adata.obs.loc[groups == cluster, prediction_key]
125
133
  names = labels.dropna().astype(str).unique()