annotuneagent 0.1.4__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.
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/CHANGELOG.md +45 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/CITATION.cff +2 -2
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/PKG-INFO +3 -3
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/README.md +2 -2
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/installation.md +1 -1
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/quickstart.md +18 -10
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/tutorials/report.md +20 -6
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/_version.py +1 -1
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/prepare.py +10 -19
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/workflow.py +398 -59
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_prepare.py +11 -9
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_version.py +2 -2
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_workflow.py +492 -2
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/.github/workflows/publish.yml +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/.github/workflows/tests.yml +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/.gitignore +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/.readthedocs.yaml +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/LICENSE +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/MANIFEST.in +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/SECURITY.md +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/_static/css/custom.css +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/_templates/README.md +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/api/index.md +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/conf.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/index.md +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/marker_sources.md +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/requirements.txt +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/tutorials/gse266598_annotation.ipynb +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/tutorials/index.md +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/tutorials/load_model.ipynb +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/docs/tutorials/pbmc8k_annotation.ipynb +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/pyproject.toml +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/setup.cfg +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/__init__.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/__main__.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/annotate.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/arbitrate.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/cli.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/decide.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/evaluate.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/evidence.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/geo.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/granularity/__init__.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/granularity/cl_dag.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/granularity/ontology_map.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/granularity/relations.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/hypotheses.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/local_lora.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/marker_plot.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/markers.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/markers.tsv +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/mltools.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/ontology/cl_isa.json +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/ontology/granularity_policy.yaml +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/ontology/ontology_map.jsonl +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/py.typed +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/read.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/tokenizer/LICENSE +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/tokenizer/merges.txt +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/tokenizer/tokenizer.json +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/tokenizer/tokenizer_config.json +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/tokenizer/vocab.json +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent/votes.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/src/annotuneagent.egg-info/SOURCES.txt +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_annotate.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_bugfixes_1111.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_cli.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_decide.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_evaluate.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_evidence.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_geo.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_granularity.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_local_lora.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_markers.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_mltools.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_read.py +0 -0
- {annotuneagent-0.1.4 → annotuneagent-0.1.5}/tests/test_votes.py +0 -0
|
@@ -2,6 +2,51 @@
|
|
|
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
|
+
|
|
5
50
|
## [0.1.4] - 2026-11-16
|
|
6
51
|
|
|
7
52
|
### Fixed
|
|
@@ -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.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
|
+
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
|
|
@@ -218,12 +218,12 @@ The tokenizer is installed with the package. See
|
|
|
218
218
|
|
|
219
219
|
## Status
|
|
220
220
|
|
|
221
|
-
**0.1.
|
|
221
|
+
**0.1.5 (Alpha).** Import as `import annotuneagent as ata`.
|
|
222
222
|
|
|
223
223
|
## Citation
|
|
224
224
|
|
|
225
225
|
For the software record, cite the [Zenodo DOI](https://doi.org/10.5281/zenodo.24092828).
|
|
226
|
-
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.5`.
|
|
227
227
|
|
|
228
228
|
## License
|
|
229
229
|
|
|
@@ -164,12 +164,12 @@ The tokenizer is installed with the package. See
|
|
|
164
164
|
|
|
165
165
|
## Status
|
|
166
166
|
|
|
167
|
-
**0.1.
|
|
167
|
+
**0.1.5 (Alpha).** Import as `import annotuneagent as ata`.
|
|
168
168
|
|
|
169
169
|
## Citation
|
|
170
170
|
|
|
171
171
|
For the software record, cite the [Zenodo DOI](https://doi.org/10.5281/zenodo.24092828).
|
|
172
|
-
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.5`.
|
|
173
173
|
|
|
174
174
|
## License
|
|
175
175
|
|
|
@@ -81,9 +81,9 @@ records the gene count, the principal-component elbow, and the resolution.
|
|
|
81
81
|
Thresholds are fit within each sample (`batch_key`, or `obs["sample"]` when
|
|
82
82
|
that column exists). For log1p total counts, log1p gene count, and the share of
|
|
83
83
|
counts in the top 20 genes, the cutoff is 5 median absolute deviations on both
|
|
84
|
-
sides (`nmads`). For mitochondrial share it is 3 on the upper side of
|
|
85
|
-
|
|
86
|
-
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
|
|
87
87
|
means 10%). With `show=True`, `prepare` prints each sample's cutoffs in counts
|
|
88
88
|
and percent.
|
|
89
89
|
|
|
@@ -213,12 +213,14 @@ panel, not to each gene separately.
|
|
|
213
213
|
- `review`: clusters that still need a look. The order is not an accuracy
|
|
214
214
|
score.
|
|
215
215
|
- `annotation_code`: an editable cluster mapping, `fine_order`, a `marker_dict`,
|
|
216
|
-
and UMAP and dotplot calls.
|
|
217
|
-
|
|
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.
|
|
218
219
|
|
|
219
220
|
{doc}`tutorials/report` explains every report field. The printed `Queries`
|
|
220
221
|
block is text to paste into another model. The heading is the local note.
|
|
221
|
-
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.
|
|
222
224
|
|
|
223
225
|
A Cell Ontology id is the exact map row for the written label. An unreviewed id
|
|
224
226
|
is marked pending.
|
|
@@ -273,10 +275,11 @@ record's `final_reason` says why the title was written or withheld.
|
|
|
273
275
|
|
|
274
276
|
- `no_marker_passed`: none of the name's cited markers passed the expression
|
|
275
277
|
check. The name stays, the hint reads `no marker passed`, and the dotplot
|
|
276
|
-
shows the best-measured cited genes.
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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.
|
|
280
283
|
- `mixed_programs`: a cluster under 40 cells shows two programs. It is named
|
|
281
284
|
only when the marker score, name model, and ML model give the same name. The
|
|
282
285
|
hint lists the programs. Otherwise the cluster stays unnamed.
|
|
@@ -286,6 +289,11 @@ record's `final_reason` says why the title was written or withheld.
|
|
|
286
289
|
when the marker rule wrote it without a hint. A name a model already wrote on
|
|
287
290
|
the same lineage stays, and the hint names the neighboring cluster. A cluster
|
|
288
291
|
that touches two lineages is not renamed.
|
|
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.
|
|
289
297
|
|
|
290
298
|
`report["queue"]` lists clusters that still have at least one cell without a
|
|
291
299
|
title. A cluster whose cells are all named, including by a subcluster split,
|
|
@@ -41,7 +41,7 @@ The first line is the species, the tissue when `run` was given one, the
|
|
|
41
41
|
number of cells, and the question. Paste from this line through `Also
|
|
42
42
|
detected`.
|
|
43
43
|
|
|
44
|
-
`Enriched versus other cells` lists up to
|
|
44
|
+
`Enriched versus other cells` lists up to 20 genes that are higher in this
|
|
45
45
|
cluster than in the other cells, in Wilcoxon order. `in` is the fraction of
|
|
46
46
|
cells in the cluster where the gene is detected. `out` is that fraction in
|
|
47
47
|
the other cells. `logfc` is the Scanpy log fold change.
|
|
@@ -50,6 +50,17 @@ the other cells. `logfc` is the Scanpy log fold change.
|
|
|
50
50
|
cluster, detected in at least half of its cells, and not already in the
|
|
51
51
|
enriched list. The list stops at 16 genes.
|
|
52
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
|
+
|
|
53
64
|
A reply from the other model is not written back into `adata` or the report.
|
|
54
65
|
Use it when you decide whether to keep or change the title in
|
|
55
66
|
`annotation_code`.
|
|
@@ -64,14 +75,14 @@ title is not a vote count.
|
|
|
64
75
|
|
|
65
76
|
| Column | What it is |
|
|
66
77
|
|---|---|
|
|
67
|
-
| `cluster` | Leiden id |
|
|
78
|
+
| `cluster` | Leiden id. A remaining child of a split is an extra row, for example `16.0` |
|
|
68
79
|
| `cells` | Cells in that cluster |
|
|
69
80
|
| `marker` | Name from the marker score, or none |
|
|
70
81
|
| `name` | First name copied by the name model. `failed` when the call failed. The action when the reply named nothing |
|
|
71
82
|
| `ml` | First name copied by the ML model. `escalate` when it abstains. `failed` when the call failed |
|
|
72
83
|
| `label` | Title written onto the cells. Empty when the cluster stays unnamed |
|
|
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 |
|
|
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 |
|
|
75
86
|
| `reason` | Why the title was written or withheld |
|
|
76
87
|
| `ontology` | Cell Ontology id for the written title. `pending` means the id is not a reviewed row |
|
|
77
88
|
|
|
@@ -104,7 +115,7 @@ and on `annotune_hint`.
|
|
|
104
115
|
|---|---|
|
|
105
116
|
| `records` | The working record for each cluster, including model rounds and the marker ranking |
|
|
106
117
|
| `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 |
|
|
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 |
|
|
108
119
|
| `arbitration` | Clusters that were not given the status `named` |
|
|
109
120
|
| `merged` | Titles that were given one `annotune_cluster` id |
|
|
110
121
|
| `all_labeled` | True when every cell has a title |
|
|
@@ -122,6 +133,9 @@ and on `annotune_hint`.
|
|
|
122
133
|
|
|
123
134
|
`annotation_code` copies the titles into `cluster2celltype`. Clusters with no
|
|
124
135
|
title are left out of that map and listed under `cluster_choices` when the
|
|
125
|
-
record has candidate names.
|
|
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
|
|
126
140
|
snippet on the annotated object. {doc}`../quickstart` records the expression
|
|
127
141
|
cutoffs used for the dotplot.
|
|
@@ -29,7 +29,6 @@ import numpy as np
|
|
|
29
29
|
import scanpy as sc
|
|
30
30
|
from anndata import AnnData
|
|
31
31
|
from scipy import sparse, stats
|
|
32
|
-
from scipy.special import expit, logit
|
|
33
32
|
|
|
34
33
|
from .evidence import require_unique_var_names
|
|
35
34
|
|
|
@@ -349,9 +348,6 @@ def _show_prepared(adata: AnnData, cluster_key: str) -> None:
|
|
|
349
348
|
print(_format_filter_report(adata.uns["annotune_prep"]))
|
|
350
349
|
sc.pl.highest_expr_genes(adata, n_top=20, layer="counts", show=True)
|
|
351
350
|
_qc_violin(adata)
|
|
352
|
-
sc.pl.scatter(adata, x="total_counts", y="n_genes_by_counts", show=True)
|
|
353
|
-
sc.pl.scatter(adata, x="total_counts", y="pct_counts_mt", show=True)
|
|
354
|
-
sc.pl.highly_variable_genes(adata, show=True)
|
|
355
351
|
n_pcs = int(adata.uns["annotune_prep"]["n_pcs"])
|
|
356
352
|
if n_pcs:
|
|
357
353
|
ratio = adata.uns["pca"]["variance_ratio"]
|
|
@@ -749,10 +745,7 @@ def _filter_qc(
|
|
|
749
745
|
log1p=True,
|
|
750
746
|
inplace=True,
|
|
751
747
|
)
|
|
752
|
-
|
|
753
|
-
total = adata.obs["total_counts"].to_numpy(dtype=float)
|
|
754
|
-
fraction = np.clip((total_mt + 1.0) / (total + 2.0), 1e-6, 1.0 - 1e-6)
|
|
755
|
-
adata.obs["logit_mt_fraction"] = logit(fraction)
|
|
748
|
+
adata.obs["log1p_pct_counts_mt"] = np.log1p(adata.obs["pct_counts_mt"].to_numpy(dtype=float))
|
|
756
749
|
labels = _sample_labels(adata, sample_key)
|
|
757
750
|
outlier = np.zeros(adata.n_obs, dtype=bool)
|
|
758
751
|
percent = None if max_pct_mt is None else float(max_pct_mt)
|
|
@@ -775,12 +768,12 @@ def _filter_qc(
|
|
|
775
768
|
rule["nmads"] = float(scale)
|
|
776
769
|
rules.append(rule)
|
|
777
770
|
batch_outlier |= hit
|
|
778
|
-
|
|
779
|
-
mt_rule, mt_hit = _mad_rule(
|
|
771
|
+
mt_values = adata.obs["log1p_pct_counts_mt"].to_numpy()[mask]
|
|
772
|
+
mt_rule, mt_hit = _mad_rule(mt_values, _MT_NMADS, upper=True)
|
|
780
773
|
pct = adata.obs["pct_counts_mt"].to_numpy()[mask]
|
|
781
774
|
above_min = pct > _MT_MIN_PCT
|
|
782
775
|
mt_removed = mt_hit & above_min
|
|
783
|
-
mt_rule["metric"] = "
|
|
776
|
+
mt_rule["metric"] = "log1p_pct_counts_mt"
|
|
784
777
|
mt_rule["side"] = "upper"
|
|
785
778
|
mt_rule["nmads"] = float(_MT_NMADS)
|
|
786
779
|
mt_rule["min_pct"] = float(_MT_MIN_PCT)
|
|
@@ -1285,19 +1278,17 @@ def _qc_label(metric: str) -> str:
|
|
|
1285
1278
|
if metric.startswith("pct_counts_in_top_") and metric.endswith("_genes"):
|
|
1286
1279
|
n = metric.removeprefix("pct_counts_in_top_").removesuffix("_genes")
|
|
1287
1280
|
return f"percent counts in top {n} genes"
|
|
1288
|
-
if metric == "
|
|
1281
|
+
if metric == "log1p_pct_counts_mt":
|
|
1289
1282
|
return "mitochondrial percent"
|
|
1290
1283
|
return metric
|
|
1291
1284
|
|
|
1292
1285
|
|
|
1293
1286
|
def _on_count_scale(metric: str, value: float | None) -> float | None:
|
|
1294
|
-
"""log1p cutoffs become UMI or gene counts. The mito
|
|
1287
|
+
"""log1p cutoffs become UMI or gene counts. The mito log1p becomes a percent."""
|
|
1295
1288
|
if value is None or not np.isfinite(value):
|
|
1296
1289
|
return None
|
|
1297
1290
|
if metric.startswith("log1p_"):
|
|
1298
1291
|
return float(np.expm1(value))
|
|
1299
|
-
if metric == "logit_mt_fraction":
|
|
1300
|
-
return float(100.0 * expit(value))
|
|
1301
1292
|
return float(value)
|
|
1302
1293
|
|
|
1303
1294
|
|
|
@@ -1305,11 +1296,11 @@ def _fmt_threshold(metric: str, value: float | None) -> str:
|
|
|
1305
1296
|
scaled = _on_count_scale(metric, value)
|
|
1306
1297
|
if scaled is None:
|
|
1307
1298
|
return "none"
|
|
1308
|
-
if metric.startswith("
|
|
1309
|
-
return f"{int(round(scaled)):,}"
|
|
1310
|
-
if metric.startswith("pct_") or metric == "logit_mt_fraction":
|
|
1299
|
+
if metric == "log1p_pct_counts_mt" or metric.startswith("pct_"):
|
|
1311
1300
|
text = f"{scaled:.1f}"
|
|
1312
1301
|
return text[:-2] if text.endswith(".0") else text
|
|
1302
|
+
if metric.startswith("log1p_"):
|
|
1303
|
+
return f"{int(round(scaled)):,}"
|
|
1313
1304
|
return _fmt(scaled)
|
|
1314
1305
|
|
|
1315
1306
|
|
|
@@ -1319,7 +1310,7 @@ def _format_rule(rule: dict) -> str:
|
|
|
1319
1310
|
removed = _count(rule["n_removed"])
|
|
1320
1311
|
if not np.isfinite(rule["mad"]) or rule["mad"] == 0:
|
|
1321
1312
|
return f"{label}: no cutoff, {removed} removed"
|
|
1322
|
-
if metric == "
|
|
1313
|
+
if metric == "log1p_pct_counts_mt":
|
|
1323
1314
|
high = _fmt_threshold(metric, rule["high"])
|
|
1324
1315
|
floor = _fmt(rule["min_pct"])
|
|
1325
1316
|
return f"{label}: {high} and {floor}, {removed} removed"
|