multiscoresplot 1.0.0__tar.gz → 1.0.2__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.
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/.gitignore +3 -1
- multiscoresplot-1.0.2/PKG-INFO +256 -0
- multiscoresplot-1.0.2/README.md +224 -0
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/pyproject.toml +15 -2
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/src/multiscoresplot/__init__.py +1 -1
- multiscoresplot-1.0.0/PKG-INFO +0 -85
- multiscoresplot-1.0.0/README.md +0 -53
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/.github/workflows/ci.yml +0 -0
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/.github/workflows/publish.yml +0 -0
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/.pre-commit-config.yaml +0 -0
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/LICENSE +0 -0
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/src/multiscoresplot/_colorspace.py +0 -0
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/src/multiscoresplot/_interactive.py +0 -0
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/src/multiscoresplot/_legend.py +0 -0
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/src/multiscoresplot/_plotting.py +0 -0
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/src/multiscoresplot/_scoring.py +0 -0
- {multiscoresplot-1.0.0 → multiscoresplot-1.0.2}/src/multiscoresplot/py.typed +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: multiscoresplot
|
|
3
|
+
Version: 1.0.2
|
|
4
|
+
Summary: Multi-dimensional gene set scoring and visualization for single-cell transcriptomics
|
|
5
|
+
Project-URL: Homepage, https://github.com/andrecmacedo/multiscoresplot
|
|
6
|
+
Project-URL: Repository, https://github.com/andrecmacedo/multiscoresplot
|
|
7
|
+
Project-URL: Issues, https://github.com/andrecmacedo/multiscoresplot/issues
|
|
8
|
+
Author: Andre Macedo
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: anndata>=0.10
|
|
24
|
+
Requires-Dist: matplotlib>=3.7
|
|
25
|
+
Requires-Dist: numpy>=1.24
|
|
26
|
+
Requires-Dist: pyucell>=0.5
|
|
27
|
+
Requires-Dist: scanpy>=1.9
|
|
28
|
+
Requires-Dist: scikit-learn>=1.3
|
|
29
|
+
Provides-Extra: interactive
|
|
30
|
+
Requires-Dist: plotly>=5.0; extra == 'interactive'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# multiscoresplot
|
|
34
|
+
|
|
35
|
+
[](https://github.com/AndreMacedo88/multiscoresplot/actions/workflows/ci.yml)
|
|
36
|
+
[](https://pypi.org/project/multiscoresplot/)
|
|
37
|
+
[](https://opensource.org/licenses/MIT)
|
|
38
|
+
[](https://pypi.org/project/multiscoresplot/)
|
|
39
|
+
|
|
40
|
+
**Multi-dimensional gene set scoring and visualization for single-cell transcriptomics.**
|
|
41
|
+
|
|
42
|
+
Color dimensionality reduction plots (UMAP, PCA, etc.) using a multi-dimensional color space derived from gene set scores — so you can visualize the activity of multiple gene programs simultaneously in a single plot.
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install multiscoresplot
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For interactive Plotly plots:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install 'multiscoresplot[interactive]'
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import multiscoresplot as msp
|
|
60
|
+
|
|
61
|
+
# Define gene sets of interest
|
|
62
|
+
gene_sets = {
|
|
63
|
+
"qNSCs": ["Id3", "Aldoc", "Slc1a3", ...],
|
|
64
|
+
"aNSCs": ["Egfr", "Ascl1", "Mki67", ...],
|
|
65
|
+
"TAP": ["Dll1", "Dcx", "Neurod1", ...],
|
|
66
|
+
"NB": ["Dcx", "Sox11", "Tubb3", ...],
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# 1. Score gene sets per cell
|
|
70
|
+
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
71
|
+
|
|
72
|
+
# 2. Map scores to RGB colors
|
|
73
|
+
rgb = msp.reduce_to_rgb(scores, method="pca")
|
|
74
|
+
|
|
75
|
+
# 3. Plot
|
|
76
|
+
msp.plot_embedding(
|
|
77
|
+
adata, rgb,
|
|
78
|
+
basis="umap",
|
|
79
|
+
method="pca",
|
|
80
|
+
gene_set_names=list(gene_sets.keys()),
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Pipeline
|
|
85
|
+
|
|
86
|
+
multiscoresplot follows a 5-step pipeline:
|
|
87
|
+
|
|
88
|
+
### Step 1 — Score gene sets
|
|
89
|
+
|
|
90
|
+
Calculate per-cell gene set scores using [pyUCell](https://github.com/Cem-Gulec/pyUCell). Scores are stored in `adata.obs` as `score-<name>` columns with values in [0, 1].
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
94
|
+
|
|
95
|
+
# Options
|
|
96
|
+
scores = msp.score_gene_sets(
|
|
97
|
+
adata, gene_sets,
|
|
98
|
+
max_rank=1500, # rank cap (tune to median genes per cell)
|
|
99
|
+
chunk_size=1000, # cells per batch
|
|
100
|
+
n_jobs=-1, # parallelism (-1 = all cores)
|
|
101
|
+
inplace=False, # don't store in adata.obs
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Step 2 — Blend to RGB (2–3 gene sets)
|
|
106
|
+
|
|
107
|
+
For 2–3 gene sets, use multiplicative blending from white. Each gene set darkens toward its base color proportional to the score.
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
# Default colors (2 sets: blue/red, 3 sets: R/G/B)
|
|
111
|
+
rgb = msp.blend_to_rgb(scores)
|
|
112
|
+
|
|
113
|
+
# Custom colors
|
|
114
|
+
rgb = msp.blend_to_rgb(scores, colors=[(1, 0, 0), (0, 0.5, 1)])
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Step 3 — Reduce to RGB (2+ gene sets)
|
|
118
|
+
|
|
119
|
+
For any number of gene sets (2 or more), use dimensionality reduction to map scores to 3 RGB channels. Built-in methods: PCA, NMF, and ICA.
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
rgb = msp.reduce_to_rgb(scores, method="pca") # default
|
|
123
|
+
rgb = msp.reduce_to_rgb(scores, method="nmf")
|
|
124
|
+
rgb = msp.reduce_to_rgb(scores, method="ica")
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Step 4 — Plot embedding
|
|
128
|
+
|
|
129
|
+
Scatter plot of embedding coordinates colored by RGB values, with an integrated color-space legend.
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
# Static matplotlib plot
|
|
133
|
+
msp.plot_embedding(
|
|
134
|
+
adata, rgb,
|
|
135
|
+
basis="umap",
|
|
136
|
+
method="pca",
|
|
137
|
+
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# Options
|
|
141
|
+
ax = msp.plot_embedding(
|
|
142
|
+
adata, rgb,
|
|
143
|
+
basis="umap",
|
|
144
|
+
method="pca",
|
|
145
|
+
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
146
|
+
legend=True, # show color legend (default)
|
|
147
|
+
legend_style="inset", # "inset" or "side"
|
|
148
|
+
legend_loc="lower right", # legend position
|
|
149
|
+
point_size=3,
|
|
150
|
+
alpha=0.8,
|
|
151
|
+
figsize=(6, 6),
|
|
152
|
+
title="SVZ lineage",
|
|
153
|
+
show=False, # return axes instead of displaying
|
|
154
|
+
)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Step 4b — Interactive plot (requires plotly)
|
|
158
|
+
|
|
159
|
+
WebGL-accelerated Plotly scatter plot with hover info showing gene set scores, RGB channel values, and custom metadata.
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
msp.plot_embedding_interactive(
|
|
163
|
+
adata, rgb,
|
|
164
|
+
basis="umap",
|
|
165
|
+
scores=scores,
|
|
166
|
+
method="nmf",
|
|
167
|
+
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
168
|
+
hover_columns=["n_counts", "cell_type"], # extra adata.obs columns
|
|
169
|
+
legend=True,
|
|
170
|
+
legend_loc="lower right",
|
|
171
|
+
point_size=2,
|
|
172
|
+
width=600,
|
|
173
|
+
height=500,
|
|
174
|
+
)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Step 5 — Standalone legend
|
|
178
|
+
|
|
179
|
+
Render the color-space legend on any matplotlib axes.
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
import matplotlib.pyplot as plt
|
|
183
|
+
|
|
184
|
+
fig, ax = plt.subplots()
|
|
185
|
+
|
|
186
|
+
# Direct mode (2-set square or 3-set triangle)
|
|
187
|
+
msp.render_legend(ax, "direct", gene_set_names=["A", "B", "C"])
|
|
188
|
+
|
|
189
|
+
# Reduction mode (RGB triangle with component labels)
|
|
190
|
+
msp.render_legend(ax, "pca")
|
|
191
|
+
msp.render_legend(ax, "nmf", component_labels=["NMF1", "NMF2", "NMF3"])
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Extensibility — Custom reducers
|
|
195
|
+
|
|
196
|
+
Register your own dimensionality reduction method:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
def my_umap_reducer(X, n_components, **kwargs):
|
|
200
|
+
"""X: (n_cells, n_gene_sets), returns (n_cells, 3) in [0, 1]."""
|
|
201
|
+
import umap
|
|
202
|
+
embedding = umap.UMAP(n_components=n_components, **kwargs).fit_transform(X)
|
|
203
|
+
# min-max normalize each column to [0, 1]
|
|
204
|
+
for j in range(embedding.shape[1]):
|
|
205
|
+
col = embedding[:, j]
|
|
206
|
+
lo, hi = col.min(), col.max()
|
|
207
|
+
if hi > lo:
|
|
208
|
+
embedding[:, j] = (col - lo) / (hi - lo)
|
|
209
|
+
return embedding
|
|
210
|
+
|
|
211
|
+
msp.register_reducer("umap", my_umap_reducer, component_prefix="UMAP")
|
|
212
|
+
|
|
213
|
+
# Now use it like any built-in method
|
|
214
|
+
rgb = msp.reduce_to_rgb(scores, method="umap")
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## API Reference
|
|
218
|
+
|
|
219
|
+
| Function | Description |
|
|
220
|
+
| --------------------------------------------------- | ----------------------------------------- |
|
|
221
|
+
| `score_gene_sets(adata, gene_sets)` | Score gene sets per cell via pyUCell |
|
|
222
|
+
| `blend_to_rgb(scores)` | Multiplicative blend to RGB (2–3 sets) |
|
|
223
|
+
| `reduce_to_rgb(scores, method="pca")` | Dimensionality reduction to RGB (2+ sets) |
|
|
224
|
+
| `plot_embedding(adata, rgb, basis=...)` | Static matplotlib scatter plot |
|
|
225
|
+
| `plot_embedding_interactive(adata, rgb, basis=...)` | Interactive Plotly scatter plot |
|
|
226
|
+
| `render_legend(ax, method)` | Draw color-space legend on axes |
|
|
227
|
+
| `register_reducer(name, fn)` | Register a custom reduction method |
|
|
228
|
+
| `get_component_labels(method)` | Get axis labels for a reduction method |
|
|
229
|
+
|
|
230
|
+
## Development
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
git clone https://github.com/andrecmacedo/multiscoresplot.git
|
|
234
|
+
cd multiscoresplot
|
|
235
|
+
|
|
236
|
+
# Install in editable mode with dev dependencies
|
|
237
|
+
pip install -e ".[interactive]"
|
|
238
|
+
pip install ruff pre-commit pytest pytest-cov mypy
|
|
239
|
+
|
|
240
|
+
# Run tests
|
|
241
|
+
pytest
|
|
242
|
+
|
|
243
|
+
# Lint & format
|
|
244
|
+
ruff check src/ tests/
|
|
245
|
+
ruff format src/ tests/
|
|
246
|
+
|
|
247
|
+
# Type check
|
|
248
|
+
mypy src/
|
|
249
|
+
|
|
250
|
+
# Set up pre-commit hooks
|
|
251
|
+
pre-commit install
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## License
|
|
255
|
+
|
|
256
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# multiscoresplot
|
|
2
|
+
|
|
3
|
+
[](https://github.com/AndreMacedo88/multiscoresplot/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/multiscoresplot/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://pypi.org/project/multiscoresplot/)
|
|
7
|
+
|
|
8
|
+
**Multi-dimensional gene set scoring and visualization for single-cell transcriptomics.**
|
|
9
|
+
|
|
10
|
+
Color dimensionality reduction plots (UMAP, PCA, etc.) using a multi-dimensional color space derived from gene set scores — so you can visualize the activity of multiple gene programs simultaneously in a single plot.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install multiscoresplot
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
For interactive Plotly plots:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install 'multiscoresplot[interactive]'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import multiscoresplot as msp
|
|
28
|
+
|
|
29
|
+
# Define gene sets of interest
|
|
30
|
+
gene_sets = {
|
|
31
|
+
"qNSCs": ["Id3", "Aldoc", "Slc1a3", ...],
|
|
32
|
+
"aNSCs": ["Egfr", "Ascl1", "Mki67", ...],
|
|
33
|
+
"TAP": ["Dll1", "Dcx", "Neurod1", ...],
|
|
34
|
+
"NB": ["Dcx", "Sox11", "Tubb3", ...],
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# 1. Score gene sets per cell
|
|
38
|
+
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
39
|
+
|
|
40
|
+
# 2. Map scores to RGB colors
|
|
41
|
+
rgb = msp.reduce_to_rgb(scores, method="pca")
|
|
42
|
+
|
|
43
|
+
# 3. Plot
|
|
44
|
+
msp.plot_embedding(
|
|
45
|
+
adata, rgb,
|
|
46
|
+
basis="umap",
|
|
47
|
+
method="pca",
|
|
48
|
+
gene_set_names=list(gene_sets.keys()),
|
|
49
|
+
)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Pipeline
|
|
53
|
+
|
|
54
|
+
multiscoresplot follows a 5-step pipeline:
|
|
55
|
+
|
|
56
|
+
### Step 1 — Score gene sets
|
|
57
|
+
|
|
58
|
+
Calculate per-cell gene set scores using [pyUCell](https://github.com/Cem-Gulec/pyUCell). Scores are stored in `adata.obs` as `score-<name>` columns with values in [0, 1].
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
62
|
+
|
|
63
|
+
# Options
|
|
64
|
+
scores = msp.score_gene_sets(
|
|
65
|
+
adata, gene_sets,
|
|
66
|
+
max_rank=1500, # rank cap (tune to median genes per cell)
|
|
67
|
+
chunk_size=1000, # cells per batch
|
|
68
|
+
n_jobs=-1, # parallelism (-1 = all cores)
|
|
69
|
+
inplace=False, # don't store in adata.obs
|
|
70
|
+
)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Step 2 — Blend to RGB (2–3 gene sets)
|
|
74
|
+
|
|
75
|
+
For 2–3 gene sets, use multiplicative blending from white. Each gene set darkens toward its base color proportional to the score.
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
# Default colors (2 sets: blue/red, 3 sets: R/G/B)
|
|
79
|
+
rgb = msp.blend_to_rgb(scores)
|
|
80
|
+
|
|
81
|
+
# Custom colors
|
|
82
|
+
rgb = msp.blend_to_rgb(scores, colors=[(1, 0, 0), (0, 0.5, 1)])
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Step 3 — Reduce to RGB (2+ gene sets)
|
|
86
|
+
|
|
87
|
+
For any number of gene sets (2 or more), use dimensionality reduction to map scores to 3 RGB channels. Built-in methods: PCA, NMF, and ICA.
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
rgb = msp.reduce_to_rgb(scores, method="pca") # default
|
|
91
|
+
rgb = msp.reduce_to_rgb(scores, method="nmf")
|
|
92
|
+
rgb = msp.reduce_to_rgb(scores, method="ica")
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Step 4 — Plot embedding
|
|
96
|
+
|
|
97
|
+
Scatter plot of embedding coordinates colored by RGB values, with an integrated color-space legend.
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
# Static matplotlib plot
|
|
101
|
+
msp.plot_embedding(
|
|
102
|
+
adata, rgb,
|
|
103
|
+
basis="umap",
|
|
104
|
+
method="pca",
|
|
105
|
+
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# Options
|
|
109
|
+
ax = msp.plot_embedding(
|
|
110
|
+
adata, rgb,
|
|
111
|
+
basis="umap",
|
|
112
|
+
method="pca",
|
|
113
|
+
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
114
|
+
legend=True, # show color legend (default)
|
|
115
|
+
legend_style="inset", # "inset" or "side"
|
|
116
|
+
legend_loc="lower right", # legend position
|
|
117
|
+
point_size=3,
|
|
118
|
+
alpha=0.8,
|
|
119
|
+
figsize=(6, 6),
|
|
120
|
+
title="SVZ lineage",
|
|
121
|
+
show=False, # return axes instead of displaying
|
|
122
|
+
)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Step 4b — Interactive plot (requires plotly)
|
|
126
|
+
|
|
127
|
+
WebGL-accelerated Plotly scatter plot with hover info showing gene set scores, RGB channel values, and custom metadata.
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
msp.plot_embedding_interactive(
|
|
131
|
+
adata, rgb,
|
|
132
|
+
basis="umap",
|
|
133
|
+
scores=scores,
|
|
134
|
+
method="nmf",
|
|
135
|
+
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
136
|
+
hover_columns=["n_counts", "cell_type"], # extra adata.obs columns
|
|
137
|
+
legend=True,
|
|
138
|
+
legend_loc="lower right",
|
|
139
|
+
point_size=2,
|
|
140
|
+
width=600,
|
|
141
|
+
height=500,
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Step 5 — Standalone legend
|
|
146
|
+
|
|
147
|
+
Render the color-space legend on any matplotlib axes.
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
import matplotlib.pyplot as plt
|
|
151
|
+
|
|
152
|
+
fig, ax = plt.subplots()
|
|
153
|
+
|
|
154
|
+
# Direct mode (2-set square or 3-set triangle)
|
|
155
|
+
msp.render_legend(ax, "direct", gene_set_names=["A", "B", "C"])
|
|
156
|
+
|
|
157
|
+
# Reduction mode (RGB triangle with component labels)
|
|
158
|
+
msp.render_legend(ax, "pca")
|
|
159
|
+
msp.render_legend(ax, "nmf", component_labels=["NMF1", "NMF2", "NMF3"])
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Extensibility — Custom reducers
|
|
163
|
+
|
|
164
|
+
Register your own dimensionality reduction method:
|
|
165
|
+
|
|
166
|
+
```python
|
|
167
|
+
def my_umap_reducer(X, n_components, **kwargs):
|
|
168
|
+
"""X: (n_cells, n_gene_sets), returns (n_cells, 3) in [0, 1]."""
|
|
169
|
+
import umap
|
|
170
|
+
embedding = umap.UMAP(n_components=n_components, **kwargs).fit_transform(X)
|
|
171
|
+
# min-max normalize each column to [0, 1]
|
|
172
|
+
for j in range(embedding.shape[1]):
|
|
173
|
+
col = embedding[:, j]
|
|
174
|
+
lo, hi = col.min(), col.max()
|
|
175
|
+
if hi > lo:
|
|
176
|
+
embedding[:, j] = (col - lo) / (hi - lo)
|
|
177
|
+
return embedding
|
|
178
|
+
|
|
179
|
+
msp.register_reducer("umap", my_umap_reducer, component_prefix="UMAP")
|
|
180
|
+
|
|
181
|
+
# Now use it like any built-in method
|
|
182
|
+
rgb = msp.reduce_to_rgb(scores, method="umap")
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## API Reference
|
|
186
|
+
|
|
187
|
+
| Function | Description |
|
|
188
|
+
| --------------------------------------------------- | ----------------------------------------- |
|
|
189
|
+
| `score_gene_sets(adata, gene_sets)` | Score gene sets per cell via pyUCell |
|
|
190
|
+
| `blend_to_rgb(scores)` | Multiplicative blend to RGB (2–3 sets) |
|
|
191
|
+
| `reduce_to_rgb(scores, method="pca")` | Dimensionality reduction to RGB (2+ sets) |
|
|
192
|
+
| `plot_embedding(adata, rgb, basis=...)` | Static matplotlib scatter plot |
|
|
193
|
+
| `plot_embedding_interactive(adata, rgb, basis=...)` | Interactive Plotly scatter plot |
|
|
194
|
+
| `render_legend(ax, method)` | Draw color-space legend on axes |
|
|
195
|
+
| `register_reducer(name, fn)` | Register a custom reduction method |
|
|
196
|
+
| `get_component_labels(method)` | Get axis labels for a reduction method |
|
|
197
|
+
|
|
198
|
+
## Development
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
git clone https://github.com/andrecmacedo/multiscoresplot.git
|
|
202
|
+
cd multiscoresplot
|
|
203
|
+
|
|
204
|
+
# Install in editable mode with dev dependencies
|
|
205
|
+
pip install -e ".[interactive]"
|
|
206
|
+
pip install ruff pre-commit pytest pytest-cov mypy
|
|
207
|
+
|
|
208
|
+
# Run tests
|
|
209
|
+
pytest
|
|
210
|
+
|
|
211
|
+
# Lint & format
|
|
212
|
+
ruff check src/ tests/
|
|
213
|
+
ruff format src/ tests/
|
|
214
|
+
|
|
215
|
+
# Type check
|
|
216
|
+
mypy src/
|
|
217
|
+
|
|
218
|
+
# Set up pre-commit hooks
|
|
219
|
+
pre-commit install
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
[MIT](LICENSE)
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "multiscoresplot"
|
|
7
|
-
version = "1.0.
|
|
7
|
+
version = "1.0.2"
|
|
8
8
|
description = "Multi-dimensional gene set scoring and visualization for single-cell transcriptomics"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -79,7 +79,20 @@ warn_unused_configs = true
|
|
|
79
79
|
disallow_untyped_defs = false
|
|
80
80
|
|
|
81
81
|
[[tool.mypy.overrides]]
|
|
82
|
-
module = [
|
|
82
|
+
module = [
|
|
83
|
+
"pyucell",
|
|
84
|
+
"pyucell.*",
|
|
85
|
+
"anndata",
|
|
86
|
+
"anndata.*",
|
|
87
|
+
"scanpy",
|
|
88
|
+
"scanpy.*",
|
|
89
|
+
"pandas",
|
|
90
|
+
"pandas.*",
|
|
91
|
+
"sklearn",
|
|
92
|
+
"sklearn.*",
|
|
93
|
+
"plotly",
|
|
94
|
+
"plotly.*",
|
|
95
|
+
]
|
|
83
96
|
ignore_missing_imports = true
|
|
84
97
|
disable_error_code = ["import-untyped"]
|
|
85
98
|
|
multiscoresplot-1.0.0/PKG-INFO
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: multiscoresplot
|
|
3
|
-
Version: 1.0.0
|
|
4
|
-
Summary: Multi-dimensional gene set scoring and visualization for single-cell transcriptomics
|
|
5
|
-
Project-URL: Homepage, https://github.com/andrecmacedo/multiscoresplot
|
|
6
|
-
Project-URL: Repository, https://github.com/andrecmacedo/multiscoresplot
|
|
7
|
-
Project-URL: Issues, https://github.com/andrecmacedo/multiscoresplot/issues
|
|
8
|
-
Author: Andre Macedo
|
|
9
|
-
License-Expression: MIT
|
|
10
|
-
License-File: LICENSE
|
|
11
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
-
Classifier: Intended Audience :: Science/Research
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
-
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
20
|
-
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
21
|
-
Classifier: Typing :: Typed
|
|
22
|
-
Requires-Python: >=3.10
|
|
23
|
-
Requires-Dist: anndata>=0.10
|
|
24
|
-
Requires-Dist: matplotlib>=3.7
|
|
25
|
-
Requires-Dist: numpy>=1.24
|
|
26
|
-
Requires-Dist: pyucell>=0.5
|
|
27
|
-
Requires-Dist: scanpy>=1.9
|
|
28
|
-
Requires-Dist: scikit-learn>=1.3
|
|
29
|
-
Provides-Extra: interactive
|
|
30
|
-
Requires-Dist: plotly>=5.0; extra == 'interactive'
|
|
31
|
-
Description-Content-Type: text/markdown
|
|
32
|
-
|
|
33
|
-
# multiscoresplot
|
|
34
|
-
|
|
35
|
-
[](https://github.com/andrecmacedo/multiscoresplot/actions/workflows/ci.yml)
|
|
36
|
-
[](https://pypi.org/project/multiscoresplot/)
|
|
37
|
-
[](https://opensource.org/licenses/MIT)
|
|
38
|
-
|
|
39
|
-
Multi-dimensional gene set scoring and visualization for single-cell transcriptomics.
|
|
40
|
-
|
|
41
|
-
Color dimensionality reduction plots (UMAP, PCA, etc.) using a multi-dimensional color space derived from gene set scores.
|
|
42
|
-
|
|
43
|
-
## Installation
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
pip install multiscoresplot
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Quick Start
|
|
50
|
-
|
|
51
|
-
```python
|
|
52
|
-
import multiscoresplot # more to come!
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Pipeline
|
|
56
|
-
|
|
57
|
-
1. **Score** -- Calculate gene set scores per cell
|
|
58
|
-
2. **Color space** -- Build a color space where each axis/vertex maps to a gene set
|
|
59
|
-
3. **Project** -- Map each cell into the color space based on its scores
|
|
60
|
-
4. **Plot** -- Color dimensionality reduction coordinates using the projected colors
|
|
61
|
-
5. **Legend** -- Render a simplex/ternary plot as the colorbar
|
|
62
|
-
|
|
63
|
-
## Development
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
# Install in editable mode with all dev dependencies
|
|
67
|
-
pip install -e ".[dev,test,type]"
|
|
68
|
-
|
|
69
|
-
# Run tests
|
|
70
|
-
pytest
|
|
71
|
-
|
|
72
|
-
# Lint & format
|
|
73
|
-
ruff check src/ tests/
|
|
74
|
-
ruff format src/ tests/
|
|
75
|
-
|
|
76
|
-
# Type check
|
|
77
|
-
mypy src/
|
|
78
|
-
|
|
79
|
-
# Set up pre-commit hooks
|
|
80
|
-
pre-commit install
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## License
|
|
84
|
-
|
|
85
|
-
[MIT](LICENSE)
|
multiscoresplot-1.0.0/README.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# multiscoresplot
|
|
2
|
-
|
|
3
|
-
[](https://github.com/andrecmacedo/multiscoresplot/actions/workflows/ci.yml)
|
|
4
|
-
[](https://pypi.org/project/multiscoresplot/)
|
|
5
|
-
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
|
|
7
|
-
Multi-dimensional gene set scoring and visualization for single-cell transcriptomics.
|
|
8
|
-
|
|
9
|
-
Color dimensionality reduction plots (UMAP, PCA, etc.) using a multi-dimensional color space derived from gene set scores.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
pip install multiscoresplot
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Quick Start
|
|
18
|
-
|
|
19
|
-
```python
|
|
20
|
-
import multiscoresplot # more to come!
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## Pipeline
|
|
24
|
-
|
|
25
|
-
1. **Score** -- Calculate gene set scores per cell
|
|
26
|
-
2. **Color space** -- Build a color space where each axis/vertex maps to a gene set
|
|
27
|
-
3. **Project** -- Map each cell into the color space based on its scores
|
|
28
|
-
4. **Plot** -- Color dimensionality reduction coordinates using the projected colors
|
|
29
|
-
5. **Legend** -- Render a simplex/ternary plot as the colorbar
|
|
30
|
-
|
|
31
|
-
## Development
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
# Install in editable mode with all dev dependencies
|
|
35
|
-
pip install -e ".[dev,test,type]"
|
|
36
|
-
|
|
37
|
-
# Run tests
|
|
38
|
-
pytest
|
|
39
|
-
|
|
40
|
-
# Lint & format
|
|
41
|
-
ruff check src/ tests/
|
|
42
|
-
ruff format src/ tests/
|
|
43
|
-
|
|
44
|
-
# Type check
|
|
45
|
-
mypy src/
|
|
46
|
-
|
|
47
|
-
# Set up pre-commit hooks
|
|
48
|
-
pre-commit install
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## License
|
|
52
|
-
|
|
53
|
-
[MIT](LICENSE)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|