Skip to content

docs: add as_points tutorial - #15

Open
timtreis wants to merge 6 commits into
mainfrom
feat/as-points-tutorial
Open

docs: add as_points tutorial#15
timtreis wants to merge 6 commits into
mainfrom
feat/as-points-tutorial

Conversation

@timtreis

@timtreis timtreis commented Aug 14, 2026

Copy link
Copy Markdown
Member

Adds tutorials/as_points.ipynb, covering how and why to use as_points on render_shapes and render_labels.

What it covers

  • as_points=True draws one centroid dot per element instead of the full geometry; outline_*, shape and contour_px are ignored.
  • The appearance controls that still apply: color (gene name, column, or literal), size, cmap, palette. The visuals colour by EPCAM to show a real spatial trend.
  • A real Xenium breast-cancer section with 167780 cells, so the timings mean something.
  • Segmentation masks are derived from the real cell_boundaries via rasterize(return_regions_as_labels=True), since Xenium rep1 ships outlines as shapes with no native labels element.
  • Backend selection and the AS_POINTS_DS_AUTO = 50000 matplotlib-to-datashader switch, plus the datashader fallback for the random-colour-per-cell case.
  • The measured speed trade-off, benchmarked up to the full 167780 cells: a large win for shapes (up to 16x), about neutral for labels (a mask already renders as a fast downsampled raster, so as_points there is about representation, not speed).

CI

The dataset is a 3.4 GB download, too heavy for execute.yaml. The notebook is added to the exclude filter and its committed outputs are trusted (executed locally, zero errors). Lint still runs and passes.

Wiring

Gallery card and toctree entry in tutorials/index.md; thumbnail at _static/img/as_points.png showing real cell boundaries turning into centroid points.

Show the how and why of `as_points` on both render_shapes and
render_labels, using a real Xenium breast-cancer section (~168k cells).
Covers what it draws (one centroid dot per element), what it ignores
(outline_*, shape, contour_px), the matplotlib->datashader backend
switch at ~50k centroids, and the measured speed trade-off: a large
win for shapes (up to ~16x), roughly neutral for labels (a mask
already renders as a fast raster).

Segmentation masks are derived from the real cell_boundaries via
rasterize(return_regions_as_labels=True), since Xenium rep1 ships
outlines as shapes with no native labels element.

The 3.4 GB download makes the notebook too heavy for CI, so it is
excluded from execute.yaml and its committed outputs are trusted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown

📖 Docs preview: https://scverse.org/spatialdata-plot-tutorials/pr-15/gallery.html

Built from 684af4d; redeployed on every push.

github-actions Bot pushed a commit that referenced this pull request Aug 14, 2026
Show as_points on render_shapes and render_labels using a real Xenium
breast-cancer section (167780 cells). Covers what it draws (one centroid
dot per element), the appearance controls that still apply (color, size,
cmap, palette), what it ignores (outline_*, shape, contour_px), the
matplotlib and datashader backends with the 50000-centroid switch, and
the measured speed trade-off: a large win for shapes (up to 16x), about
neutral for labels (a mask already renders as a fast raster).

Segmentation masks are derived from the real cell_boundaries via
rasterize(return_regions_as_labels=True), since Xenium rep1 ships
outlines as shapes with no native labels element.

The 3.4 GB download makes the notebook too heavy for CI, so it is
excluded from execute.yaml and its committed outputs are trusted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Aug 14, 2026
Open the speed section with the entire 167780-cell section rendered as
full geometry and as as_points, coloured by EPCAM. Previously the full
dataset only appeared as as_points in the backend section; the
full-geometry vs as_points comparison was limited to the crop.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Aug 14, 2026
The default backend already draws the 167780-cell as_points panel with
datashader, so the backend section's datashader render repeated the
full-section image. Drop that render and explain the backend in prose,
referencing the panel above.

In the shared-scale two-panel crops, draw the colourbar only on the
right panel so it no longer overlaps the neighbouring axes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Aug 14, 2026
At the default marker size the datashader spread left white gaps, so the
whole-section panel looked grainy. Draw it with datashader and size=12 so
each cell spreads into continuous coverage, matching the overview look,
and note in the prose that size controls the spread on that backend.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Aug 14, 2026
Revert the whole-slide full-geometry vs as_points panel and its
follow-on tweaks; the notebook reads better without it. This restores
the matplotlib vs datashader backend comparison that had been removed.
The only change kept from that stretch is drawing a single colourbar
per shared-scale panel pair, so they no longer overlap.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant