multiscoresplot 1.0.6__tar.gz → 2.1.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.
Files changed (34) hide show
  1. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/.gitignore +1 -0
  2. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/PKG-INFO +46 -36
  3. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/README.md +45 -35
  4. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/docs/api/colorspace.md +10 -0
  5. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/docs/api/index.md +4 -2
  6. multiscoresplot-2.1.0/docs/api/pipeline.md +3 -0
  7. multiscoresplot-2.1.0/docs/changelog.md +54 -0
  8. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/docs/examples.md +40 -24
  9. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/docs/getting-started.md +2 -7
  10. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/docs/index.md +3 -8
  11. multiscoresplot-2.1.0/docs/pipeline.md +329 -0
  12. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/mkdocs.yml +1 -0
  13. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/pyproject.toml +3 -1
  14. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/src/multiscoresplot/__init__.py +5 -1
  15. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/src/multiscoresplot/_colorspace.py +198 -25
  16. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/src/multiscoresplot/_interactive.py +146 -55
  17. multiscoresplot-2.1.0/src/multiscoresplot/_pipeline.py +195 -0
  18. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/src/multiscoresplot/_plotting.py +103 -29
  19. multiscoresplot-2.1.0/src/multiscoresplot/_scoring.py +224 -0
  20. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/uv.lock +1 -1
  21. multiscoresplot-1.0.6/docs/changelog.md +0 -19
  22. multiscoresplot-1.0.6/docs/pipeline.md +0 -213
  23. multiscoresplot-1.0.6/src/multiscoresplot/_scoring.py +0 -99
  24. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/.github/workflows/ci.yml +0 -0
  25. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/.github/workflows/docs.yml +0 -0
  26. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/.github/workflows/publish.yml +0 -0
  27. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/.pre-commit-config.yaml +0 -0
  28. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/LICENSE +0 -0
  29. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/docs/api/interactive.md +0 -0
  30. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/docs/api/legend.md +0 -0
  31. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/docs/api/plotting.md +0 -0
  32. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/docs/api/scoring.md +0 -0
  33. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/src/multiscoresplot/_legend.py +0 -0
  34. {multiscoresplot-1.0.6 → multiscoresplot-2.1.0}/src/multiscoresplot/py.typed +0 -0
@@ -1,3 +1,4 @@
1
+ TODOs.md
1
2
  CLAUDE.md
2
3
  RELEASE.md
3
4
  .claude
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: multiscoresplot
3
- Version: 1.0.6
3
+ Version: 2.1.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,16 +71,11 @@ 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
@@ -106,7 +101,7 @@ scores = msp.score_gene_sets(
106
101
 
107
102
  ### Step 2 — Map scores to RGB
108
103
 
109
- Convert gene set scores into per-cell RGB colors. Two options depending on how many gene sets you want to visualize:
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.
110
105
 
111
106
  **Blend (2–3 gene sets)** — multiplicative blending from white, where each gene set darkens toward its base color proportional to the score.
112
107
 
@@ -126,31 +121,35 @@ rgb = msp.reduce_to_rgb(scores, method="nmf")
126
121
  rgb = msp.reduce_to_rgb(scores, method="ica")
127
122
  ```
128
123
 
124
+ **Or use a callable directly for one-off reductions:**
125
+
126
+ ```python
127
+ rgb = msp.reduce_to_rgb(scores, method=my_custom_fn, component_prefix="MY")
128
+ ```
129
+
130
+ > **Note:** In reduction mode, RGB channels are learned statistical axes. Similar colors indicate similar *projected* profiles, not necessarily identical biology — see the [Pipeline Guide](https://AndreMacedo88.github.io/multiscoresplot/pipeline/) for interpretation caveats.
131
+
129
132
  ### Step 3 — Plot embedding
130
133
 
131
134
  Scatter plot of embedding coordinates colored by RGB values, with an integrated color-space legend.
132
135
 
133
136
  ```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
- )
137
+ # Static matplotlib plot — method & gene_set_names auto-detected from RGBResult
138
+ msp.plot_embedding(adata, rgb, basis="X_umap")
141
139
 
142
140
  # Options
143
141
  ax = msp.plot_embedding(
144
142
  adata, rgb,
145
- basis="umap",
146
- method="pca",
147
- gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
143
+ basis="X_umap",
148
144
  legend=True, # show color legend (default)
149
145
  legend_style="inset", # "inset" or "side"
150
146
  legend_loc="lower right", # legend position
147
+ legend_size=0.30, # legend size (fraction of plot)
148
+ legend_resolution=128, # legend image resolution
151
149
  point_size=3,
152
150
  alpha=0.8,
153
151
  figsize=(6, 6),
152
+ dpi=100, # figure resolution
154
153
  title="SVZ lineage",
155
154
  show=False, # return axes instead of displaying
156
155
  )
@@ -161,16 +160,14 @@ ax = msp.plot_embedding(
161
160
  ```python
162
161
  msp.plot_embedding_interactive(
163
162
  adata, rgb,
164
- basis="umap",
163
+ basis="X_umap",
165
164
  scores=scores,
166
- method="nmf",
167
- gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
168
- hover_columns=["n_counts", "cell_type"], # extra adata.obs columns
165
+ hover_columns=["n_counts", "cell_type", "Dcx"], # obs columns or gene names
169
166
  legend=True,
170
167
  legend_loc="lower right",
171
168
  point_size=2,
172
- width=600,
173
- height=500,
169
+ figsize=(6.5, 6.0), # figure size in inches
170
+ dpi=100, # pixels = figsize * dpi
174
171
  )
175
172
  ```
176
173
 
@@ -191,6 +188,17 @@ msp.render_legend(ax, "pca")
191
188
  msp.render_legend(ax, "nmf", component_labels=["NMF1", "NMF2", "NMF3"])
192
189
  ```
193
190
 
191
+ ## One-Step Convenience Function
192
+
193
+ For quick exploration, `plot_scores` wraps the entire pipeline in a single call:
194
+
195
+ ```python
196
+ scores, rgb, ax = msp.plot_scores(adata, gene_sets, basis="X_umap")
197
+ ```
198
+
199
+ It auto-selects `blend_to_rgb` for ≤ 3 gene sets and `reduce_to_rgb(method="pca")` for more.
200
+ All scoring, color-mapping, and plotting parameters are accepted as keyword arguments.
201
+
194
202
  ## Extensibility — Custom reducers
195
203
 
196
204
  Register your own dimensionality reduction method:
@@ -225,16 +233,18 @@ Full documentation is available at **[AndreMacedo88.github.io/multiscoresplot](h
225
233
 
226
234
  ## API Reference
227
235
 
228
- | Function | Description |
229
- | --------------------------------------------------- | ----------------------------------------- |
230
- | `score_gene_sets(adata, gene_sets)` | Score gene sets per cell via pyUCell |
231
- | `blend_to_rgb(scores)` | Multiplicative blend to RGB (2–3 sets) |
232
- | `reduce_to_rgb(scores, method="pca")` | Dimensionality reduction to RGB (2+ sets) |
233
- | `plot_embedding(adata, rgb, basis=...)` | Static matplotlib scatter plot |
234
- | `plot_embedding_interactive(adata, rgb, basis=...)` | Interactive Plotly scatter plot |
235
- | `render_legend(ax, method)` | Draw color-space legend on axes |
236
- | `register_reducer(name, fn)` | Register a custom reduction method |
237
- | `get_component_labels(method)` | Get axis labels for a reduction method |
236
+ | Function / Class | Description |
237
+ | --------------------------------------------------- | --------------------------------------------------- |
238
+ | `plot_scores(adata, gene_sets)` | One-step convenience: score RGB plot |
239
+ | `score_gene_sets(adata, gene_sets)` | Score gene sets per cell via pyUCell |
240
+ | `blend_to_rgb(scores)` | Multiplicative blend to RGB (2–3 sets) → RGBResult |
241
+ | `reduce_to_rgb(scores, method="pca")` | Dimensionality reduction to RGB (2+ sets) → RGBResult |
242
+ | `RGBResult` | RGB array + metadata (method, gene set names, colors) |
243
+ | `plot_embedding(adata, rgb, basis=...)` | Static matplotlib scatter plot |
244
+ | `plot_embedding_interactive(adata, rgb, basis=...)` | Interactive Plotly scatter plot |
245
+ | `render_legend(ax, method)` | Draw color-space legend on axes |
246
+ | `register_reducer(name, fn)` | Register a custom reduction method |
247
+ | `get_component_labels(method)` | Get axis labels for a reduction method |
238
248
 
239
249
  ## Development
240
250
 
@@ -38,16 +38,11 @@ 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
@@ -73,7 +68,7 @@ scores = msp.score_gene_sets(
73
68
 
74
69
  ### Step 2 — Map scores to RGB
75
70
 
76
- Convert gene set scores into per-cell RGB colors. Two options depending on how many gene sets you want to visualize:
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.
77
72
 
78
73
  **Blend (2–3 gene sets)** — multiplicative blending from white, where each gene set darkens toward its base color proportional to the score.
79
74
 
@@ -93,31 +88,35 @@ rgb = msp.reduce_to_rgb(scores, method="nmf")
93
88
  rgb = msp.reduce_to_rgb(scores, method="ica")
94
89
  ```
95
90
 
91
+ **Or use a callable directly for one-off reductions:**
92
+
93
+ ```python
94
+ rgb = msp.reduce_to_rgb(scores, method=my_custom_fn, component_prefix="MY")
95
+ ```
96
+
97
+ > **Note:** In reduction mode, RGB channels are learned statistical axes. Similar colors indicate similar *projected* profiles, not necessarily identical biology — see the [Pipeline Guide](https://AndreMacedo88.github.io/multiscoresplot/pipeline/) for interpretation caveats.
98
+
96
99
  ### Step 3 — Plot embedding
97
100
 
98
101
  Scatter plot of embedding coordinates colored by RGB values, with an integrated color-space legend.
99
102
 
100
103
  ```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
- )
104
+ # Static matplotlib plot — method & gene_set_names auto-detected from RGBResult
105
+ msp.plot_embedding(adata, rgb, basis="X_umap")
108
106
 
109
107
  # Options
110
108
  ax = msp.plot_embedding(
111
109
  adata, rgb,
112
- basis="umap",
113
- method="pca",
114
- gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
110
+ basis="X_umap",
115
111
  legend=True, # show color legend (default)
116
112
  legend_style="inset", # "inset" or "side"
117
113
  legend_loc="lower right", # legend position
114
+ legend_size=0.30, # legend size (fraction of plot)
115
+ legend_resolution=128, # legend image resolution
118
116
  point_size=3,
119
117
  alpha=0.8,
120
118
  figsize=(6, 6),
119
+ dpi=100, # figure resolution
121
120
  title="SVZ lineage",
122
121
  show=False, # return axes instead of displaying
123
122
  )
@@ -128,16 +127,14 @@ ax = msp.plot_embedding(
128
127
  ```python
129
128
  msp.plot_embedding_interactive(
130
129
  adata, rgb,
131
- basis="umap",
130
+ basis="X_umap",
132
131
  scores=scores,
133
- method="nmf",
134
- gene_set_names=["qNSCs", "aNSCs", "TAP", "NB"],
135
- hover_columns=["n_counts", "cell_type"], # extra adata.obs columns
132
+ hover_columns=["n_counts", "cell_type", "Dcx"], # obs columns or gene names
136
133
  legend=True,
137
134
  legend_loc="lower right",
138
135
  point_size=2,
139
- width=600,
140
- height=500,
136
+ figsize=(6.5, 6.0), # figure size in inches
137
+ dpi=100, # pixels = figsize * dpi
141
138
  )
142
139
  ```
143
140
 
@@ -158,6 +155,17 @@ msp.render_legend(ax, "pca")
158
155
  msp.render_legend(ax, "nmf", component_labels=["NMF1", "NMF2", "NMF3"])
159
156
  ```
160
157
 
158
+ ## One-Step Convenience Function
159
+
160
+ For quick exploration, `plot_scores` wraps the entire pipeline in a single call:
161
+
162
+ ```python
163
+ scores, rgb, ax = msp.plot_scores(adata, gene_sets, basis="X_umap")
164
+ ```
165
+
166
+ It auto-selects `blend_to_rgb` for ≤ 3 gene sets and `reduce_to_rgb(method="pca")` for more.
167
+ All scoring, color-mapping, and plotting parameters are accepted as keyword arguments.
168
+
161
169
  ## Extensibility — Custom reducers
162
170
 
163
171
  Register your own dimensionality reduction method:
@@ -192,16 +200,18 @@ Full documentation is available at **[AndreMacedo88.github.io/multiscoresplot](h
192
200
 
193
201
  ## API Reference
194
202
 
195
- | Function | Description |
196
- | --------------------------------------------------- | ----------------------------------------- |
197
- | `score_gene_sets(adata, gene_sets)` | Score gene sets per cell via pyUCell |
198
- | `blend_to_rgb(scores)` | Multiplicative blend to RGB (2–3 sets) |
199
- | `reduce_to_rgb(scores, method="pca")` | Dimensionality reduction to RGB (2+ sets) |
200
- | `plot_embedding(adata, rgb, basis=...)` | Static matplotlib scatter plot |
201
- | `plot_embedding_interactive(adata, rgb, basis=...)` | Interactive Plotly scatter plot |
202
- | `render_legend(ax, method)` | Draw color-space legend on axes |
203
- | `register_reducer(name, fn)` | Register a custom reduction method |
204
- | `get_component_labels(method)` | Get axis labels for a reduction method |
203
+ | Function / Class | Description |
204
+ | --------------------------------------------------- | --------------------------------------------------- |
205
+ | `plot_scores(adata, gene_sets)` | One-step convenience: score RGB plot |
206
+ | `score_gene_sets(adata, gene_sets)` | Score gene sets per cell via pyUCell |
207
+ | `blend_to_rgb(scores)` | Multiplicative blend to RGB (2–3 sets) → RGBResult |
208
+ | `reduce_to_rgb(scores, method="pca")` | Dimensionality reduction to RGB (2+ sets) → RGBResult |
209
+ | `RGBResult` | RGB array + metadata (method, gene set names, colors) |
210
+ | `plot_embedding(adata, rgb, basis=...)` | Static matplotlib scatter plot |
211
+ | `plot_embedding_interactive(adata, rgb, basis=...)` | Interactive Plotly scatter plot |
212
+ | `render_legend(ax, method)` | Draw color-space legend on axes |
213
+ | `register_reducer(name, fn)` | Register a custom reduction method |
214
+ | `get_component_labels(method)` | Get axis labels for a reduction method |
205
215
 
206
216
  ## Development
207
217
 
@@ -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,11 +2,13 @@
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
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_scores`](pipeline.md) | One-step convenience: score → RGB → plot | Steps 1–3 |
10
12
  | [`plot_embedding`](plotting.md) | Static matplotlib scatter plot | Step 3 |
11
13
  | [`plot_embedding_interactive`](interactive.md) | Interactive Plotly scatter plot | Step 3 |
12
14
  | [`render_legend`](legend.md) | Draw color-space legend on axes | Optional |
@@ -0,0 +1,3 @@
1
+ # plot_scores
2
+
3
+ ::: multiscoresplot.plot_scores
@@ -0,0 +1,54 @@
1
+ # Changelog
2
+
3
+ ## 2.1.0
4
+
5
+ ### New features
6
+ - **`blend_to_rgb` / `reduce_to_rgb`**: new `prefix` and `suffix` keyword parameters for custom score column naming conventions (e.g., `prefix="msp-"`, `suffix="_v2"`). Defaults match existing `"score-"` behavior.
7
+ - **`RGBResult`**: new `prefix` and `suffix` fields so downstream functions auto-detect the naming convention.
8
+ - **`plot_embedding_interactive`**: new `prefix` and `suffix` keyword parameters for correct hover auto-extraction with custom column names. Defaults inherit from `RGBResult` when available.
9
+ - **`plot_scores`**: new `prefix` and `suffix` keyword parameters forwarded to all pipeline steps (scoring, color mapping, and interactive plotting).
10
+ - **`plot_scores`**: new one-step convenience function that wraps the full score → RGB → plot pipeline. Auto-selects `blend_to_rgb` for ≤ 3 gene sets and `reduce_to_rgb(method="pca")` for more.
11
+ - **`reduce_to_rgb`**: `method` now accepts a callable with signature `(X, n_components, **kwargs) -> NDArray` for one-off custom reductions. New `component_prefix` parameter overrides legend axis labels.
12
+ - **`score_gene_sets`**: emits `UserWarning` listing missing genes per gene set (genes not found in `adata.var_names` are imputed by pyUCell with worst-case rank).
13
+ - **`score_gene_sets`**: emits `UserWarning` when `adata.X` contains negative values (e.g., after `sc.pp.scale()`), since UCell is designed for non-negative counts.
14
+ - **`score_gene_sets`**: automatically copies read-only `adata.X` arrays to prevent crashes inside pyUCell (works around a pyUCell bug with read-only arrays after `sc.pp.scale()`).
15
+ - **`score_gene_sets`**: new `clip_pct` parameter for per-gene-set percentile clipping (winsorization). Accepts a single float for upper-tail clipping or a `(lo, hi)` tuple for both tails.
16
+ - **`score_gene_sets`**: new `normalize` parameter for per-gene-set min-max rescaling to [0, 1]. Applied after clipping.
17
+
18
+ ### Documentation
19
+ - Added color interpretation caveats for reduction mode in Pipeline Guide.
20
+ - Added inline callable example in Examples page.
21
+
22
+ ## 2.0.0
23
+
24
+ ### Breaking changes
25
+ - `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.
26
+ - `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`.
27
+ - `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`.
28
+ - `plot_embedding_interactive`: `width`/`height` replaced by `figsize` (inches) + `dpi`. Pixel dimensions = `figsize * dpi`.
29
+
30
+ ### New features
31
+ - **`RGBResult`**: new dataclass returned by `blend_to_rgb` / `reduce_to_rgb`. Carries `method`, `gene_set_names`, and `colors` metadata that plotting functions auto-detect.
32
+ - **`plot_embedding`**: new params `legend_size`, `legend_resolution`, `dpi`.
33
+ - **`plot_embedding_interactive`**: new param `legend_kwargs`. `figsize`/`dpi` replace `width`/`height`.
34
+ - **Both plotting functions**: consistent `legend_size`, `legend_resolution`, and `legend_kwargs` params.
35
+ - **`hover_columns`** now falls back to `adata.var_names` for gene expression values (sparse matrices supported).
36
+ - **`gene_set_names`** behavior is now consistent between static and interactive plots.
37
+
38
+ ## 1.0.3
39
+
40
+ - Fix badge display in README
41
+
42
+ ## 1.0.2
43
+
44
+ - Fix legend not being plotted in interactive "direct" methods
45
+ - Fix CI badge path in README
46
+
47
+ ## 1.0.1
48
+
49
+ - Initial stable release
50
+ - 5-step pipeline: score, blend, reduce, plot, legend
51
+ - Built-in reducers: PCA, NMF, ICA
52
+ - Pluggable reducer registry
53
+ - Static matplotlib and interactive Plotly plotting
54
+ - Color-space legends for direct and reduction modes
@@ -38,12 +38,38 @@ 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="umap", method="umap",
44
- gene_set_names=list(gene_sets.keys()))
43
+ msp.plot_embedding(adata, rgb, basis="X_umap")
45
44
  ```
46
45
 
46
+ ## Inline Callable Reducer
47
+
48
+ For one-off custom reductions, pass a callable directly to `reduce_to_rgb` instead of
49
+ registering it:
50
+
51
+ ```python
52
+ import multiscoresplot as msp
53
+ import umap
54
+
55
+
56
+ def umap_reducer(X, n_components, **kwargs):
57
+ embedding = umap.UMAP(n_components=n_components, **kwargs).fit_transform(X)
58
+ for j in range(embedding.shape[1]):
59
+ col = embedding[:, j]
60
+ lo, hi = col.min(), col.max()
61
+ if hi > lo:
62
+ embedding[:, j] = (col - lo) / (hi - lo)
63
+ return embedding
64
+
65
+
66
+ rgb = msp.reduce_to_rgb(scores, method=umap_reducer, component_prefix="UMAP")
67
+ msp.plot_embedding(adata, rgb, basis="X_umap")
68
+ ```
69
+
70
+ This is equivalent to `register_reducer` + `reduce_to_rgb(method="umap")`, but more
71
+ convenient when you only need the reducer once.
72
+
47
73
  ## Different Embeddings
48
74
 
49
75
  Plot the same RGB coloring on different embeddings to compare:
@@ -56,12 +82,10 @@ rgb = msp.reduce_to_rgb(scores, method="pca")
56
82
 
57
83
  fig, axes = plt.subplots(1, 3, figsize=(18, 5))
58
84
 
59
- for ax, basis in zip(axes, ["umap", "pca", "X_scanorama"]):
85
+ for ax, basis in zip(axes, ["X_umap", "X_pca", "X_scanorama"]):
60
86
  msp.plot_embedding(
61
87
  adata, rgb,
62
88
  basis=basis,
63
- method="pca",
64
- gene_set_names=list(gene_sets.keys()),
65
89
  ax=ax,
66
90
  title=basis.upper(),
67
91
  show=False,
@@ -86,9 +110,7 @@ for ax, method in zip(axes, ["pca", "nmf", "ica"]):
86
110
  rgb = msp.reduce_to_rgb(scores, method=method)
87
111
  msp.plot_embedding(
88
112
  adata, rgb,
89
- basis="umap",
90
- method=method,
91
- gene_set_names=list(gene_sets.keys()),
113
+ basis="X_umap",
92
114
  ax=ax,
93
115
  title=method.upper(),
94
116
  show=False,
@@ -108,14 +130,12 @@ rgb = msp.reduce_to_rgb(scores, method="nmf")
108
130
 
109
131
  msp.plot_embedding_interactive(
110
132
  adata, rgb,
111
- basis="umap",
133
+ basis="X_umap",
112
134
  scores=scores,
113
- method="nmf",
114
- gene_set_names=list(gene_sets.keys()),
115
- hover_columns=["n_counts", "cell_type"], # any adata.obs columns
135
+ hover_columns=["n_counts", "cell_type", "Dcx"], # obs columns or gene names
116
136
  point_size=2,
117
- width=800,
118
- height=600,
137
+ figsize=(8.0, 6.0),
138
+ dpi=100,
119
139
  )
120
140
  ```
121
141
 
@@ -124,16 +144,16 @@ msp.plot_embedding_interactive(
124
144
  ```python
125
145
  ax = msp.plot_embedding(
126
146
  adata, rgb,
127
- basis="umap",
128
- method="pca",
129
- gene_set_names=list(gene_sets.keys()),
147
+ basis="X_umap",
130
148
  point_size=5,
131
149
  alpha=0.6,
132
150
  figsize=(8, 8),
151
+ dpi=150,
133
152
  title="SVZ Neural Lineage",
134
153
  legend=True,
135
154
  legend_style="side", # legend in a separate panel
136
155
  legend_loc="upper right",
156
+ legend_size=0.35, # legend size (fraction of plot)
137
157
  show=False,
138
158
  )
139
159
 
@@ -156,10 +176,6 @@ two_sets = {
156
176
  scores = msp.score_gene_sets(adata, two_sets, inplace=True)
157
177
  rgb = msp.blend_to_rgb(scores) # blue/red by default
158
178
 
159
- msp.plot_embedding(
160
- adata, rgb,
161
- basis="umap",
162
- method="direct",
163
- gene_set_names=list(two_sets.keys()),
164
- )
179
+ # method="direct" and gene_set_names auto-detected from RGBResult
180
+ msp.plot_embedding(adata, rgb, basis="X_umap")
165
181
  ```
@@ -42,13 +42,8 @@ rgb = msp.blend_to_rgb(scores)
42
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 (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
- )
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?"
@@ -29,16 +29,11 @@ gene_sets = {
29
29
  # 1. Score gene sets per cell
30
30
  scores = msp.score_gene_sets(adata, gene_sets, inplace=True)
31
31
 
32
- # 2. Map scores to RGB colors
32
+ # 2. Map scores to RGB colors (returns RGBResult with metadata)
33
33
  rgb = msp.reduce_to_rgb(scores, method="pca")
34
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
- )
35
+ # 3. Plot — method & gene_set_names auto-detected from RGBResult
36
+ msp.plot_embedding(adata, rgb, basis="X_umap")
42
37
  ```
43
38
 
44
39
  [Get Started](getting-started.md){ .md-button .md-button--primary }