You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spun out from #321 (the thread there mixes two unrelated asks — this issue is the second one, originally raised by @brainfo).
`render_images` already supports multi-channel additive compositing: you pass several channels with per-channel colormaps and they blend into a single RGB image, mirroring napari / ImageJ / FIJI for fluorescence microscopy. The same idiom is useful for sequencing-based spatial data, where a user wants to visualize co-expression of 2–3 genes per cell/spot/region on a single axis — red for gene A, green for gene B, blue for gene C, additively blended so co-expressing cells appear yellow/cyan/white.
Today this requires manual post-processing (the user in #321 mentions doing it in Illustrator).
Proposed API
Mirror the existing `render_images` multi-channel convention by letting `color` accept a list of obs/var columns on `render_shapes`, `render_labels`, and `render_points`:
```python
sdata.pl.render_shapes(
color=["Sox2", "Pax6", "Tbr2"],
palette=["red", "green", "blue"], # one color per channel
channels_as_legend=True,
).pl.show()
Output: a single axis (no multi-panel grid). Each shape / label / point gets one composited color derived from its per-column values blended via per-channel colormaps, identical in spirit to the additive multi-channel path already in `render_images`.
Why this is feasible
The additive-blending machinery already exists in `pl/render.py` for the multi-channel image path (see `render_images` branches 2A/2B/2C). The same per-channel cmap + sum + clip logic applies.
Single-axis output sidesteps the hierarchy-of-axes complexity that made multi-panel `color=[...]` (the other ask from Plotting multiple genes #321) undesirable.
`channels_as_legend` already exists for `render_images`; can extend.
Scope
In scope: 2–3-column color lists on `render_shapes`, `render_labels`, `render_points`. Per-channel `cmap` or `palette`. Additive blend on a single axis.
Motivation
Spun out from #321 (the thread there mixes two unrelated asks — this issue is the second one, originally raised by @brainfo).
`render_images` already supports multi-channel additive compositing: you pass several channels with per-channel colormaps and they blend into a single RGB image, mirroring napari / ImageJ / FIJI for fluorescence microscopy. The same idiom is useful for sequencing-based spatial data, where a user wants to visualize co-expression of 2–3 genes per cell/spot/region on a single axis — red for gene A, green for gene B, blue for gene C, additively blended so co-expressing cells appear yellow/cyan/white.
Today this requires manual post-processing (the user in #321 mentions doing it in Illustrator).
Proposed API
Mirror the existing `render_images` multi-channel convention by letting `color` accept a list of obs/var columns on `render_shapes`, `render_labels`, and `render_points`:
```python
sdata.pl.render_shapes(
color=["Sox2", "Pax6", "Tbr2"],
palette=["red", "green", "blue"], # one color per channel
channels_as_legend=True,
).pl.show()
sdata.pl.render_labels(
color=["Sox2", "Pax6"],
palette=["red", "green"],
).pl.show()
sdata.pl.render_points(
color=["Sox2", "Pax6"],
).pl.show()
```
Output: a single axis (no multi-panel grid). Each shape / label / point gets one composited color derived from its per-column values blended via per-channel colormaps, identical in spirit to the additive multi-channel path already in `render_images`.
Why this is feasible
Scope
Edge cases to design for
Relation to #321
#321 conflates two asks under "plotting multiple genes":
The documentation sub-tasks in #321 (`save`, `ncols` on `pl.show()`) are already resolved.