scatrans 0.9.2.dev0__tar.gz → 0.9.4.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 (55) hide show
  1. scatrans-0.9.4.2.dev0/.github/workflows/ci.yml +70 -0
  2. scatrans-0.9.4.2.dev0/.gitignore +177 -0
  3. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/CHANGELOG.md +52 -0
  4. scatrans-0.9.4.2.dev0/CITATION.cff +20 -0
  5. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/MANIFEST.in +6 -0
  6. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/PKG-INFO +313 -123
  7. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/README.md +309 -120
  8. scatrans-0.9.4.2.dev0/conftest.py +15 -0
  9. scatrans-0.9.4.2.dev0/conftest_fixtures.py +146 -0
  10. scatrans-0.9.4.2.dev0/coverage +0 -0
  11. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/examples/real_data_template.py +4 -3
  12. {scatrans-0.9.2.dev0/.github → scatrans-0.9.4.2.dev0/github}/workflows/ci.yml +16 -6
  13. scatrans-0.9.4.2.dev0/github/workflows/publish.yml +74 -0
  14. scatrans-0.9.2.dev0/.gitignore → scatrans-0.9.4.2.dev0/gitignore +2 -0
  15. scatrans-0.9.4.2.dev0/pre-commit-config.yaml +34 -0
  16. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/pyproject.toml +18 -4
  17. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/scatrans.egg-info/SOURCES.txt +20 -2
  18. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/__init__.py +19 -1
  19. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/_de.py +126 -34
  20. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/_permutation.py +56 -11
  21. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/_utils.py +67 -13
  22. scatrans-0.9.4.2.dev0/src/scatrans/_velocity.py +418 -0
  23. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/_version.py +3 -3
  24. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/data/README.md +22 -0
  25. scatrans-0.9.4.2.dev0/src/scatrans/data/human_GRCh38_2024A_gene_features.parquet +0 -0
  26. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/enrich.py +875 -110
  27. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/generate_gene_features.py +7 -6
  28. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/pl.py +932 -113
  29. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/pp_bias.py +84 -21
  30. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/qc.py +10 -7
  31. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/tl.py +862 -178
  32. scatrans-0.9.4.2.dev0/tests/__init__.py +0 -0
  33. scatrans-0.9.4.2.dev0/tests/conftest.py +7 -0
  34. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/tests/test_basic.py +200 -62
  35. scatrans-0.9.4.2.dev0/tests/test_de_backends.py +196 -0
  36. scatrans-0.9.4.2.dev0/tests/test_enrich_api.py +140 -0
  37. scatrans-0.9.4.2.dev0/tests/test_enrich_go.py +42 -0
  38. scatrans-0.9.4.2.dev0/tests/test_pl_coverage.py +61 -0
  39. scatrans-0.9.4.2.dev0/tests/test_pl_extended.py +59 -0
  40. scatrans-0.9.4.2.dev0/tests/test_pp_bias_cli.py +37 -0
  41. scatrans-0.9.4.2.dev0/tests/test_public_api.py +50 -0
  42. scatrans-0.9.4.2.dev0/tests/test_tl_coverage.py +302 -0
  43. scatrans-0.9.2.dev0/src/scatrans/_bias.py +0 -24
  44. scatrans-0.9.2.dev0/src/scatrans/_velocity.py +0 -181
  45. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/.github/workflows/publish.yml +0 -0
  46. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/LICENSE +0 -0
  47. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/examples/memento_de_example.py +0 -0
  48. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/examples/synthetic_active_transcription.py +0 -0
  49. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/setup.cfg +0 -0
  50. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/data/Hs_GO_Biological_Process_2026.txt +0 -0
  51. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/data/Hs_KEGG_2026.txt +0 -0
  52. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/data/Mm_GO_Biological_Process_2026.txt +0 -0
  53. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/data/Mm_KEGG_2026.txt +0 -0
  54. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/data/Mus_musculus.GRCm39.115_gene_features.parquet +0 -0
  55. {scatrans-0.9.2.dev0 → scatrans-0.9.4.2.dev0}/src/scatrans/data/mouse_2020A_gene_features.parquet +0 -0
@@ -0,0 +1,70 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.9", "3.10", "3.11", "3.12"]
16
+ install-extra:
17
+ - ""
18
+ - "advanced"
19
+ - "pseudobulk"
20
+ - "gene_features"
21
+
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ with:
25
+ fetch-depth: 0
26
+
27
+ - name: Set up Python ${{ matrix.python-version }}
28
+ uses: actions/setup-python@v5
29
+ with:
30
+ python-version: ${{ matrix.python-version }}
31
+ cache: "pip"
32
+
33
+ - name: Install package with extras
34
+ run: |
35
+ pip install --upgrade pip
36
+ EXTRA="${{ matrix.install-extra }}"
37
+ if [ -n "$EXTRA" ]; then
38
+ pip install -e ".[dev,$EXTRA]"
39
+ else
40
+ pip install -e ".[dev]"
41
+ fi
42
+
43
+ - name: Ruff lint
44
+ run: |
45
+ ruff check src/scatrans tests
46
+ ruff format --check src/scatrans tests
47
+
48
+ - name: Run fast tests
49
+ run: PYTHONPATH=src:. python -m pytest -m "not plot and not slow" -q
50
+
51
+ - name: Run slow tests (core / Python 3.11 only)
52
+ if: matrix.python-version == '3.11' && matrix.install-extra == ''
53
+ run: PYTHONPATH=src:. python -m pytest -m "slow and not plot" -q
54
+
55
+ - name: Run plot tests (core / Python 3.11 only)
56
+ if: matrix.python-version == '3.11' && matrix.install-extra == ''
57
+ run: PYTHONPATH=src:. python -m pytest -m plot -q
58
+
59
+ - name: Coverage report (core / Python 3.11 only)
60
+ if: matrix.python-version == '3.11' && matrix.install-extra == ''
61
+ run: |
62
+ PYTHONPATH=src:. python -m pytest -m "not plot" --cov=src/scatrans --cov-report=xml -q \
63
+ || PYTHONPATH=src:. python -m pytest -m "not plot" -q
64
+
65
+ - name: Upload coverage (optional)
66
+ if: matrix.python-version == '3.11' && matrix.install-extra == ''
67
+ uses: codecov/codecov-action@v4
68
+ with:
69
+ files: ./coverage.xml
70
+ fail_ci_if_error: false
@@ -0,0 +1,177 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ *.egg-info/
24
+ scatrans.egg-info/
25
+ src/scatrans.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ *.manifest
32
+ *.spec
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .nox/
42
+ .coverage
43
+ .coverage.*
44
+ .cache
45
+ nosetests.xml
46
+ coverage.xml
47
+ *.cover
48
+ *.py,cover
49
+ .hypothesis/
50
+ .pytest_cache/
51
+ cover/
52
+
53
+ # Translations
54
+ *.mo
55
+ *.pot
56
+
57
+ # Django stuff:
58
+ *.log
59
+ local_settings.py
60
+ db.sqlite3
61
+ db.sqlite3-journal
62
+
63
+ # Flask stuff:
64
+ instance/
65
+ .webassets-cache
66
+
67
+ # Scrapy stuff:
68
+ .scrapy
69
+
70
+ # Sphinx documentation
71
+ docs/_build/
72
+
73
+ # PyBuilder
74
+ .pybuilder/
75
+ target/
76
+
77
+ # Jupyter Notebook
78
+ .ipynb_checkpoints
79
+
80
+ # IPython
81
+ profile_default/
82
+ ipython_config.py
83
+
84
+ # pyenv
85
+ .python-version
86
+
87
+ # pipenv
88
+ Pipfile.lock
89
+
90
+ # poetry
91
+ poetry.lock
92
+
93
+ # pdm
94
+ .pdm.toml
95
+ .pdm-python
96
+ .pdm-build/
97
+
98
+ # PEP 582
99
+ __pypackages__/
100
+
101
+ # Celery stuff
102
+ celerybeat-schedule
103
+ celerybeat.pid
104
+
105
+ # SageMath parsed files
106
+ *.sage.py
107
+
108
+ # Environments
109
+ .env
110
+ .venv
111
+ env/
112
+ venv/
113
+ ENV/
114
+ env.bak/
115
+ venv.bak/
116
+
117
+ # Spyder project settings
118
+ .spyderproject
119
+ .spyproject
120
+
121
+ # Rope project settings
122
+ .ropeproject
123
+
124
+ # mkdocs documentation
125
+ /site
126
+
127
+ # mypy
128
+ .mypy_cache/
129
+ .dmypy.json
130
+ dmypy.json
131
+
132
+ # Pyre type checker
133
+ .pyre/
134
+
135
+ # pytype static type analyzer
136
+ .pytype/
137
+
138
+ # Cython debug symbols
139
+ cython_debug/
140
+
141
+ # Ruff
142
+ .ruff_cache/
143
+
144
+ # IDE / editors
145
+ .idea/
146
+ .vscode/
147
+ *.swp
148
+ *.swo
149
+ *~
150
+
151
+ # OS generated files
152
+ .DS_Store
153
+ .DS_Store?
154
+ ._*
155
+ .Spotlight-V100
156
+ .Trashes
157
+ ehthumbs.db
158
+ Thumbs.db
159
+
160
+ # Project specific
161
+ # Bundled large data is committed intentionally (gene features)
162
+ # but do not add user-generated .parquet outputs here by mistake
163
+ *.h5ad
164
+ *.loom
165
+ *.zarr
166
+ # Keep source data/ but ignore generated outputs at root
167
+ gene_features.parquet
168
+ *_gene_features.parquet
169
+ *_features.parquet
170
+ # Bundled package data (must be tracked for CI / wheels)
171
+ !src/scatrans/data/
172
+ !src/scatrans/data/*.parquet
173
+ # Temporary analysis outputs
174
+ *.pdf
175
+ *.png
176
+ *.svg
177
+ active_results/
@@ -5,6 +5,58 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased / Review 2026-06-27]
9
+ ### Added / Improved
10
+ - Clarified and documented the `gamma_method="empirical_bayes"` implementation as **hierarchical (分层) gamma estimation** for the reference U/S ratio (README keeps the CN term; source now English-only).
11
+ - Stronger emphasis on "always pass explicit target_group/reference_group".
12
+
13
+ ### Changed / Fixed (critical)
14
+ - **Bug 1**: Eliminated dead code — `tl.py` now calls the canonical `run_permutation_test(...)` in `_permutation.py` instead of duplicating the Parallel loop. Removed ~duplicated logic and the maintenance trap. `valid_expr` is passed explicitly for consistent behavior.
15
+ - **Bug 2**: Fixed double normalization (double log1p) in permutations. When `de_preprocess="normalize_log1p"` (or auto that applies), the value passed to permutation tasks is forced to "none" so that perm copies of the already-transformed adata are not re-normalized. Prevents systematically biased FDR.
16
+ - **Scientific Error 1**: Fixed EB gamma: `sigma2` in `_apply_empirical_bayes_gamma` now correctly includes the `n_ref` factor: `1.0 / (n_ref * U_r + c) + ...`. This was causing n_r-fold over-estimate of observation noise and excessive shrinkage (especially bad for the small-ref case EB is meant to help). `n_ref` is computed from r_mask in the caller.
17
+ - **Scientific Error 2**: Clarified `robust_median` docs in code/README: it is a heuristic variant of `heuristic_shrink` (different base_gamma estimator) and is **not** Bayesian/EB/hierarchical. Renamed descriptions to prevent user confusion.
18
+ - **Design fixes**:
19
+ - Tightened Memento raw counts check from `>=` to exact `== n_vars` + `var_names` equality (prevents misaligned HVG/raw usage).
20
+ - Renamed shadowing local `ad = ...` in `active_score_simple` / `differential_expression_simple` (avoids hiding `import anndata as ad`).
21
+ - Made `min_cells_per_sample` private (`_min_cells_per_sample`) + doc note (was public but did nothing).
22
+ - Removed all Chinese comments ("分层") from source (tl.py, _velocity.py); retained in README only.
23
+ - Replaced risky bare `except TypeError` for PyDESeq2 design_factors/design compat with explicit `_pydeseq2_uses_design_factors()` using `importlib.metadata` version check.
24
+
25
+ - Reduced anndata category storage log noise during internal DE/perm (narrow logger level bump).
26
+ - All tests + targeted EB/perm/explicit-norm cases pass after fixes.
27
+
28
+ ### Additional fixes (2026-06-27 round 2)
29
+ - **Scientific Error 3**: `generate_gene_features_from_gtf()` now computes **true exon union length per gene** (merge overlapping intervals) instead of naively summing all exons across all transcripts. Prevents ~N_transcript-fold overestimation of gene_length for multi-isoform genes (affects only users who generate their own tables; bundled .parquet files are unaffected).
30
+ - **Scientific Error 4**: `logFC` is now normalized toward consistent **log2 scale** across backends inside `_run_de_wrapper`:
31
+ - wilcoxon, mixedlm, memento: divided by ln(2)
32
+ - t-test / PyDESeq2: left as native log2
33
+ - Updated docstring. Makes `logfc_cutoff` semantically comparable.
34
+ - **Bug 3**: `_pseudobulk_with_layers` now uses a **per-run UUID-based private separator** (instead of fragile "||") to build internal keys. Completely eliminates split errors when sample names contain "||".
35
+ - **Bug 4**: Removed redundant `import warnings as _w` inside `with warnings.catch_warnings()` in `_fit_huber_bias_correction`.
36
+ - **Design 6**: `pval_cutoff` deprecation warning now fires **on every use** of the legacy name (previously only when != 0.05).
37
+ - **Design 7**: `run_go(ontology="CC"/"MF")` now emits a clear INFO log explaining that only BP is bundled and the others require gseapy + network.
38
+ - **Design 8**: Made the "max > 50" heuristic in `_prepare_log_normalized_expression` (mixed model prep) more robust: checks for negatives, uses lower threshold (20), better warning message.
39
+ - **Design 9**: `valid_expr` is now **explicitly passed** from `tl.py` into `run_permutation_test` (no more hidden reliance on adata.var after the fact).
40
+
41
+ ### Post-review hardening (2026-06-27)
42
+ - **Fragility fix (high)**: Added explicit schema validation + safe column access + clear warning in `_run_memento_de` for expected 'de_coef'/'de_pval' from memento.binary_test_1d. Prevents silent fallback (or crash) if upstream memento-de changes column names/structure. Updated optional dep pin to "memento-de>=0.1.0,<0.3.0".
43
+ - **Cleanup + consistency (high)**: `run_permutation_test` now owns the small-space FDR decision (use_fdr=False + disabled_reason="small_permutation_space" when n_perm < 100). Removed vestigial dead `if not perm_use_fdr` and useless max_perm check/assign in tl.py. `disabled_reason` (and `perm_disabled_reason`) now properly returned and stored in adata.uns["scatrans"] metadata.
44
+ - **Diagnostics improvement**: MixedLM per-gene fits now count genes hitting the neutral-except fallback (`n_genes_failed_fit`). Recorded in diagnostics["mixed_model"] (active_score) and DE metadata (differential_expression). Warning emitted when >0 so users are not unaware of silent neutral (delta_var=0, p=1) genes.
45
+ - Only confirmed high-impact issues from the review list were addressed; medium/nuance items (e.g. EB small-ref prior, advanced fallback diag completeness) were already mitigated by existing diagnostics/fallbacks or not correctness bugs.
46
+
47
+ All new issues addressed. Full test suite green.
48
+
49
+ ## [0.9.2] - 2026-06-20
50
+
51
+ ### Added / Changed
52
+ - `filter_active_genes` now accepts `logfc_direction="up"|"down"|"both"` (default remains `"up"` for backward compatibility and "active" semantics).
53
+ - `logfc_cutoff` is interpreted as a positive magnitude in all modes.
54
+ - `"down"`: selects logFC < -cutoff (downregulated genes from differential_expression results).
55
+ - `"both"`: selects |logFC| > cutoff.
56
+ - Sorting for pure-DE tables is now direction-aware (most-negative-first for down, largest |logFC| for both).
57
+ - This directly supports the common request for downregulated candidates in standalone DE workflows.
58
+ - Updated docstrings, tests, and examples.
59
+
8
60
  ## [0.9.0] - 2026-06-19
9
61
 
10
62
  ### Added
@@ -0,0 +1,20 @@
1
+ cff-version: 1.2.0
2
+ title: "scATrans: Single-cell Active Transcription Analysis"
3
+ message: >-
4
+ If you use this software, please cite it using the metadata below.
5
+ type: software
6
+ authors:
7
+ - name: "scATrans Developers"
8
+ repository-code: "https://github.com/scATrans/scatrans"
9
+ url: "https://github.com/scATrans/scatrans"
10
+ license: Apache-2.0
11
+ version: 0.9.2
12
+ keywords:
13
+ - single-cell
14
+ - RNA-seq
15
+ - unspliced RNA
16
+ - nascent RNA
17
+ - active transcription
18
+ - bioinformatics
19
+ - differential expression
20
+ - gene set enrichment
@@ -5,7 +5,13 @@
5
5
  include LICENSE
6
6
  include README.md
7
7
  include CHANGELOG.md
8
+ include CITATION.cff
8
9
  include pyproject.toml
10
+ include conftest.py
11
+ include conftest_fixtures.py
12
+
13
+ # Include the full test suite so that `pytest` can be run from sdist/unpacked source
14
+ graft tests
9
15
 
10
16
  # Include the GitHub Actions workflows (requested)
11
17
  include .github/workflows/ci.yml