Ahmed Doghri Logo Image
Ahmed Doghri

spatialniche

Coordinates become tissue context. Across 250 seeded permutations, the compact tumor neighborhood reaches a 5.10 z-score.

spatialniche spatial transcriptomics neighborhood graph
spatialniche working browser demo

Expression Is Not The Whole Tissue

A cell's transcriptome says what is active. Its neighbors say which microenvironment it occupies. Flatten those coordinates into a table and tumor boundaries, immune exclusion, and stromal niches disappear.

spatialniche builds a k-nearest-neighbor graph directly from spatial coordinates, counts cell-type contacts, and asks whether each pairing exceeds a label-permuted null model.

Make The Null Model Inspectable

The engine is deterministic: seeded permutations, explicit edge counts, and sortable observed, expected, and z-score output. The same function drives the CLI, JSON API, browser workbench, and tests.

The Demo

Twelve cells produce 19 graph edges. Across 250 permutations, tumor-to-tumor enrichment reaches 5.10, stroma-to-stroma reaches 5.06, and the immune-to-tumor boundary is depleted at -2.40.

The compact JSON input is intentionally smaller than AnnData or SpatialData. Segmentation, batch correction, and biological validation remain upstream responsibilities.

Research Basis

The statistic follows Squidpy's neighborhood-enrichment approach: compare observed cluster contacts with contacts after repeatedly permuting cluster labels.

Read the Squidpy neighborhood enrichment.

Tools Used

Python
Spatial Transcriptomics
k-NN Graphs
Permutation Tests
Docker
unittest
GitHub Actions CI