Seurat niches
Which niches the tissue divides into, judged by the cell types around each cell.
In PointillViz: Tools → Store → Install, or Install from file with the download. How to install and run a tool
This runs as you: a tool is arbitrary code, with your privileges. Safety note

Readme
Which neighbourhoods of cell types does the tissue divide into?
The tool runs BuildNicheAssay, the niche analysis of Seurat, with the authors’ own R package and the settings of their Xenium vignette. Only cell types and positions enter the analysis, not gene expression.
For each cell , the tool finds its nearest cells and counts how many of them belong to each cell type , giving . These counts are then scaled for each cell type across all cells:
Here, and are the mean and standard deviation of over all cells. A positive therefore means that cell has more type- neighbours than the average cell. Finally, k-means groups the cells into the chosen number of niches, so that cells within one niche have similar neighbourhood compositions; the best of 30 random starts is kept.
Map. Each cell is colored by its niche. Niches are numbered N1, N2, … from the largest to the smallest; the numbers carry no other meaning.
Matrix. Rows are niches and columns are cell types, ordered by abundance. Each square shows the percentage of the niche’s cells that belong to that cell type.
Table. Each row represents one niche. Cells and % of cells give its size, and Main cell types lists its three most common cell types with their shares. A download lists the niche of every cell.
The number of niches is a choice, not a finding: k-means returns as many as requested. With several sections, each cell’s neighbours come from its own section, and all sections share one set of niches.
References
Hao Y, Stuart T, Kowalski MH, et al. Dictionary learning for integrative, multimodal and scalable single-cell analysis. Nat Biotechnol 42, 293-304 (2024).
Parameters
| Parameter | Default | What it does |
|---|---|---|
Cell-type column (group.by) field |
requireda categorical column | Selects the annotation whose groups are counted around each cell. Defaults to the dataset’s cell-type column. |
Number of niches (niches.k) niches_k |
Default: 5Range 2 to 30. | Sets how many niches k-means makes. The authors use 5 in their Xenium vignette. |
Spatial neighbours (neighbors.k) neighbors_k |
Default: 30Range 5 to 100. | Sets how many nearest cells form each cell’s neighbourhood. More neighbours give broader niches; the authors use 30. |
K-means iterations (iter.max) iter_max |
Default: 10Range 10 to 500. | Sets the maximum number of iterations in each of k-means’ 30 starts. Raise it when the summary says that starts stopped at this limit. |
Outputs
summaryWrites a summarylabelsPaints categories on the spatial viewmatrixReturns a heatmaptableReturns a tablefilesReturns files to downloadoptional
More tools
-

BANKSY niches
Which niches the tissue divides into, judged by what each cell and its neighbours express.
-

Categorical Chords
Explore spatial contacts or shared membership between categorical annotations with count-weighted ribbons and enrichment colors.
-

Cell-Type Co-occurrence
Which cell types are found near each other more often than expected by chance.
-

Cell-type contact network
Which cell types touch which, from a Delaunay triangulation of the cells, as a network and a matrix corrected for abundance.