recursieve 1.0.0__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.
- recursieve-1.0.0/LICENSE +21 -0
- recursieve-1.0.0/MANIFEST.in +6 -0
- recursieve-1.0.0/PKG-INFO +137 -0
- recursieve-1.0.0/README.md +102 -0
- recursieve-1.0.0/pyproject.toml +50 -0
- recursieve-1.0.0/setup.cfg +4 -0
- recursieve-1.0.0/src/recursieve/__init__.py +10 -0
- recursieve-1.0.0/src/recursieve/recursieve.py +1383 -0
- recursieve-1.0.0/src/recursieve.egg-info/PKG-INFO +137 -0
- recursieve-1.0.0/src/recursieve.egg-info/SOURCES.txt +12 -0
- recursieve-1.0.0/src/recursieve.egg-info/dependency_links.txt +1 -0
- recursieve-1.0.0/src/recursieve.egg-info/requires.txt +15 -0
- recursieve-1.0.0/src/recursieve.egg-info/top_level.txt +1 -0
- recursieve-1.0.0/tests/test_recursieve.py +257 -0
recursieve-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 The recursieve authors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: recursieve
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Iterative gene selection algorithm for single-cell group comparisons
|
|
5
|
+
Author: Kenny Pavan
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/ArpiarSaundersLab/RecurSieve
|
|
8
|
+
Project-URL: Source, https://github.com/ArpiarSaundersLab/RecurSieve
|
|
9
|
+
Project-URL: Issues, https://github.com/ArpiarSaundersLab/RecurSieve/issues
|
|
10
|
+
Keywords: single-cell,scRNA-seq,feature selection,gene selection,random forest,anndata,scanpy
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
17
|
+
Requires-Python: >=3.12
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: AnnSQL>=1.0.3
|
|
21
|
+
Requires-Dist: anndata>=0.10
|
|
22
|
+
Requires-Dist: joblib>=1.3
|
|
23
|
+
Requires-Dist: matplotlib>=3.7
|
|
24
|
+
Requires-Dist: numpy>=1.24
|
|
25
|
+
Requires-Dist: pandas>=2.0
|
|
26
|
+
Requires-Dist: scanpy>=1.10
|
|
27
|
+
Requires-Dist: scikit-learn>=1.3
|
|
28
|
+
Requires-Dist: scipy>=1.10
|
|
29
|
+
Requires-Dist: seaborn>=0.13
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest; extra == "dev"
|
|
32
|
+
Requires-Dist: build; extra == "dev"
|
|
33
|
+
Requires-Dist: twine; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<picture>
|
|
38
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ArpiarSaundersLab/RecurSieve/main/manuscript/logo_dark.png">
|
|
39
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ArpiarSaundersLab/RecurSieve/main/manuscript/logo_light.png">
|
|
40
|
+
<img src="https://raw.githubusercontent.com/ArpiarSaundersLab/RecurSieve/main/manuscript/logo_light.png" alt="Recursieve logo" width="360">
|
|
41
|
+
</picture>
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
**RecurSieve** is an iterative gene selection algorithm that identifies discriminative genes between two biological groups in single-cell datasets. It uses an ensemble learning approach with a blend of random forest classifiers and gaussian mixture models to progressively select genes that best separate the groups, collapsing selected genes into a lower dimensional representational axis at each iteration.
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
Install from PyPI:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install recursieve
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
RecurSieve requires Python 3.12 or newer.
|
|
56
|
+
|
|
57
|
+
To install the development version from GitHub:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install git+https://github.com/ArpiarSaundersLab/RecurSieve.git
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
import anndata as ad
|
|
67
|
+
from recursieve import recursieve
|
|
68
|
+
|
|
69
|
+
adata = ad.read_h5ad("data/alz.h5ad")
|
|
70
|
+
model = recursieve(
|
|
71
|
+
adata=adata,
|
|
72
|
+
group1="control",
|
|
73
|
+
group2="disease",
|
|
74
|
+
field_name="condition",
|
|
75
|
+
max_iterations=100,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# all genes found
|
|
79
|
+
panel = model.genes
|
|
80
|
+
|
|
81
|
+
# genes unique to RecurSieve
|
|
82
|
+
non_de_genes = model.unique_gene_panel
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Parameters
|
|
86
|
+
|
|
87
|
+
| Parameter | Type | Default | Description |
|
|
88
|
+
|-----------|------|---------|-------------|
|
|
89
|
+
| adata | AnnData | required | Annotated data matrix |
|
|
90
|
+
| group1 | str | required | First group label |
|
|
91
|
+
| group2 | str | required | Second group label |
|
|
92
|
+
| field_name | str | "sample" | Column in obs containing group labels |
|
|
93
|
+
| plots | bool | False | Generate visualization plots |
|
|
94
|
+
| print_to_console | bool | False | Print selected genes during iteration |
|
|
95
|
+
| max_iterations | int | 100 | Maximum iterations to run |
|
|
96
|
+
| additive | bool | True | Add new genes to panel or replace |
|
|
97
|
+
| flip_rate_percentage | float | 0.01 | Stop when the label flip rate falls below this value |
|
|
98
|
+
| patience | int or None | 10 | Stop after this many iterations without a new flip-rate minimum (None disables) |
|
|
99
|
+
| pval_cutoff | float | 0.05 | P-value threshold for differential expression |
|
|
100
|
+
| logfc_cutoff | float | 0.1 | Absolute log2 fold-change threshold for differential expression |
|
|
101
|
+
| seed | int | 42 | Random seed for reproducibility |
|
|
102
|
+
| summary_method | str | "mean" | Method to collapse genes: "mean" or "pca" |
|
|
103
|
+
| n_estimators | int | 300 | Number of random forest trees |
|
|
104
|
+
| n_jobs | int | -1 | Number of parallel jobs (-1 uses all cores) |
|
|
105
|
+
| max_depth | int or None | 10 | Maximum random forest tree depth |
|
|
106
|
+
| n_seeds | int | 10 | Seeds used by `seed_stability()` |
|
|
107
|
+
| preprocess | bool | True | Run QC, normalization, and HVG selection |
|
|
108
|
+
| run | bool | True | Run the pipeline on construction; if False, call `fit()` later |
|
|
109
|
+
| annsql_db | str or None | None | AnnSQL database to load instead of `adata` |
|
|
110
|
+
|
|
111
|
+
## Robustness checks
|
|
112
|
+
|
|
113
|
+
`seed_stability` checks whether the same genes are selected with different random seeds. `coexpression_null` checks whether the selected genes are found more often than by chance, by rerunning on randomized data.
|
|
114
|
+
|
|
115
|
+
Each seed and each shuffle is a full RecurSieve run, so these checks take much longer than a single run. On a 10-core laptop, 25 shuffles took about 1.5 hours for 25,000 cells and about 3.5 hours for 50,000 cells.
|
|
116
|
+
|
|
117
|
+
Both methods return a dictionary of pandas DataFrames and do not write files. The example below runs both checks and saves the main tables as CSV files.
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
seeds = model.seed_stability(n_seeds=10)
|
|
121
|
+
null = model.coexpression_null(n_shuffles=25)
|
|
122
|
+
|
|
123
|
+
seeds["gene_frequency"].to_csv("seed_gene_frequency.csv", index=False)
|
|
124
|
+
null["pvalues"].to_csv("null_pvalues.csv", index=False)
|
|
125
|
+
null["gene_frequency"].to_csv("null_gene_frequency.csv", index=False)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
<br>
|
|
129
|
+
|
|
130
|
+
## License
|
|
131
|
+
|
|
132
|
+
The RecurSieve software is released under the [MIT License](https://github.com/ArpiarSaundersLab/RecurSieve/blob/main/LICENSE). The data, figures, and tables in [`manuscript/`](https://github.com/ArpiarSaundersLab/RecurSieve/tree/main/manuscript) are dedicated to the public domain under [CC0 1.0](https://github.com/ArpiarSaundersLab/RecurSieve/blob/main/manuscript/LICENSE).
|
|
133
|
+
|
|
134
|
+
## Citation
|
|
135
|
+
|
|
136
|
+
RecurSieve: An Ensemble Learning Algorithm for Single-Cell Feature Selection Captures Subtle Gene Expression Patterns<br>
|
|
137
|
+
<i>bioRxiv link coming soon</i>
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ArpiarSaundersLab/RecurSieve/main/manuscript/logo_dark.png">
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ArpiarSaundersLab/RecurSieve/main/manuscript/logo_light.png">
|
|
5
|
+
<img src="https://raw.githubusercontent.com/ArpiarSaundersLab/RecurSieve/main/manuscript/logo_light.png" alt="Recursieve logo" width="360">
|
|
6
|
+
</picture>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
**RecurSieve** is an iterative gene selection algorithm that identifies discriminative genes between two biological groups in single-cell datasets. It uses an ensemble learning approach with a blend of random forest classifiers and gaussian mixture models to progressively select genes that best separate the groups, collapsing selected genes into a lower dimensional representational axis at each iteration.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Install from PyPI:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install recursieve
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
RecurSieve requires Python 3.12 or newer.
|
|
21
|
+
|
|
22
|
+
To install the development version from GitHub:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install git+https://github.com/ArpiarSaundersLab/RecurSieve.git
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
import anndata as ad
|
|
32
|
+
from recursieve import recursieve
|
|
33
|
+
|
|
34
|
+
adata = ad.read_h5ad("data/alz.h5ad")
|
|
35
|
+
model = recursieve(
|
|
36
|
+
adata=adata,
|
|
37
|
+
group1="control",
|
|
38
|
+
group2="disease",
|
|
39
|
+
field_name="condition",
|
|
40
|
+
max_iterations=100,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# all genes found
|
|
44
|
+
panel = model.genes
|
|
45
|
+
|
|
46
|
+
# genes unique to RecurSieve
|
|
47
|
+
non_de_genes = model.unique_gene_panel
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Parameters
|
|
51
|
+
|
|
52
|
+
| Parameter | Type | Default | Description |
|
|
53
|
+
|-----------|------|---------|-------------|
|
|
54
|
+
| adata | AnnData | required | Annotated data matrix |
|
|
55
|
+
| group1 | str | required | First group label |
|
|
56
|
+
| group2 | str | required | Second group label |
|
|
57
|
+
| field_name | str | "sample" | Column in obs containing group labels |
|
|
58
|
+
| plots | bool | False | Generate visualization plots |
|
|
59
|
+
| print_to_console | bool | False | Print selected genes during iteration |
|
|
60
|
+
| max_iterations | int | 100 | Maximum iterations to run |
|
|
61
|
+
| additive | bool | True | Add new genes to panel or replace |
|
|
62
|
+
| flip_rate_percentage | float | 0.01 | Stop when the label flip rate falls below this value |
|
|
63
|
+
| patience | int or None | 10 | Stop after this many iterations without a new flip-rate minimum (None disables) |
|
|
64
|
+
| pval_cutoff | float | 0.05 | P-value threshold for differential expression |
|
|
65
|
+
| logfc_cutoff | float | 0.1 | Absolute log2 fold-change threshold for differential expression |
|
|
66
|
+
| seed | int | 42 | Random seed for reproducibility |
|
|
67
|
+
| summary_method | str | "mean" | Method to collapse genes: "mean" or "pca" |
|
|
68
|
+
| n_estimators | int | 300 | Number of random forest trees |
|
|
69
|
+
| n_jobs | int | -1 | Number of parallel jobs (-1 uses all cores) |
|
|
70
|
+
| max_depth | int or None | 10 | Maximum random forest tree depth |
|
|
71
|
+
| n_seeds | int | 10 | Seeds used by `seed_stability()` |
|
|
72
|
+
| preprocess | bool | True | Run QC, normalization, and HVG selection |
|
|
73
|
+
| run | bool | True | Run the pipeline on construction; if False, call `fit()` later |
|
|
74
|
+
| annsql_db | str or None | None | AnnSQL database to load instead of `adata` |
|
|
75
|
+
|
|
76
|
+
## Robustness checks
|
|
77
|
+
|
|
78
|
+
`seed_stability` checks whether the same genes are selected with different random seeds. `coexpression_null` checks whether the selected genes are found more often than by chance, by rerunning on randomized data.
|
|
79
|
+
|
|
80
|
+
Each seed and each shuffle is a full RecurSieve run, so these checks take much longer than a single run. On a 10-core laptop, 25 shuffles took about 1.5 hours for 25,000 cells and about 3.5 hours for 50,000 cells.
|
|
81
|
+
|
|
82
|
+
Both methods return a dictionary of pandas DataFrames and do not write files. The example below runs both checks and saves the main tables as CSV files.
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
seeds = model.seed_stability(n_seeds=10)
|
|
86
|
+
null = model.coexpression_null(n_shuffles=25)
|
|
87
|
+
|
|
88
|
+
seeds["gene_frequency"].to_csv("seed_gene_frequency.csv", index=False)
|
|
89
|
+
null["pvalues"].to_csv("null_pvalues.csv", index=False)
|
|
90
|
+
null["gene_frequency"].to_csv("null_gene_frequency.csv", index=False)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
<br>
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
The RecurSieve software is released under the [MIT License](https://github.com/ArpiarSaundersLab/RecurSieve/blob/main/LICENSE). The data, figures, and tables in [`manuscript/`](https://github.com/ArpiarSaundersLab/RecurSieve/tree/main/manuscript) are dedicated to the public domain under [CC0 1.0](https://github.com/ArpiarSaundersLab/RecurSieve/blob/main/manuscript/LICENSE).
|
|
98
|
+
|
|
99
|
+
## Citation
|
|
100
|
+
|
|
101
|
+
RecurSieve: An Ensemble Learning Algorithm for Single-Cell Feature Selection Captures Subtle Gene Expression Patterns<br>
|
|
102
|
+
<i>bioRxiv link coming soon</i>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "recursieve"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Iterative gene selection algorithm for single-cell group comparisons"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.12"
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Kenny Pavan" }
|
|
13
|
+
]
|
|
14
|
+
license = "MIT"
|
|
15
|
+
license-files = ["LICENSE"]
|
|
16
|
+
keywords = ["single-cell", "scRNA-seq", "feature selection", "gene selection", "random forest", "anndata", "scanpy"]
|
|
17
|
+
classifiers = [
|
|
18
|
+
"Development Status :: 5 - Production/Stable",
|
|
19
|
+
"Intended Audience :: Science/Research",
|
|
20
|
+
"Operating System :: OS Independent",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Bio-Informatics",
|
|
24
|
+
]
|
|
25
|
+
dependencies = [
|
|
26
|
+
"AnnSQL>=1.0.3",
|
|
27
|
+
"anndata>=0.10",
|
|
28
|
+
"joblib>=1.3",
|
|
29
|
+
"matplotlib>=3.7",
|
|
30
|
+
"numpy>=1.24",
|
|
31
|
+
"pandas>=2.0",
|
|
32
|
+
"scanpy>=1.10",
|
|
33
|
+
"scikit-learn>=1.3",
|
|
34
|
+
"scipy>=1.10",
|
|
35
|
+
"seaborn>=0.13",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.optional-dependencies]
|
|
39
|
+
dev = ["pytest", "build", "twine"]
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/ArpiarSaundersLab/RecurSieve"
|
|
43
|
+
Source = "https://github.com/ArpiarSaundersLab/RecurSieve"
|
|
44
|
+
Issues = "https://github.com/ArpiarSaundersLab/RecurSieve/issues"
|
|
45
|
+
|
|
46
|
+
[tool.setuptools]
|
|
47
|
+
package-dir = {"" = "src"}
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.packages.find]
|
|
50
|
+
where = ["src"]
|