Tutorial: explore cells in 2D¶
Walk through the ileum molab notebook on Xu et al. 2026 ileum MERFISH (#343). Each step below matches one section of the notebook and shows a visible result on the map or in a table.
1. Load the ileum slice¶
Download the slice with ml.datasets or the short alias ml.ds (pinned URL, user cache). The matrix X is already the authors' log-normalized values — do not call normalize_total or log1p.
Result: adata is 30,332 cells × 1,815 genes with obsm["spatial"] in micrometres. The notebook preloads a small curated gene list in ml.peek(..., genes=...) so the widget export stays within the static payload budget. See the Datasets reference for fields and citation.
2. Open the map on cell types¶
DEMO_GENES = [
"Apob", "Slc5a1", "Nos2", "Cps1", "Mki67", "Lgr5", "Erbb3", "H2-Eb1",
"Acta2", "Col1a1", "Phox2b", "Kit", "Pecam1", "Mzb1", "Cd3e", "Csf1r",
"Cxcl13", "Cr2", "Ccr7",
]
w = ml.peek(adata, color="cell_type", genes=DEMO_GENES)
w
Result: The full ileum ring appears, coloured by cell_type.
3. Layer and villus–crypt genes¶
Recolour in place — no new figure objects:
w.color = "anatomical_layer" # mucosa, submucosa, muscle, GALT
w.color = "Apob" # villus-tip enterocytes
w.color = "Cps1" # crypt / lower villus
Result: You see the crypt–villus axis and the GALT patches in anatomical layers before you select them.
4. Lasso GALT cryptopatch aggregates¶
Use the Select tool and lasso each GALT cryptopatch on the map (Select regions). Xu et al. annotate these as small ILF-like aggregates (rich in cDC, ILC3, and FRC), not classical B/T follicles. Each edit updates w.selections.
The notebook seeds two tight polygons (galt-aggregates-west and galt-aggregates-east). Join them for downstream analysis:
galt_hits = w.get_obs_names("galt-aggregates-west").union(
w.get_obs_names("galt-aggregates-east")
)
Result: The seeded headless lassos select 278 cells in total, 261 with anatomical_layer GALT (93.9% of the selection), covering all 260 annotated GALT cells in the two cryptopatch aggregates on this slice. The western polygon is 90.2% GALT (164 cells, 148 GALT); the tightened eastern polygon is 99.1% GALT (114 cells, 113 GALT). Your own lassos may differ.
5. Enrichment and violin plots¶
Result: Stromal and innate immune types rank highest by log2_enrichment relative to the whole section (seeded union: FRC 6.20, cDC (Il22ra2+) 6.04, ILC3 5.66, FDC 5.35, B (follicular) 4.52).
Flag the selection and plot immune markers:
adata.obs["galt_vs_rest"] = "rest"
adata.obs.loc[galt_hits, "galt_vs_rest"] = "GALT selection"
sc.pl.violin(adata, ["Mzb1", "Cd3e"], groupby="galt_vs_rest")
Result: Mzb1 and Cd3e are higher in the GALT selection than in the rest of the section.