Explore spatial biology in your notebook.
Layer images, cells, and transcripts in 3D, in one reactive widget.
You have a spatial dataset and a hunch. milume turns a notebook cell into a tactile,
reactive surface where you can look at your tissue, select what catches your eye, and
carry that selection straight into code. Cells, landmarks and measurements stay in
plain AnnData / obs_names / geometry, so what you see on the surface is what you
analyze next.
One call opens it:
import milume
w = milume.peek(adata, color="cell_type")
Draw selections and landmarks, color by category or gene, expand neighborhoods, and read everything back in Python. The name comes from mille (thousand, as in mille-feuille, layers) + lume (light).
Contents
Install
pip install milume
With uv:
uv add milume
# or, into an existing environment, with .pyc compiled up front for a faster first import:
uv pip install --compile-bytecode milume
See the changelog for what changed in each release.
Use with AI agents
npx skills add ckmah/milume --skill use-milume
In Claude Code, add the marketplace once, then install the plugin (only the use-milume skill):
/plugin marketplace add ckmah/milume
/plugin install use-milume@milume
With milume installed, copy the matching skill from the wheel:
python -m milume.skill install
Skill source: skills/use-milume/SKILL.md.
Contributors: see AGENTS.md for dev setup.
Migrate from spatial-rx
Note: Milume was formerly spatial-rx. The API is unchanged; only the names moved:
pip uninstall spatial-rx
pip install milume
import milume # was: import spatial_rx
Alongside other viewers
Milume complements other viewers. Use milume to form intuition: layer images, cells,
and transcripts in a notebook, select what stands out, and carry the selection straight
into your analysis code. Use heavier viewers when you need to inspect in depth.
Landmarks and selections round-trip as plain geometry and obs_names, so you can hand
the same regions to any viewer.
API
milume.peek(data, **kwargs) opens the surface on your data and returns a widget w
you read results from. Full widget guide and generated API reference:
docs site.
import milume
w = milume.peek(adata, color="cell_type") # AnnData with obsm["spatial"]
w = milume.peek(sdata, color="cell_type") # SpatialData on disk: adds the 3D cube
| Argument | Meaning |
|---|---|
data |
AnnData with obsm["spatial"], or a SpatialData |
color |
obs column to color cells by |
genes |
gene(s) to expose for coloring; limits the catalog on large matrices |
spatial_key |
obsm key holding coordinates (default "spatial") |
table, image, labels |
override what is inferred from a SpatialData |
contrast_limits |
display range for the 3D image (default: its 1st percentile to its max, from the coarsest pyramid level) |
milume.peek works on AnnData and on-disk SpatialData (including Pyxa-backed
mosaics). For Xenium, Atera, CosMx, and other readers, see
Other platforms below and the
LandmarksWidget guide on the docs site.
Other platforms
Read with spatialdata-io as usual. Xenium and Atera work with defaults (obsm["spatial"] is the cell position in global coordinates). CosMx puts FOV-local pixels in obsm["spatial"]; use global coordinates instead:
import spatialdata_io as sio
import milume
w = milume.peek(sio.cosmx(path), spatial_key="global")
- From a SpatialData, the widget finds the table, the per-slice cell polygons it annotates, a 3D image, and their µm frame (override with
table=,image=,shapes=;contrast_limits=for the image). - Press I (Inspect): the top toolbar turns into a dashed Inspect pill, hovering shows a live coarse preview of the tissue under the cursor, and a click places a 300 µm window; on release a full-resolution cube of it takes over the plot area, cells drawn as 3D meshes colored like the map, with your landmarks on top. Shift+drag in the cube (or the Move tool) slides the window across the tissue; a plain drag orbits. The bottom bar holds the camera, Adjust (image and cell display) and Cross-section (cuts). Esc (or ×) closes the cube and leaves Inspect in one press. The side panels' peek tabs stay over the cube, so you can focus a category or Selection to color it.
- Save window on the Inspect pill adds the window as an inspect selection, listed in the Selections panel with a thumbnail and named by its main category and size (e.g.
Epithelial · 214); hover a row for its cell count and category mix, click it to reopen the window. Read the inspected cells back withw.get_obs_names(adata, "<inspect id>")orw.selections. - Hold Space to pan in any tool.
Read results back in Python:
| Need | Call |
|---|---|
| Cells in a selection | w.get_obs_names(selection_id) or w.get_obs_names("focus") (a pd.Index); adata.obs[key] = adata.obs_names.isin(w.get_obs_names(selection_id)) |
| Landmarks as geometry | landmarks_to_geodataframe(w.landmarks) |
| Measure against landmarks | distances, composition, along_positions (+ write_obs) |
| Compare a subset with the tissue | enrichment(adata, obs_names, obs_key=...) |
| XY vs 3D neighbors | nearest_distances(adata, seeds, obs_key=...) (needs obsm["spatial"] x, y, z) |
| Map colors for other plots | w.category_colors("cell_type") |
| Inspect window and cube cut | w.inspect_open = True opens the cube at w.inspect_cx, w.inspect_cy, or at the volume centre when no window is placed (set them to move it; False closes it and exits Inspect); w.inspect_size_um; w.volume_cut = x0, x1, y0, y1, z0, z1 µm (intersect X/Y with the window for the shown box) |
Gene expression loads per gene when you first colour by it, so whole-transcriptome
panels (18k genes × 170k cells) open without sending the matrix. genes=[...] restricts
the catalog and preloads it when it packs under 64 MiB.
Metadata
Release files for milume 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| milume-2.1.0.tar.gz | 8.6 MB | Without provenance | Details for milume-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| milume-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for milume-2.1.0-py3-none-any.whl |
Total release size: 9.8 MB
Release files / milume-2.1.0.tar.gz
| Download URL | milume-2.1.0.tar.gz |
|---|---|
| Size | 8.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
845d245e2426e4720d8d0f363df4a52214135599abdbcff1d5f188228c5ec505
|
|
BLAKE2b-256 checksum How to use checksums |
9a7b33de992e546f138ee92b8e9fc94af2151691b62b35bad88da36429004af1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / milume-2.1.0-py3-none-any.whl
| Download URL | milume-2.1.0-py3-none-any.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b63ac29b54da7ac19b0d6f0127ba0f185d39f2e911030543b8f729511fe38386
|
|
BLAKE2b-256 checksum How to use checksums |
dc141cc8c5b21bb16726da000a26287c7b253f8417714c0f845c86c4d77ad54f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for milume 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.