annotuneagent 0.1.2__tar.gz → 0.1.4__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.4/CHANGELOG.md +208 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/CITATION.cff +2 -2
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/PKG-INFO +12 -6
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/README.md +10 -5
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/api/index.md +1 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/installation.md +3 -2
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/quickstart.md +33 -10
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/tutorials/load_model.ipynb +1 -1
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/tutorials/report.md +11 -10
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/pyproject.toml +1 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/__init__.py +15 -5
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/_version.py +1 -1
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/annotate.py +16 -4
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/arbitrate.py +82 -16
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/cli.py +22 -13
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/decide.py +43 -16
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/evaluate.py +64 -2
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/geo.py +119 -7
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/hypotheses.py +9 -4
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/local_lora.py +88 -19
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/markers.tsv +23 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/ontology/ontology_map.jsonl +11 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/prepare.py +15 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/workflow.py +668 -40
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent.egg-info/SOURCES.txt +1 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_annotate.py +118 -20
- annotuneagent-0.1.4/tests/test_bugfixes_1111.py +398 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_cli.py +8 -5
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_decide.py +33 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_evaluate.py +68 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_geo.py +67 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_markers.py +22 -4
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_version.py +2 -2
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_workflow.py +732 -20
- annotuneagent-0.1.2/CHANGELOG.md +0 -102
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/.github/workflows/publish.yml +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/.github/workflows/tests.yml +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/.gitignore +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/.readthedocs.yaml +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/LICENSE +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/MANIFEST.in +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/SECURITY.md +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/_static/css/custom.css +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/_templates/README.md +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/conf.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/index.md +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/marker_sources.md +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/requirements.txt +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/tutorials/gse266598_annotation.ipynb +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/tutorials/index.md +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/docs/tutorials/pbmc8k_annotation.ipynb +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/setup.cfg +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/__main__.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/evidence.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/granularity/__init__.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/granularity/cl_dag.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/granularity/ontology_map.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/granularity/relations.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/marker_plot.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/markers.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/mltools.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/ontology/cl_isa.json +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/ontology/granularity_policy.yaml +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/py.typed +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/read.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/tokenizer/LICENSE +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/tokenizer/merges.txt +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/tokenizer/tokenizer.json +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/tokenizer/tokenizer_config.json +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/tokenizer/vocab.json +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/src/annotuneagent/votes.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_evidence.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_granularity.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_local_lora.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_mltools.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_prepare.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_read.py +0 -0
- {annotuneagent-0.1.2 → annotuneagent-0.1.4}/tests/test_votes.py +0 -0
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
## [0.1.4] - 2026-11-16
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- A cytotoxic mixture that is not fully split stays `review`, with reason
|
|
10
|
+
`cytotoxic_mixture` and a hint that NK and T programs are both enriched.
|
|
11
|
+
`evaluate` scores a workflow record by `written_label`, so that cluster is
|
|
12
|
+
not counted as a marker hit. Pass `prediction_key="annotune_label"` to score
|
|
13
|
+
the labels written on the cells.
|
|
14
|
+
- Child labels of a cytotoxic mixture are written only when every child has a
|
|
15
|
+
label.
|
|
16
|
+
- `annotate` skips a support gene that is absent from the matrix.
|
|
17
|
+
- Adapter ids from `/lora-adapters` are cached only after the name file and
|
|
18
|
+
the ml file are both parsed. A failed read, or a list that does not name
|
|
19
|
+
both adapters, is tried again on the next request. Until then the load
|
|
20
|
+
order is name 0 and ml 1.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- `evidence_agreement` that is not program-specific stays written. The hint
|
|
25
|
+
is `weak agreement on {label}` and the cluster stays in the review list.
|
|
26
|
+
A one-gene panel cannot meet the specific test, so that agreement is left
|
|
27
|
+
unchanged. When no candidate panel is detected in the majority, the status
|
|
28
|
+
is `out_of_dictionary`, no name is written, and the hint lists genes that
|
|
29
|
+
are high and not in the dictionary panels.
|
|
30
|
+
- A cluster with no title takes a name that is already written on a cluster
|
|
31
|
+
it touches on the UMAP. Connection is the distance between the closest
|
|
32
|
+
cells, within two typical neighbor spacings. The shorter distance wins.
|
|
33
|
+
A name withheld as `out_of_dictionary` is not copied. The hint records the
|
|
34
|
+
neighbor and the distance.
|
|
35
|
+
- A subcluster whose cells all receive one title is dropped. The parent
|
|
36
|
+
keeps that title, and the child ids are not left as unresolved clusters.
|
|
37
|
+
A cytotoxic mixture is left split.
|
|
38
|
+
- A cluster is split when the name model and the ML model name different
|
|
39
|
+
lineages, including one the marker score already named. The split is kept
|
|
40
|
+
only when the children receive more than one title.
|
|
41
|
+
- When no panel is detected and the calls are endothelial cell and pericyte,
|
|
42
|
+
endothelial cell is written if an endothelial gene is enriched and no
|
|
43
|
+
pericyte program gene is. The hint is `endothelial cell rather than pericyte`.
|
|
44
|
+
- Each ranking row records `presence`, the mean fraction of cluster cells
|
|
45
|
+
that express the positive markers. Presence does not choose the name.
|
|
46
|
+
- Every cluster gets an enriched-gene query.
|
|
47
|
+
- `read_geo` stores each GEO characteristic on `obs`. A time point is also
|
|
48
|
+
`obs["day"]`, and a treatment or stimulus is also `obs["treatment"]`. Those
|
|
49
|
+
words are read from the sample title when the record does not name them.
|
|
50
|
+
`obs={...}` adds or replaces sample-level columns with the same syntax as
|
|
51
|
+
`groups`.
|
|
52
|
+
- The docs state that one missing positive gene stays in the panel and scores
|
|
53
|
+
0. `ANNOTUNE_API_KEY` is documented for a server started with `--api-key`.
|
|
54
|
+
- A cluster whose top marker panel is a specific `mature NK T cell` is named
|
|
55
|
+
as that type. NK and T programs that are both specific still withhold a
|
|
56
|
+
title when another type ranks first.
|
|
57
|
+
- Limb `Schwann cell` uses `MOG`/`Mog` as the oligodendrocyte negative marker.
|
|
58
|
+
`PLP1`/`Plp1` stays off that negative list because Schwann cells express it.
|
|
59
|
+
|
|
60
|
+
## [0.1.3] - 2026-11-11
|
|
61
|
+
|
|
62
|
+
### Added
|
|
63
|
+
|
|
64
|
+
- Dictionary rows for macrophage, mature NK T cell, choroid plexus epithelium,
|
|
65
|
+
kidney connecting tubule epithelium, retinal horizontal and amacrine cells,
|
|
66
|
+
skeletal muscle myoblast, ovarian stroma, Merkel cell, small-intestine
|
|
67
|
+
transit amplifying cell, limb Schwann cell, and brain innate lymphoid cell.
|
|
68
|
+
- `evaluate(..., raw_label_key=...)`. A mapped name is the reference only when
|
|
69
|
+
it is the majority of every author-labeled cell. An unmapped raw majority
|
|
70
|
+
stays unmapped.
|
|
71
|
+
- `write_h5ad` saves a prepared AnnData with its QC report.
|
|
72
|
+
- `ANNOTUNE_API_KEY` is sent as a bearer token.
|
|
73
|
+
|
|
74
|
+
### Changed
|
|
75
|
+
|
|
76
|
+
- A marker score caps each gene's log2 fold change at 3. A fired negative marker
|
|
77
|
+
subtracts half of one positive gene's share and still blocks a hard marker
|
|
78
|
+
label.
|
|
79
|
+
- When a call touches both CD4 and CD8, the written title is T cell. A cluster
|
|
80
|
+
whose NK and T panels are both specific is a cytotoxic mixture. A tissue
|
|
81
|
+
macrophage or alveolar fibroblast named by a model is kept when its own
|
|
82
|
+
panel is on. Effector-memory CD8 is not written when a MAIT marker is
|
|
83
|
+
enriched.
|
|
84
|
+
|
|
85
|
+
### Fixed
|
|
86
|
+
|
|
87
|
+
- `dictionary_hits` order no longer depends on the input file name. The
|
|
88
|
+
command line and the Python API use the same fixed seed.
|
|
89
|
+
- A negative marker that is absent from the matrix stays on the ML panel.
|
|
90
|
+
`n_negative_unmeasured` counts it, and the marker score does not.
|
|
91
|
+
- `annotuneagent[models]` installs `jinja2`, which the chat template needs.
|
|
92
|
+
`run` with model endpoints checks `transformers` and `jinja2` before
|
|
93
|
+
scoring instead of failing at the first cluster.
|
|
94
|
+
- Model runs no longer stop on a one-cell cluster, an integer cluster
|
|
95
|
+
column, or unused categories. Wilcoxon skips clusters with fewer than two
|
|
96
|
+
cells; their model calls are recorded as failed.
|
|
97
|
+
- A label needs a positive gene that is enriched and detected in 25% of the
|
|
98
|
+
cluster, the same rule as the score.
|
|
99
|
+
- A model URL with a trailing slash no longer posts to `//completion` (404).
|
|
100
|
+
- A server not started by this process is called with the adapter ids its
|
|
101
|
+
`/lora-adapters` file names give, so `--lora ml.gguf,name.gguf` is not
|
|
102
|
+
swapped. A server started with repeated `--lora` flags is recognized.
|
|
103
|
+
- `TaskEndpoint(system=...)` is used on the URL path.
|
|
104
|
+
- The report shows `escalate` for an ML escalation instead of `null`.
|
|
105
|
+
- `--hypotheses` reads UTF-8 with or without a BOM, accepts `support` and
|
|
106
|
+
`requires_any`, and rejects non-list gene fields. `Hypothesis("x",
|
|
107
|
+
positive="CD3E")` is one gene, not four letters.
|
|
108
|
+
- `read_geo` keeps an uncompressed `features.tsv` or `genes.tsv`.
|
|
109
|
+
- `evaluate` treats a cluster with no record as uncertain.
|
|
110
|
+
|
|
111
|
+
## [0.1.2] - 2026-11-10
|
|
112
|
+
|
|
113
|
+
### Added
|
|
114
|
+
|
|
115
|
+
- `geo_info` reads a GEO series record: sample titles, accessions, and
|
|
116
|
+
characteristics, without the count matrices. `read_geo` downloads the
|
|
117
|
+
samples you name and joins them. `groups` sets `obs["group"]`. The GEO
|
|
118
|
+
title stays in `obs["sample"]`.
|
|
119
|
+
- A tutorial runs [GSE266598](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE266598)
|
|
120
|
+
from the series page through `prepare` and annotation.
|
|
121
|
+
|
|
122
|
+
### Fixed
|
|
123
|
+
|
|
124
|
+
- The CLI refuses to write the JSON report, the labeled h5ad, or the marker
|
|
125
|
+
PDF onto an input file, or to use one path for two of those outputs.
|
|
126
|
+
- A T-cell subtype with no receptor gene detected in 25% of the cluster is
|
|
127
|
+
left out of `dictionary_hits`, is not a vote, and is not written when it is
|
|
128
|
+
the only name still in the judgment.
|
|
129
|
+
- `read_geo` keeps an uncompressed 10x file uncompressed. Several h5 matrices
|
|
130
|
+
use the one filtered file; otherwise the call raises. A sample title that
|
|
131
|
+
contains spaces can be passed as one string.
|
|
132
|
+
- Reusing a server this process did not start checks `/props` and
|
|
133
|
+
`/lora-adapters` again.
|
|
134
|
+
|
|
135
|
+
- `prepare` drops a stored neighbors record that has no `n_neighbors` before
|
|
136
|
+
it builds the graph. Hao 2021 PBMC carries that record, and Scanpy raised
|
|
137
|
+
`KeyError` on it.
|
|
138
|
+
- A marker score keeps every positive gene in the mean. A gene detected in
|
|
139
|
+
fewer than 25% of the cells contributes 0. Dropping that gene let monocyte
|
|
140
|
+
clusters match memory CD4 T cell on `S100a4` and `Cd44` alone.
|
|
141
|
+
- A name whose cited markers fail the expression check is not kept when the
|
|
142
|
+
name and ML models agree on another lineage. A marker call that already
|
|
143
|
+
failed is not written again in its place.
|
|
144
|
+
- A name under T cell cannot win the marker score unless `CD3D`, `CD3E`,
|
|
145
|
+
`CD3G`, or `TRAC` is detected in at least 25% of the cluster. Mouse symbols
|
|
146
|
+
are `Cd3d`, `Cd3e`, `Cd3g`, and `Trac`. The T cell row itself is unchanged.
|
|
147
|
+
- Human memory CD4 T cell uses `SLC4A10` and `TRAV1-2` as negative markers.
|
|
148
|
+
|
|
149
|
+
## [0.1.1] - 2026-11-09
|
|
150
|
+
|
|
151
|
+
### Fixed
|
|
152
|
+
|
|
153
|
+
- A running server is checked with `/props` and `/lora-adapters` when `/proc`
|
|
154
|
+
is unavailable, so Windows and macOS can reuse a server this package did
|
|
155
|
+
not start.
|
|
156
|
+
- A `TaskEndpoint` URL calls `/completion` and enables one LoRA adapter for
|
|
157
|
+
that request. When `maxlen` is omitted, name allows 2048 tokens and ML
|
|
158
|
+
allows 8192. An ML prompt does not fit in the name limit.
|
|
159
|
+
- A model request waits 600 seconds. `ANNOTUNE_TIMEOUT` or the `timeout`
|
|
160
|
+
argument overrides it. Health checks stay at 2 seconds.
|
|
161
|
+
- On Windows, a process check does not call `os.kill`.
|
|
162
|
+
|
|
163
|
+
### Changed
|
|
164
|
+
|
|
165
|
+
- The load-model tutorial points Windows users to
|
|
166
|
+
[AnnoTuneLoader](https://github.com/leelieber2025/AnnoTuneLoader).
|
|
167
|
+
- A tutorial explains each field of the `run` report. The `Queries` paragraph
|
|
168
|
+
is text to paste into another model.
|
|
169
|
+
|
|
170
|
+
## [0.1.0] - 2026-11-09
|
|
171
|
+
|
|
172
|
+
First public release.
|
|
173
|
+
|
|
174
|
+
### Added
|
|
175
|
+
|
|
176
|
+
- `read_10x(base, samples)` reads one filtered 10x matrix per sample folder
|
|
177
|
+
(h5 preferred over the mtx directory), makes gene and cell names unique,
|
|
178
|
+
and joins the samples.
|
|
179
|
+
- `prepare` fits QC per sample and prints the numeric cutoffs: total counts,
|
|
180
|
+
genes per cell, percent of counts in the top 20 genes, and mitochondrial
|
|
181
|
+
percent together with the 8% floor. Ribosomal and hemoglobin shares are
|
|
182
|
+
recorded and not used as filters.
|
|
183
|
+
- `prepare` normalization is `norm="log1p"` (default) or `norm="shifted"`.
|
|
184
|
+
Neighbor-graph batch correction is `none`, `harmony`, `combat`,
|
|
185
|
+
`scanorama`, `scvi`, or `scvi+harmony`.
|
|
186
|
+
- Scrublet and SOLO run per sample on the filtered unnormalized counts.
|
|
187
|
+
`doublet_chip` is `"10k"` (0.8% multiplets per 1,000 recovered cells) or
|
|
188
|
+
`"20k"` (0.4% per 1,000). `solo_expected_rates` replaces that rate.
|
|
189
|
+
AmbiDose, when enabled, runs per sample.
|
|
190
|
+
- `run` collects three results for each cluster: the marker score, the name
|
|
191
|
+
model, and the ML model. A judgment reads those results and writes the
|
|
192
|
+
title. The title is a dictionary name. The name and ML models run when a
|
|
193
|
+
model chain is passed. The name model copies a name from the marker
|
|
194
|
+
dictionary. The ML model is trained on machine-learning measurements of
|
|
195
|
+
the cluster (differential expression and marker-panel statistics) and
|
|
196
|
+
copies a name from those candidates. A cluster can stay unnamed. A cluster
|
|
197
|
+
with two programs and fewer than 40 cells keeps the name when marker,
|
|
198
|
+
name, and ML agree. An unclear cluster can take the title of the one clear
|
|
199
|
+
cluster it touches.
|
|
200
|
+
- `annotate` scores caller-supplied positive and negative markers.
|
|
201
|
+
`evaluate` compares cluster labels with a majority author label.
|
|
202
|
+
- The CLI entry point is `annotuneagent`.
|
|
203
|
+
|
|
204
|
+
### Changed
|
|
205
|
+
|
|
206
|
+
- GGUF weights are not in the package. They are downloaded separately. The
|
|
207
|
+
tokenizer, marker table, and Cell Ontology snapshot are installed with the
|
|
208
|
+
package.
|
|
@@ -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.
|
|
21
|
-
date-released: "2026-11-
|
|
20
|
+
version: 0.1.4
|
|
21
|
+
date-released: "2026-11-16"
|
|
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
|
+
Version: 0.1.4
|
|
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
|
|
@@ -37,6 +37,7 @@ Provides-Extra: scvi
|
|
|
37
37
|
Requires-Dist: scvi-tools>=1.1.3; extra == "scvi"
|
|
38
38
|
Provides-Extra: models
|
|
39
39
|
Requires-Dist: transformers; extra == "models"
|
|
40
|
+
Requires-Dist: jinja2>=3.1; extra == "models"
|
|
40
41
|
Provides-Extra: scfair
|
|
41
42
|
Requires-Dist: scfair>=0.8; extra == "scfair"
|
|
42
43
|
Provides-Extra: dev
|
|
@@ -74,7 +75,9 @@ call stays auditable.
|
|
|
74
75
|
|
|
75
76
|
One Qwen3.5-4B base (Q6_K GGUF) is shared by two independent LoRA adapters.
|
|
76
77
|
The adapters are not merged into the base, so they load together on a single
|
|
77
|
-
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.
|
|
78
81
|
|
|
79
82
|
| Model | Task it was fine-tuned for | Input | Output |
|
|
80
83
|
| --- | --- | --- | --- |
|
|
@@ -125,7 +128,8 @@ Python 3.10–3.13.
|
|
|
125
128
|
pip install annotuneagent
|
|
126
129
|
```
|
|
127
130
|
|
|
128
|
-
Local GGUF models need `pip install 'annotuneagent[models]'
|
|
131
|
+
Local GGUF models need `pip install 'annotuneagent[models]'`, which installs
|
|
132
|
+
the tokenizer stack (`transformers` and `jinja2`). Optional methods:
|
|
129
133
|
AmbiDose (`denoise=True`, [install](https://github.com/leelieber2025/AmbiDose)),
|
|
130
134
|
scVI and SOLO (`annotuneagent[scvi]`), scFair (`annotuneagent[scfair]`),
|
|
131
135
|
Harmony, and Scanorama. If you select one that is missing, `prepare` prints
|
|
@@ -160,7 +164,9 @@ filtered counts. `doublet_chip="10k"` (default) uses 0.8% multiplets per
|
|
|
160
164
|
1,000 recovered cells, and `"20k"` uses 0.4%.
|
|
161
165
|
|
|
162
166
|
`geo_info("GSE341410")` lists the samples in a GEO series. `read_geo` then
|
|
163
|
-
downloads the ones you name
|
|
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.
|
|
164
170
|
[docs/tutorials/gse266598_annotation.ipynb](docs/tutorials/gse266598_annotation.ipynb)
|
|
165
171
|
follows one series from the GEO page through annotation.
|
|
166
172
|
|
|
@@ -212,12 +218,12 @@ The tokenizer is installed with the package. See
|
|
|
212
218
|
|
|
213
219
|
## Status
|
|
214
220
|
|
|
215
|
-
**0.1.
|
|
221
|
+
**0.1.4 (Alpha).** Import as `import annotuneagent as ata`.
|
|
216
222
|
|
|
217
223
|
## Citation
|
|
218
224
|
|
|
219
225
|
For the software record, cite the [Zenodo DOI](https://doi.org/10.5281/zenodo.24092828).
|
|
220
|
-
Pin the package version used in the analysis, for example `annotuneagent==0.1.
|
|
226
|
+
Pin the package version used in the analysis, for example `annotuneagent==0.1.4`.
|
|
221
227
|
|
|
222
228
|
## License
|
|
223
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
|
| --- | --- | --- | --- |
|
|
@@ -72,7 +74,8 @@ Python 3.10–3.13.
|
|
|
72
74
|
pip install annotuneagent
|
|
73
75
|
```
|
|
74
76
|
|
|
75
|
-
Local GGUF models need `pip install 'annotuneagent[models]'
|
|
77
|
+
Local GGUF models need `pip install 'annotuneagent[models]'`, which installs
|
|
78
|
+
the tokenizer stack (`transformers` and `jinja2`). Optional methods:
|
|
76
79
|
AmbiDose (`denoise=True`, [install](https://github.com/leelieber2025/AmbiDose)),
|
|
77
80
|
scVI and SOLO (`annotuneagent[scvi]`), scFair (`annotuneagent[scfair]`),
|
|
78
81
|
Harmony, and Scanorama. If you select one that is missing, `prepare` prints
|
|
@@ -107,7 +110,9 @@ filtered counts. `doublet_chip="10k"` (default) uses 0.8% multiplets per
|
|
|
107
110
|
1,000 recovered cells, and `"20k"` uses 0.4%.
|
|
108
111
|
|
|
109
112
|
`geo_info("GSE341410")` lists the samples in a GEO series. `read_geo` then
|
|
110
|
-
downloads the ones you name
|
|
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.
|
|
111
116
|
[docs/tutorials/gse266598_annotation.ipynb](docs/tutorials/gse266598_annotation.ipynb)
|
|
112
117
|
follows one series from the GEO page through annotation.
|
|
113
118
|
|
|
@@ -159,12 +164,12 @@ The tokenizer is installed with the package. See
|
|
|
159
164
|
|
|
160
165
|
## Status
|
|
161
166
|
|
|
162
|
-
**0.1.
|
|
167
|
+
**0.1.4 (Alpha).** Import as `import annotuneagent as ata`.
|
|
163
168
|
|
|
164
169
|
## Citation
|
|
165
170
|
|
|
166
171
|
For the software record, cite the [Zenodo DOI](https://doi.org/10.5281/zenodo.24092828).
|
|
167
|
-
Pin the package version used in the analysis, for example `annotuneagent==0.1.
|
|
172
|
+
Pin the package version used in the analysis, for example `annotuneagent==0.1.4`.
|
|
168
173
|
|
|
169
174
|
## License
|
|
170
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.
|
|
14
|
+
The version is set in `src/annotuneagent/_version.py` (currently **0.1.4**).
|
|
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.
|
|
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(
|
|
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")
|
|
@@ -157,7 +167,9 @@ annotuneagent --input counts.h5ad --output report.json --output-h5ad prepared.h5
|
|
|
157
167
|
|
|
158
168
|
When the CLI writes a prepared `.h5ad`, it stores `uns["annotune_prep"]` as a
|
|
159
169
|
JSON string so AnnData can write the nested QC report. After reloading, use
|
|
160
|
-
`json.loads(adata.uns["annotune_prep"])`.
|
|
170
|
+
`json.loads(adata.uns["annotune_prep"])`. From Python, save with
|
|
171
|
+
`ata.write_h5ad(adata, "prepared.h5ad")`; `adata.write_h5ad` raises on that
|
|
172
|
+
report.
|
|
161
173
|
|
|
162
174
|
## Outputs
|
|
163
175
|
|
|
@@ -193,8 +205,11 @@ panel, not to each gene separately.
|
|
|
193
205
|
|
|
194
206
|
### Report fields
|
|
195
207
|
|
|
196
|
-
- `dropped_hypotheses`: each dictionary type left out
|
|
197
|
-
|
|
208
|
+
- `dropped_hypotheses`: each dictionary type left out because none of its
|
|
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.
|
|
198
213
|
- `review`: clusters that still need a look. The order is not an accuracy
|
|
199
214
|
score.
|
|
200
215
|
- `annotation_code`: an editable cluster mapping, `fine_order`, a `marker_dict`,
|
|
@@ -247,8 +262,14 @@ same way when it has the `batch_key` column.
|
|
|
247
262
|
## How a cluster gets its name
|
|
248
263
|
|
|
249
264
|
A judgment reads the marker score, the name-model result, and the ML-model
|
|
250
|
-
result
|
|
251
|
-
|
|
265
|
+
result. It writes a dictionary name, or it leaves the cluster unnamed and
|
|
266
|
+
records why. A hint, when there is one, is stored on `annotune_hint`. The
|
|
267
|
+
record's `final_reason` says why the title was written or withheld.
|
|
268
|
+
|
|
269
|
+
- `cytotoxic_mixture`: the NK panel and the T panel are both specific. The
|
|
270
|
+
cluster stays unnamed so it can be split. A top-ranked `mature NK T cell`
|
|
271
|
+
whose own panel is specific is written as that type. Labels from the split
|
|
272
|
+
are written only when every child cluster has a label.
|
|
252
273
|
|
|
253
274
|
- `no_marker_passed`: none of the name's cited markers passed the expression
|
|
254
275
|
check. The name stays, the hint reads `no marker passed`, and the dotplot
|
|
@@ -266,5 +287,7 @@ result, and writes the title. Doubt is recorded in `annotune_hint` and in
|
|
|
266
287
|
the same lineage stays, and the hint names the neighboring cluster. A cluster
|
|
267
288
|
that touches two lineages is not renamed.
|
|
268
289
|
|
|
269
|
-
`report["queue"]` lists
|
|
270
|
-
|
|
290
|
+
`report["queue"]` lists clusters that still have at least one cell without a
|
|
291
|
+
title. A cluster whose cells are all named, including by a subcluster split,
|
|
292
|
+
is not in `queue`. To find a titled cluster that still carries a question,
|
|
293
|
+
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
|
|
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
|
|
|
@@ -71,14 +70,14 @@ title is not a vote count.
|
|
|
71
70
|
| `name` | First name copied by the name model. `failed` when the call failed. The action when the reply named nothing |
|
|
72
71
|
| `ml` | First name copied by the ML model. `escalate` when it abstains. `failed` when the call failed |
|
|
73
72
|
| `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
|
|
73
|
+
| `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` |
|
|
74
|
+
| `query` | The paragraph to paste. Present for every cluster that has a Wilcoxon table |
|
|
76
75
|
| `reason` | Why the title was written or withheld |
|
|
77
76
|
| `ontology` | Cell Ontology id for the written title. `pending` means the id is not a reviewed row |
|
|
78
77
|
|
|
79
78
|
`adata.obs["annotune_label"]` is the title. `adata.obs["annotune_hint"]` is
|
|
80
79
|
the hint on every cell of that cluster. `adata.obs["annotune_final_status"]`
|
|
81
|
-
is `named`, `review`, or `
|
|
80
|
+
is `named`, `review`, `escalate`, or `out_of_dictionary`. Clusters that share a title also share
|
|
82
81
|
one id in `adata.obs["annotune_cluster"]`. The Leiden column is kept.
|
|
83
82
|
|
|
84
83
|
## What to read first
|
|
@@ -89,21 +88,23 @@ order, not an accuracy score.
|
|
|
89
88
|
| Priority | Which clusters |
|
|
90
89
|
|---|---|
|
|
91
90
|
| 0 | No title |
|
|
92
|
-
| 1 | A conflict,
|
|
91
|
+
| 1 | A conflict, close marker scores, weak agreement, a name outside the dictionary, or endothelial cell rather than pericyte |
|
|
93
92
|
| 2 | A model call failed |
|
|
94
93
|
| 3 | Fewer than 20 cells |
|
|
95
94
|
| 4 | Any other hint |
|
|
96
95
|
|
|
97
|
-
`report["queue"]` lists
|
|
98
|
-
|
|
96
|
+
`report["queue"]` lists clusters that still have at least one unlabeled cell.
|
|
97
|
+
A cluster whose cells are all named is not in `queue`, even when that cluster
|
|
98
|
+
has no single title of its own. A titled cluster with a hint is in `review`
|
|
99
|
+
and on `annotune_hint`.
|
|
99
100
|
|
|
100
101
|
## The rest of the report
|
|
101
102
|
|
|
102
103
|
| Field | What it is |
|
|
103
104
|
|---|---|
|
|
104
105
|
| `records` | The working record for each cluster, including model rounds and the marker ranking |
|
|
105
|
-
| `dropped_hypotheses` | Dictionary types left out because
|
|
106
|
-
| `subclusters` |
|
|
106
|
+
| `dropped_hypotheses` | Dictionary types left out because none of their positive markers are in the matrix |
|
|
107
|
+
| `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. A split whose cells all have one title is dropped. Empty when `subcluster=False` or nothing was split |
|
|
107
108
|
| `arbitration` | Clusters that were not given the status `named` |
|
|
108
109
|
| `merged` | Titles that were given one `annotune_cluster` id |
|
|
109
110
|
| `all_labeled` | True when every cell has a title |
|
|
@@ -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(
|
|
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.
|
|
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
|
|
@@ -47,7 +56,7 @@ from .hypotheses import Hypothesis
|
|
|
47
56
|
from .local_lora import attach, local_server
|
|
48
57
|
from .markers import hypotheses_from_names, marker_names, suggest_tissues, tissue_pages
|
|
49
58
|
from .mltools import conformal_quantile, fit_ranker
|
|
50
|
-
from .prepare import prepare
|
|
59
|
+
from .prepare import prepare, write_h5ad
|
|
51
60
|
from .read import read_10x
|
|
52
61
|
from .workflow import ModelChain, TaskEndpoint, dictionary_hypotheses, local_models, run
|
|
53
62
|
|
|
@@ -75,4 +84,5 @@ __all__ = [
|
|
|
75
84
|
"run",
|
|
76
85
|
"suggest_tissues",
|
|
77
86
|
"tissue_pages",
|
|
87
|
+
"write_h5ad",
|
|
78
88
|
]
|
|
@@ -11,6 +11,7 @@ from anndata import AnnData
|
|
|
11
11
|
|
|
12
12
|
from .arbitrate import DEFAULT_MIN_MARGIN, arbitrate, score_hypothesis
|
|
13
13
|
from .evidence import (
|
|
14
|
+
GeneEvidence,
|
|
14
15
|
cluster_ids,
|
|
15
16
|
cluster_mask,
|
|
16
17
|
evidence_from_stats,
|
|
@@ -21,6 +22,10 @@ from .evidence import (
|
|
|
21
22
|
from .hypotheses import Hypothesis
|
|
22
23
|
|
|
23
24
|
|
|
25
|
+
def _absent_gene(name: str) -> GeneEvidence:
|
|
26
|
+
return GeneEvidence(name, "positive", 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, False)
|
|
27
|
+
|
|
28
|
+
|
|
24
29
|
def annotate(
|
|
25
30
|
adata: AnnData,
|
|
26
31
|
cluster_key: str,
|
|
@@ -36,9 +41,11 @@ def annotate(
|
|
|
36
41
|
``clusters`` limits the records to those cluster ids. Each cluster is still
|
|
37
42
|
compared with every other cell, so its record is the same either way.
|
|
38
43
|
|
|
39
|
-
Expression is read from ``adata.X``.
|
|
40
|
-
``var_names
|
|
41
|
-
|
|
44
|
+
Expression is read from ``adata.X``. A positive gene absent from
|
|
45
|
+
``var_names`` scores 0 and stays in the panel mean. A negative gene
|
|
46
|
+
absent from ``var_names`` is not a penalty. Declared markers that are
|
|
47
|
+
present are scored together across clusters, using every CPU.
|
|
48
|
+
Mann-Whitney p-values are reported and do not change the score.
|
|
42
49
|
"""
|
|
43
50
|
if adata.n_obs == 0:
|
|
44
51
|
raise ValueError("AnnData has no cells")
|
|
@@ -59,8 +66,9 @@ def annotate(
|
|
|
59
66
|
*hypothesis.positive,
|
|
60
67
|
*hypothesis.negative,
|
|
61
68
|
*hypothesis.support,
|
|
62
|
-
*
|
|
69
|
+
*hypothesis.requires_any,
|
|
63
70
|
)
|
|
71
|
+
if gene in present
|
|
64
72
|
)
|
|
65
73
|
)
|
|
66
74
|
measured = marker_statistics(adata, masks, genes)
|
|
@@ -72,15 +80,19 @@ def annotate(
|
|
|
72
80
|
for hypothesis in hypotheses:
|
|
73
81
|
positive = [
|
|
74
82
|
evidence_from_stats(gene, "positive", cluster_stats[gene])
|
|
83
|
+
if gene in cluster_stats
|
|
84
|
+
else _absent_gene(gene)
|
|
75
85
|
for gene in hypothesis.positive
|
|
76
86
|
]
|
|
77
87
|
negative = [
|
|
78
88
|
evidence_from_stats(gene, "negative", cluster_stats[gene])
|
|
79
89
|
for gene in hypothesis.negative
|
|
90
|
+
if gene in cluster_stats
|
|
80
91
|
]
|
|
81
92
|
support = [
|
|
82
93
|
evidence_from_stats(gene, "positive", cluster_stats[gene])
|
|
83
94
|
for gene in hypothesis.support
|
|
95
|
+
if gene in cluster_stats
|
|
84
96
|
]
|
|
85
97
|
required = None
|
|
86
98
|
if hypothesis.requires_any:
|