scatrans 0.9.1.dev0__tar.gz → 0.9.2.dev0__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 (36) hide show
  1. scatrans-0.9.2.dev0/LICENSE +201 -0
  2. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/PKG-INFO +156 -40
  3. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/README.md +153 -37
  4. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/pyproject.toml +2 -2
  5. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/__init__.py +8 -2
  6. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/_version.py +3 -3
  7. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/data/README.md +28 -2
  8. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/enrich.py +6 -4
  9. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/generate_gene_features.py +25 -14
  10. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/pp_bias.py +67 -19
  11. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/tests/test_basic.py +6 -0
  12. scatrans-0.9.1.dev0/LICENSE +0 -21
  13. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/.github/workflows/ci.yml +0 -0
  14. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/.github/workflows/publish.yml +0 -0
  15. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/.gitignore +0 -0
  16. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/CHANGELOG.md +0 -0
  17. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/MANIFEST.in +0 -0
  18. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/examples/memento_de_example.py +0 -0
  19. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/examples/real_data_template.py +0 -0
  20. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/examples/synthetic_active_transcription.py +0 -0
  21. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/scatrans.egg-info/SOURCES.txt +0 -0
  22. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/setup.cfg +0 -0
  23. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/_bias.py +0 -0
  24. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/_de.py +0 -0
  25. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/_permutation.py +0 -0
  26. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/_utils.py +0 -0
  27. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/_velocity.py +0 -0
  28. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/data/Hs_GO_Biological_Process_2026.txt +0 -0
  29. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/data/Hs_KEGG_2026.txt +0 -0
  30. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/data/Mm_GO_Biological_Process_2026.txt +0 -0
  31. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/data/Mm_KEGG_2026.txt +0 -0
  32. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/data/Mus_musculus.GRCm39.115_gene_features.parquet +0 -0
  33. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/data/mouse_2020A_gene_features.parquet +0 -0
  34. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/pl.py +0 -0
  35. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/qc.py +0 -0
  36. {scatrans-0.9.1.dev0 → scatrans-0.9.2.dev0}/src/scatrans/tl.py +0 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 scATrans Developers
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,14 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scatrans
3
- Version: 0.9.1.dev0
3
+ Version: 0.9.2.dev0
4
4
  Summary: Single-cell Active Transcription Analysis
5
5
  Author: scATrans Developers
6
- License: MIT
6
+ License: Apache-2.0
7
7
  Project-URL: Homepage, https://github.com/scATrans/scatrans
8
8
  Keywords: single-cell,RNA-seq,unspliced,nascent RNA,active transcription,bioinformatics
9
9
  Classifier: Development Status :: 4 - Beta
10
10
  Classifier: Intended Audience :: Science/Research
11
- Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
12
  Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
14
14
  Requires-Python: >=3.8
@@ -46,9 +46,9 @@ Dynamic: license-file
46
46
 
47
47
  # scATrans
48
48
 
49
- scATrans computes a composite score from differential expression and reference-based excess unspliced (nascent) RNA between groups. It ranks genes in single-cell spliced/unspliced or mature/nascent data.
49
+ scATrans is a Python toolkit for single-cell differential analysis. It is primarily designed for datasets that contain spliced/unspliced (or mature/nascent) RNA layers. In this setting it computes a composite active transcription score that integrates differential expression with reference-based excess unspliced RNA to rank genes.
50
50
 
51
- Results must be interpreted using the provided diagnostics. The method has known limitations and does not guarantee recovery of truly active genes.
51
+ Even without spliced/unspliced layers, scATrans remains a complete, self-contained single-cell differential analysis package. It provides multiple differential expression methods (scanpy, PyDESeq2 pseudobulk, linear mixed models, and optional Memento), comprehensive functional enrichment (ORA, GSEA, GO, KEGG with bundled up-to-date gene sets and proper universe handling), and a full suite of publication-ready visualization tools. At present there is no closely comparable all-in-one Python package offering this breadth for single-cell data.
52
52
 
53
53
  ## Installation
54
54
 
@@ -66,7 +66,7 @@ pip install "scatrans[pseudobulk]"
66
66
  pip install "scatrans[memento]"
67
67
  ```
68
68
 
69
- The package ships precomputed gene feature tables (gene length and intron number) for mouse. These are used for bias correction when available.
69
+ The package ships precomputed gene feature tables (gene length + intron number) for both mouse and human. These are used for optional bias correction in `active_score`. You can also supply custom tables (e.g. from your own GTF).
70
70
 
71
71
  To install from source:
72
72
 
@@ -76,6 +76,30 @@ cd scatrans
76
76
  pip install -e ".[dev]"
77
77
  ```
78
78
 
79
+ **Note on version when installing from git:**
80
+
81
+ The package uses `setuptools_scm` to determine the version from git tags. If you see `0.8.0.devN` after `pip install @git+...`, it means the repository you are installing from has its latest tag at 0.8.x.
82
+
83
+ To get version 0.9.0:
84
+
85
+ - Tag the repository first (recommended):
86
+ ```bash
87
+ git tag 0.9.0
88
+ git push origin 0.9.0
89
+ ```
90
+ Then reinstall.
91
+
92
+ - Or force it for this install:
93
+ ```bash
94
+ SETUPTOOLS_SCM_PRETEND_VERSION=0.9.0 pip install -U "scatrans[memento]@git+https://..."
95
+ ```
96
+
97
+ After install, verify with:
98
+ ```python
99
+ import scatrans as scat
100
+ print(scat.__version__) # should be 0.9.0
101
+ ```
102
+
79
103
  **Logging.** The package logs under the name `scatrans`. You can control verbosity with:
80
104
 
81
105
  ```python
@@ -254,6 +278,29 @@ enrich_res = scat.run_enrichment(
254
278
  # - res.attrs["universe_info"] with effective_universe_size, dropped_by_annotation_filter, etc.
255
279
  ```
256
280
 
281
+ **run_gsea** (pre-ranked GSEA for ranked gene lists):
282
+
283
+ ```python
284
+ # ranked list from active_score / differential_expression results
285
+ ranked = all_results["logFC"].sort_values(ascending=False)
286
+
287
+ gsea_res = scat.run_gsea(
288
+ ranked_genes=ranked,
289
+ gene_sets="GO_Biological_Process",
290
+ organism="mouse",
291
+ nperm=1000,
292
+ )
293
+ print(gsea_res.head())
294
+
295
+ scat.pl.enrich_dotplot(gsea_res, x="NES", color_by="NES")
296
+
297
+ # gseaplot (uses the exact curve stored by run_gsea)
298
+ term = gsea_res.iloc[0]["Term"]
299
+ scat.pl.gseaplot(ranked, gsea_res, term=term)
300
+ ```
301
+
302
+ Requires `pip install "scatrans[gsea]"`.
303
+
257
304
  **run_kegg** (convenience wrapper for KEGG pathways):
258
305
 
259
306
  ```python
@@ -473,10 +520,6 @@ A dictionary containing:
473
520
 
474
521
  `diagnose_design` is automatically called inside `active_score(...)` whenever you pass `sample_col` or set `use_pseudobulk=True`. You will see its output in the log.
475
522
 
476
- ### run_kegg and simplify_enrichment
477
-
478
- These are convenience functions built on top of `run_enrichment`.
479
-
480
523
  **run_kegg** – Run KEGG pathway enrichment directly:
481
524
 
482
525
  ```python
@@ -495,11 +538,12 @@ kegg_res = scat.run_kegg(
495
538
 
496
539
  ### run_gsea (pre-ranked GSEA)
497
540
 
498
- For ranked-list enrichment (the classic GSEA approach):
541
+ For ranked-list enrichment (the classic GSEA / prerank approach):
499
542
 
500
543
  ```python
501
- # ranked list: higher = more associated with target (e.g. logFC or custom score)
502
- ranked = all_results.set_index("gene")["logFC"] # or "active_score" etc.
544
+ # Obtain a ranked gene list (e.g. from active_score or differential_expression results).
545
+ # Convention: higher value = more associated with the target group.
546
+ ranked = all_results["logFC"].sort_values(ascending=False)
503
547
 
504
548
  gsea_res = scat.run_gsea(
505
549
  ranked_genes=ranked,
@@ -507,23 +551,24 @@ gsea_res = scat.run_gsea(
507
551
  organism="mouse",
508
552
  nperm=1000,
509
553
  min_size=15,
510
- # gsea_res is a DataFrame with NES, ES, pvalue, p.adjust, leading_edge, ...
511
554
  )
512
- print(gsea_res.head())
513
- scat.pl.enrich_dotplot(gsea_res, x="NES", color_by="NES") # auto-friendly
555
+ print(gsea_res[["Term", "NES", "p.adjust", "leading_edge"]].head())
556
+
557
+ # Works with existing plotting helpers (auto-detects GSEA columns)
558
+ scat.pl.enrich_dotplot(gsea_res, x="NES", color_by="NES")
559
+
560
+ # Dedicated running-sum plot (uses curves stored by run_gsea)
514
561
  scat.pl.gseaplot(ranked, gsea_res, term=gsea_res.iloc[0]["Term"])
515
562
  ```
516
563
 
517
- `run_gsea` stores pre-computed RES curves in `.attrs["gsea_details"]` so `gseaplot` can render the exact running sum used for the NES/p-values.
564
+ `run_gsea` stores the full enrichment score curves in `.attrs["gsea_details"]` so that `gseaplot` renders exactly the same RES that produced the reported NES/p-values.
518
565
 
519
- Requires `pip install "scatrans[gsea]"` (or gseapy).
520
-
521
- print(kegg_res[["Term", "p.adjust", "Count"]].head())
566
+ Requires the optional extra:
567
+ ```bash
568
+ pip install "scatrans[gsea]" # pulls in gseapy
522
569
  ```
523
570
 
524
- The `gene_set_source` parameter (default `"scatrans"`) controls which KEGG set is used.
525
- See the section "Choosing gene sets explicitly with `gene_set_source`" above for full details
526
- and examples for both GO and KEGG.
571
+ See the Plotting section below for details on GSEA-aware `enrich_dotplot` and the new `gseaplot`.
527
572
 
528
573
  **simplify_enrichment** – Remove redundant terms from enrichment results:
529
574
 
@@ -701,16 +746,6 @@ Recommended only when you have a reasonable number of cells and want noise reduc
701
746
 
702
747
  ---
703
748
 
704
- ## Limitations
705
-
706
- The unspliced excess term is a group-contrast proxy derived from a reference-group gamma calculation. It is not a full stochastic or dynamical model.
707
-
708
- Interpretation is simplest for clear binary contrasts. Within-group heterogeneity reduces observed signal. The permutation approximation (used when `use_permutation=True`) fixes unspliced/spliced layers and the reference gamma on the original labels; the note is recorded in the results. Global unspliced fractions above ~50% are flagged as potential technical artifacts. Bias-correction quality depends on the number of genes with length and intron annotations. With few biological replicates, power for the unspliced excess term and permutation-based FDR is limited. Mixed-model statistics tend to be conservative when between-sample variation is large.
709
-
710
- Always examine diagnostics, score distributions, and (when available) the original spliced/unspliced counts before biological interpretation.
711
-
712
- ---
713
-
714
749
  ## API Reference (Simplified)
715
750
 
716
751
  ### Core functions
@@ -718,6 +753,7 @@ Always examine diagnostics, score distributions, and (when available) the origin
718
753
  - `active_score(...)` — main analysis for active transcription from velocity data. Returns `(adata_res, significant, all_results)`.
719
754
  - `differential_expression(...)` — standalone DE (no velocity data required). Supports the same backends as `active_score` (including optional Memento). Returns `(adata, results_df)`.
720
755
  - `filter_active_genes(results_df, ...)` — post-filter the full ranked table. Supports `preset="heuristic" | "pseudobulk" | "permissive"`. Works for both `active_score` and `differential_expression` results.
756
+ - `store_raw_counts` / `ensure_raw_counts` / `restore_raw_counts` — preserve the original full count matrix and spliced/unspliced layers (call early, before HVG/normalize). Essential for correct backgrounds in enrichment and for count-based DE backends.
721
757
 
722
758
  ### Basic parameters (most users only need these)
723
759
 
@@ -747,12 +783,17 @@ Full signatures and all parameters are documented in the function docstrings and
747
783
 
748
784
  ### Other commonly used functions
749
785
 
750
- - `add_gene_features(adata, organism="mouse", ...)` — attach length/intron info
751
- - `list_available_gene_features()`
786
+ - `add_gene_features(adata, organism="mouse" or "human", ...)` — attach length/intron info from bundled or custom table
787
+ - `generate_gene_features_from_gtf(gtf_path, output_name, ...)` — build a custom table from a GTF (requires `[gene_features]`)
788
+ - `list_available_gene_features()` — list bundled tables
789
+ - `generate-gene-features` (CLI) — same as above, for the shell
790
+ - `store_raw_counts(adata, layer="counts", save_raw=False)`, `ensure_raw_counts(adata)`, `restore_raw_counts(adata, ...)` — preserve full raw counts + original spliced/unspliced layers before HVG/normalization (critical for correct DE, enrichment background, and Memento/PyDESeq2)
752
791
  - `diagnose_design(adata, groupby, target_group, reference_group, sample_col=None)` — analyzes cell/sample counts and global unspliced fraction; returns warnings, recommendations, and a suggested `filter_active_genes` preset. Automatically called internally when `sample_col` or `use_pseudobulk=True` is used.
753
792
  - `run_enrichment(...)`, `run_kegg(...)`, `run_go(...)`, `run_gsea(...)`, `simplify_enrichment(...)`, `save_enrichment_report(...)`, `expand_enrichment_genes(...)`, `list_bundled_gene_sets()`
754
- - `scat.pl.*` plotting functions (comet_plot, volcano_plot, bias_diagnostic_plot, ...)
793
+ - `scat.pl.*` plotting functions (comet_plot, volcano_plot, bias_diagnostic_plot, enrich_dotplot, gseaplot, active_score_rankplot, active_genes_heatmap, velocity_phase_portraits, ...)
755
794
  - `scat.qc.unspliced_global(adata)`
795
+ - `scat.pl.set_style()` / `scat.pl.style_context()` — publication-friendly matplotlib style (opt-in, off by default per-plot via use_style=)
796
+ - Submodules `scat.pl` and `scat.qc` (scanpy-style)
756
797
 
757
798
  ### Layer names
758
799
 
@@ -762,13 +803,69 @@ The package auto-detects `mature`/`nascent` (kb_python) and remaps them internal
762
803
 
763
804
  ## Gene Feature Attachment & CLI
764
805
 
806
+ Gene length and intron count are used for optional bias correction inside `active_score`.
807
+
765
808
  ```python
766
- adata = scat.add_gene_features(adata, organism="mouse")
809
+ # Use bundled tables
810
+ adata = scat.add_gene_features(adata, organism="mouse") # or organism="human"
811
+
767
812
  # or provide your own table
768
813
  adata = scat.add_gene_features(adata, gene_features_path="my_features.parquet")
769
814
  ```
770
815
 
771
- After installing the `gene_features` extra, the `generate-gene-features` CLI is available for creating custom tables from GTF files.
816
+ The package ships mouse tables + a human table (`human_GRCh38_2024A_gene_features.parquet`). Use `organism="human"` to select the bundled human table automatically. For other custom annotations, generate your own table and point to it with `gene_features_path`.
817
+
818
+ ### Generating a custom table from GTF
819
+
820
+ Install the generator:
821
+
822
+ ```bash
823
+ pip install "scatrans[gene_features]"
824
+ ```
825
+
826
+ Use the CLI (works with 10x `genes.gtf` or GENCODE GTFs):
827
+
828
+ ```bash
829
+ # Mouse
830
+ generate-gene-features --gtf /path/to/genes.gtf \
831
+ --output my_mouse_features.parquet \
832
+ --organism mouse
833
+
834
+ # Human (GENCODE or 10x)
835
+ generate-gene-features --gtf gencode.v49.primary_assembly.annotation.gtf \
836
+ --output human_GRCh38_2024A_gene_features.parquet \
837
+ --organism human
838
+ ```
839
+
840
+ Then use it:
841
+
842
+ ```python
843
+ import scatrans as scat
844
+
845
+ adata = scat.add_gene_features(
846
+ adata,
847
+ gene_features_path="human_GRCh38_2024A_gene_features.parquet"
848
+ )
849
+
850
+ # bias correction will now be able to use length + intron_number
851
+ adata_res, significant, all_results = scat.active_score(adata, ...)
852
+ ```
853
+
854
+ You can also call the generator programmatically:
855
+
856
+ ```python
857
+ from scatrans import generate_gene_features_from_gtf
858
+
859
+ df = generate_gene_features_from_gtf(
860
+ "path/to/genes.gtf",
861
+ output_name="my_custom_features.parquet",
862
+ organism="human"
863
+ )
864
+ ```
865
+
866
+ See also `scat.list_available_gene_features()` (for bundled tables) and the full signature of `add_gene_features`.
867
+
868
+ **Tip**: The generated parquet must contain a `gene_name` column (plus `gene_length` and `intron_number`). `add_gene_features` does a `reindex` on your `adata.var_names`.
772
869
 
773
870
  ---
774
871
 
@@ -837,7 +934,14 @@ Most return `(fig, ax)` (or `(fig, axes_list)` for grids like phase portraits) f
837
934
 
838
935
  ## Command-Line Interface
839
936
 
840
- Only the gene-feature generator is exposed as a CLI (`generate-gene-features`).
937
+ The only console script is the gene-feature table generator:
938
+
939
+ ```bash
940
+ pip install "scatrans[gene_features]"
941
+ generate-gene-features --gtf /path/to/genes.gtf --output my_features.parquet --organism human
942
+ ```
943
+
944
+ See the "Gene Feature Attachment & CLI" section for full examples (mouse/human + how to use the output with `add_gene_features`).
841
945
 
842
946
  ---
843
947
 
@@ -915,9 +1019,21 @@ adata, de_res = scat.differential_expression(adata, use_memento_de=True, ...)
915
1019
 
916
1020
  ---
917
1021
 
1022
+ ## Limitations
1023
+
1024
+ The unspliced excess term (used by the primary `active_score` workflow) is a group-contrast proxy derived from a reference-group gamma calculation. It is not a full stochastic or dynamical model.
1025
+
1026
+ Interpretation is simplest for clear binary contrasts. Within-group heterogeneity reduces observed signal. The permutation approximation (used when `use_permutation=True`) fixes unspliced/spliced layers and the reference gamma on the original labels; the note is recorded in the results. Global unspliced fractions above ~50% are flagged as potential technical artifacts. Bias-correction quality depends on the number of genes with length and intron annotations. With few biological replicates, power for the unspliced excess term and permutation-based FDR is limited. Mixed-model statistics tend to be conservative when between-sample variation is large.
1027
+
1028
+ When used purely as a differential expression + enrichment toolkit (via `differential_expression`, `run_enrichment`, etc.), scATrans relies on established backends (scanpy, PyDESeq2, etc.) whose standard statistical caveats apply.
1029
+
1030
+ Always examine diagnostics, score distributions, and (when available) the original spliced/unspliced counts before biological interpretation.
1031
+
1032
+ ---
1033
+
918
1034
  ## License
919
1035
 
920
- MIT License.
1036
+ Apache License 2.0.
921
1037
 
922
1038
  ---
923
1039