multiscoresplot 1.0.3__tar.gz → 1.0.6__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.6/.github/workflows/docs.yml +27 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/.pre-commit-config.yaml +1 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/PKG-INFO +28 -19
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/README.md +23 -15
- multiscoresplot-1.0.6/docs/api/colorspace.md +25 -0
- multiscoresplot-1.0.6/docs/api/index.md +27 -0
- multiscoresplot-1.0.6/docs/api/interactive.md +8 -0
- multiscoresplot-1.0.6/docs/api/legend.md +5 -0
- multiscoresplot-1.0.6/docs/api/plotting.md +5 -0
- multiscoresplot-1.0.6/docs/api/scoring.md +5 -0
- multiscoresplot-1.0.6/docs/changelog.md +19 -0
- multiscoresplot-1.0.6/docs/examples.md +165 -0
- multiscoresplot-1.0.6/docs/getting-started.md +64 -0
- multiscoresplot-1.0.6/docs/index.md +45 -0
- multiscoresplot-1.0.6/docs/pipeline.md +213 -0
- multiscoresplot-1.0.6/mkdocs.yml +92 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/pyproject.toml +7 -5
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/src/multiscoresplot/__init__.py +1 -1
- multiscoresplot-1.0.6/uv.lock +2784 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/.github/workflows/ci.yml +0 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/.github/workflows/publish.yml +0 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/.gitignore +0 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/LICENSE +0 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/src/multiscoresplot/_colorspace.py +0 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/src/multiscoresplot/_interactive.py +0 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/src/multiscoresplot/_legend.py +0 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/src/multiscoresplot/_plotting.py +0 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/src/multiscoresplot/_scoring.py +0 -0
- {multiscoresplot-1.0.3 → multiscoresplot-1.0.6}/src/multiscoresplot/py.typed +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Deploy Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
deploy:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
|
|
17
|
+
- uses: astral-sh/setup-uv@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: "3.12"
|
|
20
|
+
|
|
21
|
+
- name: Configure git for gh-deploy
|
|
22
|
+
run: |
|
|
23
|
+
git config user.name "github-actions[bot]"
|
|
24
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
25
|
+
|
|
26
|
+
- name: Deploy to GitHub Pages
|
|
27
|
+
run: uv run --group docs mkdocs gh-deploy --force
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiscoresplot
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.6
|
|
4
4
|
Summary: Multi-dimensional gene set scoring and visualization for single-cell transcriptomics
|
|
5
|
-
Project-URL: Homepage, https://github.com/
|
|
6
|
-
Project-URL:
|
|
7
|
-
Project-URL:
|
|
5
|
+
Project-URL: Homepage, https://github.com/AndreMacedo88/multiscoresplot
|
|
6
|
+
Project-URL: Documentation, https://AndreMacedo88.github.io/multiscoresplot/
|
|
7
|
+
Project-URL: Repository, https://github.com/AndreMacedo88/multiscoresplot
|
|
8
|
+
Project-URL: Issues, https://github.com/AndreMacedo88/multiscoresplot/issues
|
|
8
9
|
Author: Andre Macedo
|
|
9
10
|
License-Expression: MIT
|
|
10
11
|
License-File: LICENSE
|
|
@@ -33,9 +34,10 @@ Description-Content-Type: text/markdown
|
|
|
33
34
|
# multiscoresplot
|
|
34
35
|
|
|
35
36
|
[](https://github.com/AndreMacedo88/multiscoresplot/actions/workflows/ci.yml)
|
|
36
|
-
[](https://AndreMacedo88.github.io/multiscoresplot/)
|
|
38
|
+
[](https://pypi.org/project/multiscoresplot/)
|
|
39
|
+
[](https://pypi.org/project/multiscoresplot/)
|
|
37
40
|
[](https://opensource.org/licenses/MIT)
|
|
38
|
-
[](https://pypi.org/project/multiscoresplot/)
|
|
39
41
|
|
|
40
42
|
**Multi-dimensional gene set scoring and visualization for single-cell transcriptomics.**
|
|
41
43
|
|
|
@@ -83,7 +85,7 @@ msp.plot_embedding(
|
|
|
83
85
|
|
|
84
86
|
## Pipeline
|
|
85
87
|
|
|
86
|
-
multiscoresplot follows a
|
|
88
|
+
multiscoresplot follows a 3-step pipeline:
|
|
87
89
|
|
|
88
90
|
### Step 1 — Score gene sets
|
|
89
91
|
|
|
@@ -102,9 +104,11 @@ scores = msp.score_gene_sets(
|
|
|
102
104
|
)
|
|
103
105
|
```
|
|
104
106
|
|
|
105
|
-
### Step 2 —
|
|
107
|
+
### Step 2 — Map scores to RGB
|
|
106
108
|
|
|
107
|
-
|
|
109
|
+
Convert gene set scores into per-cell RGB colors. Two options depending on how many gene sets you want to visualize:
|
|
110
|
+
|
|
111
|
+
**Blend (2–3 gene sets)** — multiplicative blending from white, where each gene set darkens toward its base color proportional to the score.
|
|
108
112
|
|
|
109
113
|
```python
|
|
110
114
|
# Default colors (2 sets: blue/red, 3 sets: R/G/B)
|
|
@@ -114,9 +118,7 @@ rgb = msp.blend_to_rgb(scores)
|
|
|
114
118
|
rgb = msp.blend_to_rgb(scores, colors=[(1, 0, 0), (0, 0.5, 1)])
|
|
115
119
|
```
|
|
116
120
|
|
|
117
|
-
|
|
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.
|
|
121
|
+
**Reduce (2+ gene sets)** — dimensionality reduction maps scores to 3 RGB channels. Built-in methods: PCA, NMF, and ICA.
|
|
120
122
|
|
|
121
123
|
```python
|
|
122
124
|
rgb = msp.reduce_to_rgb(scores, method="pca") # default
|
|
@@ -124,7 +126,7 @@ rgb = msp.reduce_to_rgb(scores, method="nmf")
|
|
|
124
126
|
rgb = msp.reduce_to_rgb(scores, method="ica")
|
|
125
127
|
```
|
|
126
128
|
|
|
127
|
-
### Step
|
|
129
|
+
### Step 3 — Plot embedding
|
|
128
130
|
|
|
129
131
|
Scatter plot of embedding coordinates colored by RGB values, with an integrated color-space legend.
|
|
130
132
|
|
|
@@ -154,9 +156,7 @@ ax = msp.plot_embedding(
|
|
|
154
156
|
)
|
|
155
157
|
```
|
|
156
158
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
WebGL-accelerated Plotly scatter plot with hover info showing gene set scores, RGB channel values, and custom metadata.
|
|
159
|
+
**Interactive plot (requires plotly)** — WebGL-accelerated scatter plot with hover info showing gene set scores, RGB channel values, and custom metadata.
|
|
160
160
|
|
|
161
161
|
```python
|
|
162
162
|
msp.plot_embedding_interactive(
|
|
@@ -174,9 +174,9 @@ msp.plot_embedding_interactive(
|
|
|
174
174
|
)
|
|
175
175
|
```
|
|
176
176
|
|
|
177
|
-
###
|
|
177
|
+
### Optional — Standalone legend
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
The plotting functions above include an integrated legend by default. If you need to render the legend separately (e.g., for a custom figure layout):
|
|
180
180
|
|
|
181
181
|
```python
|
|
182
182
|
import matplotlib.pyplot as plt
|
|
@@ -214,6 +214,15 @@ msp.register_reducer("umap", my_umap_reducer, component_prefix="UMAP")
|
|
|
214
214
|
rgb = msp.reduce_to_rgb(scores, method="umap")
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
+
## Documentation
|
|
218
|
+
|
|
219
|
+
Full documentation is available at **[AndreMacedo88.github.io/multiscoresplot](https://AndreMacedo88.github.io/multiscoresplot/)**, including:
|
|
220
|
+
|
|
221
|
+
- [Getting Started](https://AndreMacedo88.github.io/multiscoresplot/getting-started/) — installation and quick start
|
|
222
|
+
- [Pipeline Guide](https://AndreMacedo88.github.io/multiscoresplot/pipeline/) — detailed pipeline tutorial
|
|
223
|
+
- [API Reference](https://AndreMacedo88.github.io/multiscoresplot/api/) — full function signatures and parameters
|
|
224
|
+
- [Examples](https://AndreMacedo88.github.io/multiscoresplot/examples/) — custom reducers, plot customization, and more
|
|
225
|
+
|
|
217
226
|
## API Reference
|
|
218
227
|
|
|
219
228
|
| Function | Description |
|
|
@@ -230,7 +239,7 @@ rgb = msp.reduce_to_rgb(scores, method="umap")
|
|
|
230
239
|
## Development
|
|
231
240
|
|
|
232
241
|
```bash
|
|
233
|
-
git clone https://github.com/
|
|
242
|
+
git clone https://github.com/AndreMacedo88/multiscoresplot.git
|
|
234
243
|
cd multiscoresplot
|
|
235
244
|
|
|
236
245
|
# Install in editable mode with dev dependencies
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# multiscoresplot
|
|
2
2
|
|
|
3
3
|
[](https://github.com/AndreMacedo88/multiscoresplot/actions/workflows/ci.yml)
|
|
4
|
-
[](https://AndreMacedo88.github.io/multiscoresplot/)
|
|
5
|
+
[](https://pypi.org/project/multiscoresplot/)
|
|
6
|
+
[](https://pypi.org/project/multiscoresplot/)
|
|
5
7
|
[](https://opensource.org/licenses/MIT)
|
|
6
|
-
[](https://pypi.org/project/multiscoresplot/)
|
|
7
8
|
|
|
8
9
|
**Multi-dimensional gene set scoring and visualization for single-cell transcriptomics.**
|
|
9
10
|
|
|
@@ -51,7 +52,7 @@ msp.plot_embedding(
|
|
|
51
52
|
|
|
52
53
|
## Pipeline
|
|
53
54
|
|
|
54
|
-
multiscoresplot follows a
|
|
55
|
+
multiscoresplot follows a 3-step pipeline:
|
|
55
56
|
|
|
56
57
|
### Step 1 — Score gene sets
|
|
57
58
|
|
|
@@ -70,9 +71,11 @@ scores = msp.score_gene_sets(
|
|
|
70
71
|
)
|
|
71
72
|
```
|
|
72
73
|
|
|
73
|
-
### Step 2 —
|
|
74
|
+
### Step 2 — Map scores to RGB
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
Convert gene set scores into per-cell RGB colors. Two options depending on how many gene sets you want to visualize:
|
|
77
|
+
|
|
78
|
+
**Blend (2–3 gene sets)** — multiplicative blending from white, where each gene set darkens toward its base color proportional to the score.
|
|
76
79
|
|
|
77
80
|
```python
|
|
78
81
|
# Default colors (2 sets: blue/red, 3 sets: R/G/B)
|
|
@@ -82,9 +85,7 @@ rgb = msp.blend_to_rgb(scores)
|
|
|
82
85
|
rgb = msp.blend_to_rgb(scores, colors=[(1, 0, 0), (0, 0.5, 1)])
|
|
83
86
|
```
|
|
84
87
|
|
|
85
|
-
|
|
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
|
+
**Reduce (2+ gene sets)** — dimensionality reduction maps scores to 3 RGB channels. Built-in methods: PCA, NMF, and ICA.
|
|
88
89
|
|
|
89
90
|
```python
|
|
90
91
|
rgb = msp.reduce_to_rgb(scores, method="pca") # default
|
|
@@ -92,7 +93,7 @@ rgb = msp.reduce_to_rgb(scores, method="nmf")
|
|
|
92
93
|
rgb = msp.reduce_to_rgb(scores, method="ica")
|
|
93
94
|
```
|
|
94
95
|
|
|
95
|
-
### Step
|
|
96
|
+
### Step 3 — Plot embedding
|
|
96
97
|
|
|
97
98
|
Scatter plot of embedding coordinates colored by RGB values, with an integrated color-space legend.
|
|
98
99
|
|
|
@@ -122,9 +123,7 @@ ax = msp.plot_embedding(
|
|
|
122
123
|
)
|
|
123
124
|
```
|
|
124
125
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
WebGL-accelerated Plotly scatter plot with hover info showing gene set scores, RGB channel values, and custom metadata.
|
|
126
|
+
**Interactive plot (requires plotly)** — WebGL-accelerated scatter plot with hover info showing gene set scores, RGB channel values, and custom metadata.
|
|
128
127
|
|
|
129
128
|
```python
|
|
130
129
|
msp.plot_embedding_interactive(
|
|
@@ -142,9 +141,9 @@ msp.plot_embedding_interactive(
|
|
|
142
141
|
)
|
|
143
142
|
```
|
|
144
143
|
|
|
145
|
-
###
|
|
144
|
+
### Optional — Standalone legend
|
|
146
145
|
|
|
147
|
-
|
|
146
|
+
The plotting functions above include an integrated legend by default. If you need to render the legend separately (e.g., for a custom figure layout):
|
|
148
147
|
|
|
149
148
|
```python
|
|
150
149
|
import matplotlib.pyplot as plt
|
|
@@ -182,6 +181,15 @@ msp.register_reducer("umap", my_umap_reducer, component_prefix="UMAP")
|
|
|
182
181
|
rgb = msp.reduce_to_rgb(scores, method="umap")
|
|
183
182
|
```
|
|
184
183
|
|
|
184
|
+
## Documentation
|
|
185
|
+
|
|
186
|
+
Full documentation is available at **[AndreMacedo88.github.io/multiscoresplot](https://AndreMacedo88.github.io/multiscoresplot/)**, including:
|
|
187
|
+
|
|
188
|
+
- [Getting Started](https://AndreMacedo88.github.io/multiscoresplot/getting-started/) — installation and quick start
|
|
189
|
+
- [Pipeline Guide](https://AndreMacedo88.github.io/multiscoresplot/pipeline/) — detailed pipeline tutorial
|
|
190
|
+
- [API Reference](https://AndreMacedo88.github.io/multiscoresplot/api/) — full function signatures and parameters
|
|
191
|
+
- [Examples](https://AndreMacedo88.github.io/multiscoresplot/examples/) — custom reducers, plot customization, and more
|
|
192
|
+
|
|
185
193
|
## API Reference
|
|
186
194
|
|
|
187
195
|
| Function | Description |
|
|
@@ -198,7 +206,7 @@ rgb = msp.reduce_to_rgb(scores, method="umap")
|
|
|
198
206
|
## Development
|
|
199
207
|
|
|
200
208
|
```bash
|
|
201
|
-
git clone https://github.com/
|
|
209
|
+
git clone https://github.com/AndreMacedo88/multiscoresplot.git
|
|
202
210
|
cd multiscoresplot
|
|
203
211
|
|
|
204
212
|
# Install in editable mode with dev dependencies
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Color Space
|
|
2
|
+
|
|
3
|
+
Color mapping from gene set scores to RGB (pipeline steps 2–3).
|
|
4
|
+
|
|
5
|
+
## Blending (2–3 gene sets)
|
|
6
|
+
|
|
7
|
+
::: multiscoresplot.blend_to_rgb
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Dimensionality Reduction (2+ gene sets)
|
|
12
|
+
|
|
13
|
+
::: multiscoresplot.reduce_to_rgb
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Custom Reducers
|
|
18
|
+
|
|
19
|
+
::: multiscoresplot.register_reducer
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Utility
|
|
24
|
+
|
|
25
|
+
::: multiscoresplot.get_component_labels
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
| Function | Description | Pipeline Step |
|
|
6
|
+
|----------|-------------|---------------|
|
|
7
|
+
| [`score_gene_sets`](scoring.md) | Score gene sets per cell via pyUCell | Step 1 |
|
|
8
|
+
| [`blend_to_rgb`](colorspace.md#multiscoresplot.blend_to_rgb) | Multiplicative blend to RGB (2–3 sets) | Step 2 |
|
|
9
|
+
| [`reduce_to_rgb`](colorspace.md#multiscoresplot.reduce_to_rgb) | Dimensionality reduction to RGB (2+ sets) | Step 2 |
|
|
10
|
+
| [`plot_embedding`](plotting.md) | Static matplotlib scatter plot | Step 3 |
|
|
11
|
+
| [`plot_embedding_interactive`](interactive.md) | Interactive Plotly scatter plot | Step 3 |
|
|
12
|
+
| [`render_legend`](legend.md) | Draw color-space legend on axes | Optional |
|
|
13
|
+
| [`register_reducer`](colorspace.md#multiscoresplot.register_reducer) | Register a custom reduction method | Extensibility |
|
|
14
|
+
| [`get_component_labels`](colorspace.md#multiscoresplot.get_component_labels) | Get axis labels for a reduction method | Utility |
|
|
15
|
+
|
|
16
|
+
## Module Layout
|
|
17
|
+
|
|
18
|
+
All public functions are available directly from the top-level `multiscoresplot` namespace:
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import multiscoresplot as msp
|
|
22
|
+
|
|
23
|
+
msp.score_gene_sets(...)
|
|
24
|
+
msp.blend_to_rgb(...)
|
|
25
|
+
msp.reduce_to_rgb(...)
|
|
26
|
+
msp.plot_embedding(...)
|
|
27
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.3
|
|
4
|
+
|
|
5
|
+
- Fix badge display in README
|
|
6
|
+
|
|
7
|
+
## 1.0.2
|
|
8
|
+
|
|
9
|
+
- Fix legend not being plotted in interactive "direct" methods
|
|
10
|
+
- Fix CI badge path in README
|
|
11
|
+
|
|
12
|
+
## 1.0.1
|
|
13
|
+
|
|
14
|
+
- Initial stable release
|
|
15
|
+
- 5-step pipeline: score, blend, reduce, plot, legend
|
|
16
|
+
- Built-in reducers: PCA, NMF, ICA
|
|
17
|
+
- Pluggable reducer registry
|
|
18
|
+
- Static matplotlib and interactive Plotly plotting
|
|
19
|
+
- Color-space legends for direct and reduction modes
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Examples
|
|
2
|
+
|
|
3
|
+
## Custom Reducer — UMAP
|
|
4
|
+
|
|
5
|
+
Register your own dimensionality reduction method and use it like any built-in:
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
import multiscoresplot as msp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def umap_reducer(X, n_components, **kwargs):
|
|
12
|
+
"""Reduce score matrix to RGB via UMAP.
|
|
13
|
+
|
|
14
|
+
Parameters
|
|
15
|
+
----------
|
|
16
|
+
X : ndarray of shape (n_cells, n_gene_sets)
|
|
17
|
+
Score matrix.
|
|
18
|
+
n_components : int
|
|
19
|
+
Number of output components (always 3 for RGB).
|
|
20
|
+
|
|
21
|
+
Returns
|
|
22
|
+
-------
|
|
23
|
+
ndarray of shape (n_cells, 3)
|
|
24
|
+
Embedding with values in [0, 1].
|
|
25
|
+
"""
|
|
26
|
+
import umap
|
|
27
|
+
|
|
28
|
+
embedding = umap.UMAP(n_components=n_components, **kwargs).fit_transform(X)
|
|
29
|
+
# min-max normalize each column to [0, 1]
|
|
30
|
+
for j in range(embedding.shape[1]):
|
|
31
|
+
col = embedding[:, j]
|
|
32
|
+
lo, hi = col.min(), col.max()
|
|
33
|
+
if hi > lo:
|
|
34
|
+
embedding[:, j] = (col - lo) / (hi - lo)
|
|
35
|
+
return embedding
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# Register it
|
|
39
|
+
msp.register_reducer("umap", umap_reducer, component_prefix="UMAP")
|
|
40
|
+
|
|
41
|
+
# Use it
|
|
42
|
+
rgb = msp.reduce_to_rgb(scores, method="umap")
|
|
43
|
+
msp.plot_embedding(adata, rgb, basis="umap", method="umap",
|
|
44
|
+
gene_set_names=list(gene_sets.keys()))
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Different Embeddings
|
|
48
|
+
|
|
49
|
+
Plot the same RGB coloring on different embeddings to compare:
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
import matplotlib.pyplot as plt
|
|
53
|
+
|
|
54
|
+
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
55
|
+
rgb = msp.reduce_to_rgb(scores, method="pca")
|
|
56
|
+
|
|
57
|
+
fig, axes = plt.subplots(1, 3, figsize=(18, 5))
|
|
58
|
+
|
|
59
|
+
for ax, basis in zip(axes, ["umap", "pca", "X_scanorama"]):
|
|
60
|
+
msp.plot_embedding(
|
|
61
|
+
adata, rgb,
|
|
62
|
+
basis=basis,
|
|
63
|
+
method="pca",
|
|
64
|
+
gene_set_names=list(gene_sets.keys()),
|
|
65
|
+
ax=ax,
|
|
66
|
+
title=basis.upper(),
|
|
67
|
+
show=False,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
plt.tight_layout()
|
|
71
|
+
plt.show()
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Comparing Reduction Methods
|
|
75
|
+
|
|
76
|
+
Visualize how PCA, NMF, and ICA produce different colorings:
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
import matplotlib.pyplot as plt
|
|
80
|
+
|
|
81
|
+
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
82
|
+
|
|
83
|
+
fig, axes = plt.subplots(1, 3, figsize=(18, 5))
|
|
84
|
+
|
|
85
|
+
for ax, method in zip(axes, ["pca", "nmf", "ica"]):
|
|
86
|
+
rgb = msp.reduce_to_rgb(scores, method=method)
|
|
87
|
+
msp.plot_embedding(
|
|
88
|
+
adata, rgb,
|
|
89
|
+
basis="umap",
|
|
90
|
+
method=method,
|
|
91
|
+
gene_set_names=list(gene_sets.keys()),
|
|
92
|
+
ax=ax,
|
|
93
|
+
title=method.upper(),
|
|
94
|
+
show=False,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
plt.tight_layout()
|
|
98
|
+
plt.show()
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Interactive Plot with Hover Metadata
|
|
102
|
+
|
|
103
|
+
Explore individual cells with hover tooltips:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
107
|
+
rgb = msp.reduce_to_rgb(scores, method="nmf")
|
|
108
|
+
|
|
109
|
+
msp.plot_embedding_interactive(
|
|
110
|
+
adata, rgb,
|
|
111
|
+
basis="umap",
|
|
112
|
+
scores=scores,
|
|
113
|
+
method="nmf",
|
|
114
|
+
gene_set_names=list(gene_sets.keys()),
|
|
115
|
+
hover_columns=["n_counts", "cell_type"], # any adata.obs columns
|
|
116
|
+
point_size=2,
|
|
117
|
+
width=800,
|
|
118
|
+
height=600,
|
|
119
|
+
)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Customizing Plot Appearance
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
ax = msp.plot_embedding(
|
|
126
|
+
adata, rgb,
|
|
127
|
+
basis="umap",
|
|
128
|
+
method="pca",
|
|
129
|
+
gene_set_names=list(gene_sets.keys()),
|
|
130
|
+
point_size=5,
|
|
131
|
+
alpha=0.6,
|
|
132
|
+
figsize=(8, 8),
|
|
133
|
+
title="SVZ Neural Lineage",
|
|
134
|
+
legend=True,
|
|
135
|
+
legend_style="side", # legend in a separate panel
|
|
136
|
+
legend_loc="upper right",
|
|
137
|
+
show=False,
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
# Further customize the returned axes
|
|
141
|
+
ax.set_xlabel("UMAP 1", fontsize=14)
|
|
142
|
+
ax.set_ylabel("UMAP 2", fontsize=14)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Direct Blend for 2–3 Gene Sets
|
|
146
|
+
|
|
147
|
+
When you have exactly 2 or 3 gene sets, direct blending gives the most intuitive
|
|
148
|
+
color mapping:
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
two_sets = {
|
|
152
|
+
"Stem": ["Sox2", "Pax6", "Nes"],
|
|
153
|
+
"Neuronal": ["Dcx", "Tubb3", "Neurod1"],
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
scores = msp.score_gene_sets(adata, two_sets, inplace=True)
|
|
157
|
+
rgb = msp.blend_to_rgb(scores) # blue/red by default
|
|
158
|
+
|
|
159
|
+
msp.plot_embedding(
|
|
160
|
+
adata, rgb,
|
|
161
|
+
basis="umap",
|
|
162
|
+
method="direct",
|
|
163
|
+
gene_set_names=list(two_sets.keys()),
|
|
164
|
+
)
|
|
165
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
Install from PyPI:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install multiscoresplot
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
For interactive Plotly plots:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install 'multiscoresplot[interactive]'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Prerequisites
|
|
18
|
+
|
|
19
|
+
multiscoresplot expects an [AnnData](https://anndata.readthedocs.io/) object with:
|
|
20
|
+
|
|
21
|
+
- A precomputed dimensionality reduction embedding (e.g., UMAP, PCA, or Scanorama) stored in `adata.obsm`
|
|
22
|
+
- Gene expression data (raw or normalized) accessible for scoring
|
|
23
|
+
|
|
24
|
+
## Minimal Working Example
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import multiscoresplot as msp
|
|
28
|
+
|
|
29
|
+
# 1. Define your gene sets
|
|
30
|
+
gene_sets = {
|
|
31
|
+
"Stem": ["Sox2", "Pax6", "Nes"],
|
|
32
|
+
"Neuronal": ["Dcx", "Tubb3", "Neurod1"],
|
|
33
|
+
"Astrocytic": ["Gfap", "Aqp4", "Aldh1l1"],
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# 2. Score gene sets per cell (stores in adata.obs as score-<name>)
|
|
37
|
+
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
38
|
+
|
|
39
|
+
# 3. Map scores to RGB — choose one:
|
|
40
|
+
# Blend (2–3 gene sets only)
|
|
41
|
+
rgb = msp.blend_to_rgb(scores)
|
|
42
|
+
# Or reduce via dimensionality reduction (any number of gene sets)
|
|
43
|
+
rgb = msp.reduce_to_rgb(scores, method="pca")
|
|
44
|
+
|
|
45
|
+
# 4. Plot on a UMAP embedding (step 3 of the pipeline)
|
|
46
|
+
msp.plot_embedding(
|
|
47
|
+
adata, rgb,
|
|
48
|
+
basis="umap",
|
|
49
|
+
method="pca",
|
|
50
|
+
gene_set_names=list(gene_sets.keys()),
|
|
51
|
+
)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
!!! tip "Which color mapping to use?"
|
|
55
|
+
- **`blend_to_rgb`** — Best for 2–3 gene sets. Uses intuitive multiplicative blending from white, where each gene set darkens toward its assigned color.
|
|
56
|
+
- **`reduce_to_rgb`** — Works for any number of gene sets (2+). Uses PCA, NMF, or ICA to project scores into a 3D RGB space.
|
|
57
|
+
|
|
58
|
+
See the [Pipeline Guide](pipeline.md) for a detailed comparison.
|
|
59
|
+
|
|
60
|
+
## Next Steps
|
|
61
|
+
|
|
62
|
+
- [Pipeline Guide](pipeline.md) — Understand each step and when to use each method
|
|
63
|
+
- [API Reference](api/index.md) — Full function signatures and parameters
|
|
64
|
+
- [Examples](examples.md) — Custom reducers, plot customization, and more
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# multiscoresplot
|
|
2
|
+
|
|
3
|
+
**Multi-dimensional gene set scoring and visualization for single-cell transcriptomics.**
|
|
4
|
+
|
|
5
|
+
Color dimensionality reduction plots (UMAP, PCA, etc.) using a multi-dimensional
|
|
6
|
+
color space derived from gene set scores — visualize the activity of multiple gene
|
|
7
|
+
programs simultaneously in a single plot.
|
|
8
|
+
|
|
9
|
+
## Key Features
|
|
10
|
+
|
|
11
|
+
- **Score** gene sets per cell using [UCell](https://github.com/Cem-Gulec/pyUCell)
|
|
12
|
+
- **Map to RGB** via multiplicative blending (2–3 sets) or dimensionality reduction (2+ sets, PCA / NMF / ICA)
|
|
13
|
+
- **Plot** static matplotlib or interactive Plotly scatter plots
|
|
14
|
+
- **Extend** with custom dimensionality reduction methods
|
|
15
|
+
|
|
16
|
+
## Quick Example
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
import multiscoresplot as msp
|
|
20
|
+
|
|
21
|
+
# Define gene sets of interest
|
|
22
|
+
gene_sets = {
|
|
23
|
+
"qNSCs": ["Id3", "Aldoc", "Slc1a3"],
|
|
24
|
+
"aNSCs": ["Egfr", "Ascl1", "Mki67"],
|
|
25
|
+
"TAP": ["Dll1", "Dcx", "Neurod1"],
|
|
26
|
+
"NB": ["Dcx", "Sox11", "Tubb3"],
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# 1. Score gene sets per cell
|
|
30
|
+
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
31
|
+
|
|
32
|
+
# 2. Map scores to RGB colors
|
|
33
|
+
rgb = msp.reduce_to_rgb(scores, method="pca")
|
|
34
|
+
|
|
35
|
+
# 3. Plot
|
|
36
|
+
msp.plot_embedding(
|
|
37
|
+
adata, rgb,
|
|
38
|
+
basis="umap",
|
|
39
|
+
method="pca",
|
|
40
|
+
gene_set_names=list(gene_sets.keys()),
|
|
41
|
+
)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
[Get Started](getting-started.md){ .md-button .md-button--primary }
|
|
45
|
+
[API Reference](api/index.md){ .md-button }
|