multiscoresplot 1.0.5__tar.gz → 2.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.
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/PKG-INFO +44 -47
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/README.md +43 -46
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/docs/api/colorspace.md +10 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/docs/api/index.md +7 -6
- multiscoresplot-2.0.0/docs/changelog.md +35 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/docs/examples.md +13 -24
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/docs/getting-started.md +4 -9
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/docs/index.md +4 -10
- multiscoresplot-2.0.0/docs/pipeline.md +232 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/pyproject.toml +3 -1
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/src/multiscoresplot/__init__.py +3 -1
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/src/multiscoresplot/_colorspace.py +106 -10
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/src/multiscoresplot/_interactive.py +117 -52
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/src/multiscoresplot/_plotting.py +103 -29
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/uv.lock +1 -1
- multiscoresplot-1.0.5/docs/changelog.md +0 -19
- multiscoresplot-1.0.5/docs/pipeline.md +0 -149
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/.github/workflows/ci.yml +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/.github/workflows/docs.yml +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/.github/workflows/publish.yml +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/.gitignore +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/.pre-commit-config.yaml +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/LICENSE +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/docs/api/interactive.md +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/docs/api/legend.md +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/docs/api/plotting.md +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/docs/api/scoring.md +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/mkdocs.yml +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/src/multiscoresplot/_legend.py +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/src/multiscoresplot/_scoring.py +0 -0
- {multiscoresplot-1.0.5 → multiscoresplot-2.0.0}/src/multiscoresplot/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: multiscoresplot
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0
|
|
4
4
|
Summary: Multi-dimensional gene set scoring and visualization for single-cell transcriptomics
|
|
5
5
|
Project-URL: Homepage, https://github.com/AndreMacedo88/multiscoresplot
|
|
6
6
|
Project-URL: Documentation, https://AndreMacedo88.github.io/multiscoresplot/
|
|
@@ -71,21 +71,16 @@ gene_sets = {
|
|
|
71
71
|
# 1. Score gene sets per cell
|
|
72
72
|
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
73
73
|
|
|
74
|
-
# 2. Map scores to RGB colors
|
|
74
|
+
# 2. Map scores to RGB colors (returns RGBResult with metadata)
|
|
75
75
|
rgb = msp.reduce_to_rgb(scores, method="pca")
|
|
76
76
|
|
|
77
|
-
# 3. Plot
|
|
78
|
-
msp.plot_embedding(
|
|
79
|
-
adata, rgb,
|
|
80
|
-
basis="umap",
|
|
81
|
-
method="pca",
|
|
82
|
-
gene_set_names=list(gene_sets.keys()),
|
|
83
|
-
)
|
|
77
|
+
# 3. Plot — method & gene_set_names auto-detected from RGBResult
|
|
78
|
+
msp.plot_embedding(adata, rgb, basis="X_umap")
|
|
84
79
|
```
|
|
85
80
|
|
|
86
81
|
## Pipeline
|
|
87
82
|
|
|
88
|
-
multiscoresplot follows a
|
|
83
|
+
multiscoresplot follows a 3-step pipeline:
|
|
89
84
|
|
|
90
85
|
### Step 1 — Score gene sets
|
|
91
86
|
|
|
@@ -104,9 +99,11 @@ scores = msp.score_gene_sets(
|
|
|
104
99
|
)
|
|
105
100
|
```
|
|
106
101
|
|
|
107
|
-
### Step 2 —
|
|
102
|
+
### Step 2 — Map scores to RGB
|
|
103
|
+
|
|
104
|
+
Convert gene set scores into per-cell RGB colors. Both functions return an `RGBResult` that carries the RGB array plus metadata (method, gene set names, colors) used automatically by the plotting functions.
|
|
108
105
|
|
|
109
|
-
|
|
106
|
+
**Blend (2–3 gene sets)** — multiplicative blending from white, where each gene set darkens toward its base color proportional to the score.
|
|
110
107
|
|
|
111
108
|
```python
|
|
112
109
|
# Default colors (2 sets: blue/red, 3 sets: R/G/B)
|
|
@@ -116,9 +113,7 @@ rgb = msp.blend_to_rgb(scores)
|
|
|
116
113
|
rgb = msp.blend_to_rgb(scores, colors=[(1, 0, 0), (0, 0.5, 1)])
|
|
117
114
|
```
|
|
118
115
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
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.
|
|
116
|
+
**Reduce (2+ gene sets)** — dimensionality reduction maps scores to 3 RGB channels. Built-in methods: PCA, NMF, and ICA.
|
|
122
117
|
|
|
123
118
|
```python
|
|
124
119
|
rgb = msp.reduce_to_rgb(scores, method="pca") # default
|
|
@@ -126,59 +121,51 @@ rgb = msp.reduce_to_rgb(scores, method="nmf")
|
|
|
126
121
|
rgb = msp.reduce_to_rgb(scores, method="ica")
|
|
127
122
|
```
|
|
128
123
|
|
|
129
|
-
### Step
|
|
124
|
+
### Step 3 — Plot embedding
|
|
130
125
|
|
|
131
126
|
Scatter plot of embedding coordinates colored by RGB values, with an integrated color-space legend.
|
|
132
127
|
|
|
133
128
|
```python
|
|
134
|
-
# Static matplotlib plot
|
|
135
|
-
msp.plot_embedding(
|
|
136
|
-
adata, rgb,
|
|
137
|
-
basis="umap",
|
|
138
|
-
method="pca",
|
|
139
|
-
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
140
|
-
)
|
|
129
|
+
# Static matplotlib plot — method & gene_set_names auto-detected from RGBResult
|
|
130
|
+
msp.plot_embedding(adata, rgb, basis="X_umap")
|
|
141
131
|
|
|
142
132
|
# Options
|
|
143
133
|
ax = msp.plot_embedding(
|
|
144
134
|
adata, rgb,
|
|
145
|
-
basis="
|
|
146
|
-
method="pca",
|
|
147
|
-
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
135
|
+
basis="X_umap",
|
|
148
136
|
legend=True, # show color legend (default)
|
|
149
137
|
legend_style="inset", # "inset" or "side"
|
|
150
138
|
legend_loc="lower right", # legend position
|
|
139
|
+
legend_size=0.30, # legend size (fraction of plot)
|
|
140
|
+
legend_resolution=128, # legend image resolution
|
|
151
141
|
point_size=3,
|
|
152
142
|
alpha=0.8,
|
|
153
143
|
figsize=(6, 6),
|
|
144
|
+
dpi=100, # figure resolution
|
|
154
145
|
title="SVZ lineage",
|
|
155
146
|
show=False, # return axes instead of displaying
|
|
156
147
|
)
|
|
157
148
|
```
|
|
158
149
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
WebGL-accelerated Plotly scatter plot with hover info showing gene set scores, RGB channel values, and custom metadata.
|
|
150
|
+
**Interactive plot (requires plotly)** — WebGL-accelerated scatter plot with hover info showing gene set scores, RGB channel values, and custom metadata.
|
|
162
151
|
|
|
163
152
|
```python
|
|
164
153
|
msp.plot_embedding_interactive(
|
|
165
154
|
adata, rgb,
|
|
166
|
-
basis="
|
|
155
|
+
basis="X_umap",
|
|
167
156
|
scores=scores,
|
|
168
|
-
|
|
169
|
-
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
170
|
-
hover_columns=["n_counts", "cell_type"], # extra adata.obs columns
|
|
157
|
+
hover_columns=["n_counts", "cell_type", "Dcx"], # obs columns or gene names
|
|
171
158
|
legend=True,
|
|
172
159
|
legend_loc="lower right",
|
|
173
160
|
point_size=2,
|
|
174
|
-
|
|
175
|
-
|
|
161
|
+
figsize=(6.5, 6.0), # figure size in inches
|
|
162
|
+
dpi=100, # pixels = figsize * dpi
|
|
176
163
|
)
|
|
177
164
|
```
|
|
178
165
|
|
|
179
|
-
###
|
|
166
|
+
### Optional — Standalone legend
|
|
180
167
|
|
|
181
|
-
|
|
168
|
+
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):
|
|
182
169
|
|
|
183
170
|
```python
|
|
184
171
|
import matplotlib.pyplot as plt
|
|
@@ -216,18 +203,28 @@ msp.register_reducer("umap", my_umap_reducer, component_prefix="UMAP")
|
|
|
216
203
|
rgb = msp.reduce_to_rgb(scores, method="umap")
|
|
217
204
|
```
|
|
218
205
|
|
|
206
|
+
## Documentation
|
|
207
|
+
|
|
208
|
+
Full documentation is available at **[AndreMacedo88.github.io/multiscoresplot](https://AndreMacedo88.github.io/multiscoresplot/)**, including:
|
|
209
|
+
|
|
210
|
+
- [Getting Started](https://AndreMacedo88.github.io/multiscoresplot/getting-started/) — installation and quick start
|
|
211
|
+
- [Pipeline Guide](https://AndreMacedo88.github.io/multiscoresplot/pipeline/) — detailed pipeline tutorial
|
|
212
|
+
- [API Reference](https://AndreMacedo88.github.io/multiscoresplot/api/) — full function signatures and parameters
|
|
213
|
+
- [Examples](https://AndreMacedo88.github.io/multiscoresplot/examples/) — custom reducers, plot customization, and more
|
|
214
|
+
|
|
219
215
|
## API Reference
|
|
220
216
|
|
|
221
|
-
| Function
|
|
222
|
-
| --------------------------------------------------- |
|
|
223
|
-
| `score_gene_sets(adata, gene_sets)` | Score gene sets per cell via pyUCell
|
|
224
|
-
| `blend_to_rgb(scores)` | Multiplicative blend to RGB (2–3 sets)
|
|
225
|
-
| `reduce_to_rgb(scores, method="pca")` | Dimensionality reduction to RGB (2+ sets) |
|
|
226
|
-
| `
|
|
227
|
-
| `
|
|
228
|
-
| `
|
|
229
|
-
| `
|
|
230
|
-
| `
|
|
217
|
+
| Function / Class | Description |
|
|
218
|
+
| --------------------------------------------------- | --------------------------------------------------- |
|
|
219
|
+
| `score_gene_sets(adata, gene_sets)` | Score gene sets per cell via pyUCell |
|
|
220
|
+
| `blend_to_rgb(scores)` | Multiplicative blend to RGB (2–3 sets) → RGBResult |
|
|
221
|
+
| `reduce_to_rgb(scores, method="pca")` | Dimensionality reduction to RGB (2+ sets) → RGBResult |
|
|
222
|
+
| `RGBResult` | RGB array + metadata (method, gene set names, colors) |
|
|
223
|
+
| `plot_embedding(adata, rgb, basis=...)` | Static matplotlib scatter plot |
|
|
224
|
+
| `plot_embedding_interactive(adata, rgb, basis=...)` | Interactive Plotly scatter plot |
|
|
225
|
+
| `render_legend(ax, method)` | Draw color-space legend on axes |
|
|
226
|
+
| `register_reducer(name, fn)` | Register a custom reduction method |
|
|
227
|
+
| `get_component_labels(method)` | Get axis labels for a reduction method |
|
|
231
228
|
|
|
232
229
|
## Development
|
|
233
230
|
|
|
@@ -38,21 +38,16 @@ gene_sets = {
|
|
|
38
38
|
# 1. Score gene sets per cell
|
|
39
39
|
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
40
40
|
|
|
41
|
-
# 2. Map scores to RGB colors
|
|
41
|
+
# 2. Map scores to RGB colors (returns RGBResult with metadata)
|
|
42
42
|
rgb = msp.reduce_to_rgb(scores, method="pca")
|
|
43
43
|
|
|
44
|
-
# 3. Plot
|
|
45
|
-
msp.plot_embedding(
|
|
46
|
-
adata, rgb,
|
|
47
|
-
basis="umap",
|
|
48
|
-
method="pca",
|
|
49
|
-
gene_set_names=list(gene_sets.keys()),
|
|
50
|
-
)
|
|
44
|
+
# 3. Plot — method & gene_set_names auto-detected from RGBResult
|
|
45
|
+
msp.plot_embedding(adata, rgb, basis="X_umap")
|
|
51
46
|
```
|
|
52
47
|
|
|
53
48
|
## Pipeline
|
|
54
49
|
|
|
55
|
-
multiscoresplot follows a
|
|
50
|
+
multiscoresplot follows a 3-step pipeline:
|
|
56
51
|
|
|
57
52
|
### Step 1 — Score gene sets
|
|
58
53
|
|
|
@@ -71,9 +66,11 @@ scores = msp.score_gene_sets(
|
|
|
71
66
|
)
|
|
72
67
|
```
|
|
73
68
|
|
|
74
|
-
### Step 2 —
|
|
69
|
+
### Step 2 — Map scores to RGB
|
|
70
|
+
|
|
71
|
+
Convert gene set scores into per-cell RGB colors. Both functions return an `RGBResult` that carries the RGB array plus metadata (method, gene set names, colors) used automatically by the plotting functions.
|
|
75
72
|
|
|
76
|
-
|
|
73
|
+
**Blend (2–3 gene sets)** — multiplicative blending from white, where each gene set darkens toward its base color proportional to the score.
|
|
77
74
|
|
|
78
75
|
```python
|
|
79
76
|
# Default colors (2 sets: blue/red, 3 sets: R/G/B)
|
|
@@ -83,9 +80,7 @@ rgb = msp.blend_to_rgb(scores)
|
|
|
83
80
|
rgb = msp.blend_to_rgb(scores, colors=[(1, 0, 0), (0, 0.5, 1)])
|
|
84
81
|
```
|
|
85
82
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
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.
|
|
83
|
+
**Reduce (2+ gene sets)** — dimensionality reduction maps scores to 3 RGB channels. Built-in methods: PCA, NMF, and ICA.
|
|
89
84
|
|
|
90
85
|
```python
|
|
91
86
|
rgb = msp.reduce_to_rgb(scores, method="pca") # default
|
|
@@ -93,59 +88,51 @@ rgb = msp.reduce_to_rgb(scores, method="nmf")
|
|
|
93
88
|
rgb = msp.reduce_to_rgb(scores, method="ica")
|
|
94
89
|
```
|
|
95
90
|
|
|
96
|
-
### Step
|
|
91
|
+
### Step 3 — Plot embedding
|
|
97
92
|
|
|
98
93
|
Scatter plot of embedding coordinates colored by RGB values, with an integrated color-space legend.
|
|
99
94
|
|
|
100
95
|
```python
|
|
101
|
-
# Static matplotlib plot
|
|
102
|
-
msp.plot_embedding(
|
|
103
|
-
adata, rgb,
|
|
104
|
-
basis="umap",
|
|
105
|
-
method="pca",
|
|
106
|
-
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
107
|
-
)
|
|
96
|
+
# Static matplotlib plot — method & gene_set_names auto-detected from RGBResult
|
|
97
|
+
msp.plot_embedding(adata, rgb, basis="X_umap")
|
|
108
98
|
|
|
109
99
|
# Options
|
|
110
100
|
ax = msp.plot_embedding(
|
|
111
101
|
adata, rgb,
|
|
112
|
-
basis="
|
|
113
|
-
method="pca",
|
|
114
|
-
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
102
|
+
basis="X_umap",
|
|
115
103
|
legend=True, # show color legend (default)
|
|
116
104
|
legend_style="inset", # "inset" or "side"
|
|
117
105
|
legend_loc="lower right", # legend position
|
|
106
|
+
legend_size=0.30, # legend size (fraction of plot)
|
|
107
|
+
legend_resolution=128, # legend image resolution
|
|
118
108
|
point_size=3,
|
|
119
109
|
alpha=0.8,
|
|
120
110
|
figsize=(6, 6),
|
|
111
|
+
dpi=100, # figure resolution
|
|
121
112
|
title="SVZ lineage",
|
|
122
113
|
show=False, # return axes instead of displaying
|
|
123
114
|
)
|
|
124
115
|
```
|
|
125
116
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
WebGL-accelerated Plotly scatter plot with hover info showing gene set scores, RGB channel values, and custom metadata.
|
|
117
|
+
**Interactive plot (requires plotly)** — WebGL-accelerated scatter plot with hover info showing gene set scores, RGB channel values, and custom metadata.
|
|
129
118
|
|
|
130
119
|
```python
|
|
131
120
|
msp.plot_embedding_interactive(
|
|
132
121
|
adata, rgb,
|
|
133
|
-
basis="
|
|
122
|
+
basis="X_umap",
|
|
134
123
|
scores=scores,
|
|
135
|
-
|
|
136
|
-
gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
|
|
137
|
-
hover_columns=["n_counts", "cell_type"], # extra adata.obs columns
|
|
124
|
+
hover_columns=["n_counts", "cell_type", "Dcx"], # obs columns or gene names
|
|
138
125
|
legend=True,
|
|
139
126
|
legend_loc="lower right",
|
|
140
127
|
point_size=2,
|
|
141
|
-
|
|
142
|
-
|
|
128
|
+
figsize=(6.5, 6.0), # figure size in inches
|
|
129
|
+
dpi=100, # pixels = figsize * dpi
|
|
143
130
|
)
|
|
144
131
|
```
|
|
145
132
|
|
|
146
|
-
###
|
|
133
|
+
### Optional — Standalone legend
|
|
147
134
|
|
|
148
|
-
|
|
135
|
+
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):
|
|
149
136
|
|
|
150
137
|
```python
|
|
151
138
|
import matplotlib.pyplot as plt
|
|
@@ -183,18 +170,28 @@ msp.register_reducer("umap", my_umap_reducer, component_prefix="UMAP")
|
|
|
183
170
|
rgb = msp.reduce_to_rgb(scores, method="umap")
|
|
184
171
|
```
|
|
185
172
|
|
|
173
|
+
## Documentation
|
|
174
|
+
|
|
175
|
+
Full documentation is available at **[AndreMacedo88.github.io/multiscoresplot](https://AndreMacedo88.github.io/multiscoresplot/)**, including:
|
|
176
|
+
|
|
177
|
+
- [Getting Started](https://AndreMacedo88.github.io/multiscoresplot/getting-started/) — installation and quick start
|
|
178
|
+
- [Pipeline Guide](https://AndreMacedo88.github.io/multiscoresplot/pipeline/) — detailed pipeline tutorial
|
|
179
|
+
- [API Reference](https://AndreMacedo88.github.io/multiscoresplot/api/) — full function signatures and parameters
|
|
180
|
+
- [Examples](https://AndreMacedo88.github.io/multiscoresplot/examples/) — custom reducers, plot customization, and more
|
|
181
|
+
|
|
186
182
|
## API Reference
|
|
187
183
|
|
|
188
|
-
| Function
|
|
189
|
-
| --------------------------------------------------- |
|
|
190
|
-
| `score_gene_sets(adata, gene_sets)` | Score gene sets per cell via pyUCell
|
|
191
|
-
| `blend_to_rgb(scores)` | Multiplicative blend to RGB (2–3 sets)
|
|
192
|
-
| `reduce_to_rgb(scores, method="pca")` | Dimensionality reduction to RGB (2+ sets) |
|
|
193
|
-
| `
|
|
194
|
-
| `
|
|
195
|
-
| `
|
|
196
|
-
| `
|
|
197
|
-
| `
|
|
184
|
+
| Function / Class | Description |
|
|
185
|
+
| --------------------------------------------------- | --------------------------------------------------- |
|
|
186
|
+
| `score_gene_sets(adata, gene_sets)` | Score gene sets per cell via pyUCell |
|
|
187
|
+
| `blend_to_rgb(scores)` | Multiplicative blend to RGB (2–3 sets) → RGBResult |
|
|
188
|
+
| `reduce_to_rgb(scores, method="pca")` | Dimensionality reduction to RGB (2+ sets) → RGBResult |
|
|
189
|
+
| `RGBResult` | RGB array + metadata (method, gene set names, colors) |
|
|
190
|
+
| `plot_embedding(adata, rgb, basis=...)` | Static matplotlib scatter plot |
|
|
191
|
+
| `plot_embedding_interactive(adata, rgb, basis=...)` | Interactive Plotly scatter plot |
|
|
192
|
+
| `render_legend(ax, method)` | Draw color-space legend on axes |
|
|
193
|
+
| `register_reducer(name, fn)` | Register a custom reduction method |
|
|
194
|
+
| `get_component_labels(method)` | Get axis labels for a reduction method |
|
|
198
195
|
|
|
199
196
|
## Development
|
|
200
197
|
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Color mapping from gene set scores to RGB (pipeline steps 2–3).
|
|
4
4
|
|
|
5
|
+
Both `blend_to_rgb` and `reduce_to_rgb` return an `RGBResult` object that wraps
|
|
6
|
+
the RGB array with metadata (method, gene set names, colors). This metadata is
|
|
7
|
+
auto-detected by the plotting functions.
|
|
8
|
+
|
|
9
|
+
## RGBResult
|
|
10
|
+
|
|
11
|
+
::: multiscoresplot.RGBResult
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
5
15
|
## Blending (2–3 gene sets)
|
|
6
16
|
|
|
7
17
|
::: multiscoresplot.blend_to_rgb
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
| Function | Description | Pipeline Step |
|
|
6
|
-
|
|
5
|
+
| Function / Class | Description | Pipeline Step |
|
|
6
|
+
|------------------|-------------|---------------|
|
|
7
7
|
| [`score_gene_sets`](scoring.md) | Score gene sets per cell via pyUCell | Step 1 |
|
|
8
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
|
|
10
|
-
| [`
|
|
11
|
-
| [`
|
|
12
|
-
| [`
|
|
9
|
+
| [`reduce_to_rgb`](colorspace.md#multiscoresplot.reduce_to_rgb) | Dimensionality reduction to RGB (2+ sets) | Step 2 |
|
|
10
|
+
| [`RGBResult`](colorspace.md#multiscoresplot.RGBResult) | Return type of `blend_to_rgb` / `reduce_to_rgb` with metadata | Step 2 |
|
|
11
|
+
| [`plot_embedding`](plotting.md) | Static matplotlib scatter plot | Step 3 |
|
|
12
|
+
| [`plot_embedding_interactive`](interactive.md) | Interactive Plotly scatter plot | Step 3 |
|
|
13
|
+
| [`render_legend`](legend.md) | Draw color-space legend on axes | Optional |
|
|
13
14
|
| [`register_reducer`](colorspace.md#multiscoresplot.register_reducer) | Register a custom reduction method | Extensibility |
|
|
14
15
|
| [`get_component_labels`](colorspace.md#multiscoresplot.get_component_labels) | Get axis labels for a reduction method | Utility |
|
|
15
16
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Breaking changes
|
|
6
|
+
- `blend_to_rgb` and `reduce_to_rgb` now return `RGBResult` (carries RGB array + metadata). The object supports numpy array protocol, so `np.asarray(result)`, indexing, and comparisons still work.
|
|
7
|
+
- `plot_embedding` and `plot_embedding_interactive`: `basis=` now takes the **full obsm key** (e.g. `"X_umap"`, `"umap_consensus"`). The old short form (`basis="umap"`) still works but emits a `DeprecationWarning`.
|
|
8
|
+
- `plot_embedding`: `legend=True` (default) now **requires** a known method. Previously it silently skipped the legend when `method=None`; now it raises `ValueError`. Pass `legend=False` or provide `method=`, or use an `RGBResult`.
|
|
9
|
+
- `plot_embedding_interactive`: `width`/`height` replaced by `figsize` (inches) + `dpi`. Pixel dimensions = `figsize * dpi`.
|
|
10
|
+
|
|
11
|
+
### New features
|
|
12
|
+
- **`RGBResult`**: new dataclass returned by `blend_to_rgb` / `reduce_to_rgb`. Carries `method`, `gene_set_names`, and `colors` metadata that plotting functions auto-detect.
|
|
13
|
+
- **`plot_embedding`**: new params `legend_size`, `legend_resolution`, `dpi`.
|
|
14
|
+
- **`plot_embedding_interactive`**: new param `legend_kwargs`. `figsize`/`dpi` replace `width`/`height`.
|
|
15
|
+
- **Both plotting functions**: consistent `legend_size`, `legend_resolution`, and `legend_kwargs` params.
|
|
16
|
+
- **`hover_columns`** now falls back to `adata.var_names` for gene expression values (sparse matrices supported).
|
|
17
|
+
- **`gene_set_names`** behavior is now consistent between static and interactive plots.
|
|
18
|
+
|
|
19
|
+
## 1.0.3
|
|
20
|
+
|
|
21
|
+
- Fix badge display in README
|
|
22
|
+
|
|
23
|
+
## 1.0.2
|
|
24
|
+
|
|
25
|
+
- Fix legend not being plotted in interactive "direct" methods
|
|
26
|
+
- Fix CI badge path in README
|
|
27
|
+
|
|
28
|
+
## 1.0.1
|
|
29
|
+
|
|
30
|
+
- Initial stable release
|
|
31
|
+
- 5-step pipeline: score, blend, reduce, plot, legend
|
|
32
|
+
- Built-in reducers: PCA, NMF, ICA
|
|
33
|
+
- Pluggable reducer registry
|
|
34
|
+
- Static matplotlib and interactive Plotly plotting
|
|
35
|
+
- Color-space legends for direct and reduction modes
|
|
@@ -38,10 +38,9 @@ def umap_reducer(X, n_components, **kwargs):
|
|
|
38
38
|
# Register it
|
|
39
39
|
msp.register_reducer("umap", umap_reducer, component_prefix="UMAP")
|
|
40
40
|
|
|
41
|
-
# Use it
|
|
41
|
+
# Use it — method auto-detected from RGBResult
|
|
42
42
|
rgb = msp.reduce_to_rgb(scores, method="umap")
|
|
43
|
-
msp.plot_embedding(adata, rgb, basis="
|
|
44
|
-
gene_set_names=list(gene_sets.keys()))
|
|
43
|
+
msp.plot_embedding(adata, rgb, basis="X_umap")
|
|
45
44
|
```
|
|
46
45
|
|
|
47
46
|
## Different Embeddings
|
|
@@ -56,12 +55,10 @@ rgb = msp.reduce_to_rgb(scores, method="pca")
|
|
|
56
55
|
|
|
57
56
|
fig, axes = plt.subplots(1, 3, figsize=(18, 5))
|
|
58
57
|
|
|
59
|
-
for ax, basis in zip(axes, ["
|
|
58
|
+
for ax, basis in zip(axes, ["X_umap", "X_pca", "X_scanorama"]):
|
|
60
59
|
msp.plot_embedding(
|
|
61
60
|
adata, rgb,
|
|
62
61
|
basis=basis,
|
|
63
|
-
method="pca",
|
|
64
|
-
gene_set_names=list(gene_sets.keys()),
|
|
65
62
|
ax=ax,
|
|
66
63
|
title=basis.upper(),
|
|
67
64
|
show=False,
|
|
@@ -86,9 +83,7 @@ for ax, method in zip(axes, ["pca", "nmf", "ica"]):
|
|
|
86
83
|
rgb = msp.reduce_to_rgb(scores, method=method)
|
|
87
84
|
msp.plot_embedding(
|
|
88
85
|
adata, rgb,
|
|
89
|
-
basis="
|
|
90
|
-
method=method,
|
|
91
|
-
gene_set_names=list(gene_sets.keys()),
|
|
86
|
+
basis="X_umap",
|
|
92
87
|
ax=ax,
|
|
93
88
|
title=method.upper(),
|
|
94
89
|
show=False,
|
|
@@ -108,14 +103,12 @@ rgb = msp.reduce_to_rgb(scores, method="nmf")
|
|
|
108
103
|
|
|
109
104
|
msp.plot_embedding_interactive(
|
|
110
105
|
adata, rgb,
|
|
111
|
-
basis="
|
|
106
|
+
basis="X_umap",
|
|
112
107
|
scores=scores,
|
|
113
|
-
|
|
114
|
-
gene_set_names=list(gene_sets.keys()),
|
|
115
|
-
hover_columns=["n_counts", "cell_type"], # any adata.obs columns
|
|
108
|
+
hover_columns=["n_counts", "cell_type", "Dcx"], # obs columns or gene names
|
|
116
109
|
point_size=2,
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
figsize=(8.0, 6.0),
|
|
111
|
+
dpi=100,
|
|
119
112
|
)
|
|
120
113
|
```
|
|
121
114
|
|
|
@@ -124,16 +117,16 @@ msp.plot_embedding_interactive(
|
|
|
124
117
|
```python
|
|
125
118
|
ax = msp.plot_embedding(
|
|
126
119
|
adata, rgb,
|
|
127
|
-
basis="
|
|
128
|
-
method="pca",
|
|
129
|
-
gene_set_names=list(gene_sets.keys()),
|
|
120
|
+
basis="X_umap",
|
|
130
121
|
point_size=5,
|
|
131
122
|
alpha=0.6,
|
|
132
123
|
figsize=(8, 8),
|
|
124
|
+
dpi=150,
|
|
133
125
|
title="SVZ Neural Lineage",
|
|
134
126
|
legend=True,
|
|
135
127
|
legend_style="side", # legend in a separate panel
|
|
136
128
|
legend_loc="upper right",
|
|
129
|
+
legend_size=0.35, # legend size (fraction of plot)
|
|
137
130
|
show=False,
|
|
138
131
|
)
|
|
139
132
|
|
|
@@ -156,10 +149,6 @@ two_sets = {
|
|
|
156
149
|
scores = msp.score_gene_sets(adata, two_sets, inplace=True)
|
|
157
150
|
rgb = msp.blend_to_rgb(scores) # blue/red by default
|
|
158
151
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
basis="umap",
|
|
162
|
-
method="direct",
|
|
163
|
-
gene_set_names=list(two_sets.keys()),
|
|
164
|
-
)
|
|
152
|
+
# method="direct" and gene_set_names auto-detected from RGBResult
|
|
153
|
+
msp.plot_embedding(adata, rgb, basis="X_umap")
|
|
165
154
|
```
|
|
@@ -37,18 +37,13 @@ gene_sets = {
|
|
|
37
37
|
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
38
38
|
|
|
39
39
|
# 3. Map scores to RGB — choose one:
|
|
40
|
-
#
|
|
40
|
+
# Blend (2–3 gene sets only)
|
|
41
41
|
rgb = msp.blend_to_rgb(scores)
|
|
42
|
-
# Or dimensionality reduction (any number of gene sets)
|
|
42
|
+
# Or reduce via dimensionality reduction (any number of gene sets)
|
|
43
43
|
rgb = msp.reduce_to_rgb(scores, method="pca")
|
|
44
44
|
|
|
45
|
-
# 4. Plot on a UMAP embedding
|
|
46
|
-
msp.plot_embedding(
|
|
47
|
-
adata, rgb,
|
|
48
|
-
basis="umap",
|
|
49
|
-
method="pca",
|
|
50
|
-
gene_set_names=list(gene_sets.keys()),
|
|
51
|
-
)
|
|
45
|
+
# 4. Plot on a UMAP embedding — method & labels auto-detected from RGBResult
|
|
46
|
+
msp.plot_embedding(adata, rgb, basis="X_umap")
|
|
52
47
|
```
|
|
53
48
|
|
|
54
49
|
!!! tip "Which color mapping to use?"
|
|
@@ -9,8 +9,7 @@ programs simultaneously in a single plot.
|
|
|
9
9
|
## Key Features
|
|
10
10
|
|
|
11
11
|
- **Score** gene sets per cell using [UCell](https://github.com/Cem-Gulec/pyUCell)
|
|
12
|
-
- **
|
|
13
|
-
- **Reduce** any number of gene sets to RGB via PCA / NMF / ICA
|
|
12
|
+
- **Map to RGB** via multiplicative blending (2–3 sets) or dimensionality reduction (2+ sets, PCA / NMF / ICA)
|
|
14
13
|
- **Plot** static matplotlib or interactive Plotly scatter plots
|
|
15
14
|
- **Extend** with custom dimensionality reduction methods
|
|
16
15
|
|
|
@@ -30,16 +29,11 @@ gene_sets = {
|
|
|
30
29
|
# 1. Score gene sets per cell
|
|
31
30
|
scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
|
|
32
31
|
|
|
33
|
-
# 2. Map scores to RGB colors
|
|
32
|
+
# 2. Map scores to RGB colors (returns RGBResult with metadata)
|
|
34
33
|
rgb = msp.reduce_to_rgb(scores, method="pca")
|
|
35
34
|
|
|
36
|
-
# 3. Plot
|
|
37
|
-
msp.plot_embedding(
|
|
38
|
-
adata, rgb,
|
|
39
|
-
basis="umap",
|
|
40
|
-
method="pca",
|
|
41
|
-
gene_set_names=list(gene_sets.keys()),
|
|
42
|
-
)
|
|
35
|
+
# 3. Plot — method & gene_set_names auto-detected from RGBResult
|
|
36
|
+
msp.plot_embedding(adata, rgb, basis="X_umap")
|
|
43
37
|
```
|
|
44
38
|
|
|
45
39
|
[Get Started](getting-started.md){ .md-button .md-button--primary }
|