Load AnnData / SpatialData¶
Open milume on AnnData or SpatialData you already have in the notebook.
Goal¶
Show spatial cells (and, for SpatialData, the Inspect cube when a 3D image is available) with milume.peek.
AnnData¶
- Load AnnData with coordinates in
obsm["spatial"](for example the ileum demo slice):
- If your matrix uses another
obsmkey, passspatial_key=when you callpeek.
Result: The Landmarks map opens on the ileum section, colored by cell_type.
Constructor options (color, genes, spatial_key, …) are in the LandmarksWidget API.
SpatialData¶
Install the platform reader once:
Then read with the loader for your platform and pass the object to peek. milume infers the table, cell polygons, and 3D image when they are present. Override with table=, image=, labels=, or shapes= when needed (constructor parameters).
Pyxa¶
-
Install a
spatialdata-iobuild that includes the Pyxa reader (see the Landmarks molab demo pin if the release you use does not yet shippyxa). -
Read Stellaromics Pyxa output into SpatialData:
from pathlib import Path
import spatialdata as sd
from spatialdata_io.experimental import pyxa
data_dir = Path("/path/to/pyxa/small") # counts, metadata, DAPI mosaic
sdata = pyxa(data_dir, cell_assigned_gene=False)
- To use Inspect on the DAPI mosaic, write the store to disk and reopen it (the cube reads the image from Zarr):
- Open milume on the table you want to color (for example
rnaafter you add a cluster column):
Result: Pyxa cells and mosaic load; Inspect is available after the Zarr round-trip.
Xenium¶
- Point
spatialdata_io.xeniumat the Xenium*_outsfolder (or a subset of its files):
import spatialdata_io as sio
import milume
sdata = sio.xenium("/path/to/xenium_outs", transcripts=False)
w = milume.peek(sdata)
w
- Set
w.colorto any categorical column on the table, or passcolor=topeekwhen you open it.
Result: Xenium cells render in global coordinates from obsm["spatial"] (default spatial_key).
Platform-specific reader flags stay in the spatialdata-io docs.
CosMx¶
- Read CosMx flat files with
spatialdata_io.cosmx:
import spatialdata_io as sio
import milume
sdata = sio.cosmx("/path/to/cosmx_flat_files", dataset_id="my_run", transcripts=False)
- Pass
spatial_key="global". CosMx FOV-local pixels live inobsm["spatial"]; milume needs global coordinates:
Result: CosMx cells from every FOV share one map in global pixel space.
For Inspect behavior on platforms without per-slice cell meshes, see Inspect in 3D.