Skip to content
PointillViz Build & publish a tool
PointillViz

© 2026 PointillViz

All tools

Seurat niches

No ratings yet by PointillViz reference tools

Which niches the tissue divides into, judged by the cell types around each cell.

Download .pvtool · 151.3 kB

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

Seurat v5
Download

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 i, the tool finds its k nearest cells and counts how many of them belong to each cell type t, giving n(i,t). These counts are then scaled for each cell type across all cells:

Here, n¯(t) and s(t) are the mean and standard deviation of n(i,t) over all cells. A positive z(i,t) therefore means that cell i has more type-t 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

ParameterDefaultWhat 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 summary
  • labelsPaints categories on the spatial view
  • matrixReturns a heatmap
  • tableReturns a table
  • filesReturns files to downloadoptional

Tool test summary

9 of 9 gates passed when this version was released. They ran in this order:

  1. bundlepass

    6 files, 151.3 kB packed and 526.7 kB unpacked, plugin.json at the root.

  2. manifestpass

    seurat-niches 1.0.1 by PointillViz reference tools; R entry tool.R, outputs summary, labels, matrix, table.

  3. environmentpass

    pixi.lock matches pixi.toml, which declares python, numpy, scipy, r-base, r-jsonlite for linux-64, osx-64, osx-arm64, win-64; environments: default.

  4. entrypass

    tool.R sourced in 2.48 s and defines run <- function(ds, params).

  5. imports advisorypass

    1 source file, using Matrix, Seurat, jsonlite, ps, stats, utils; no network, subprocess, filesystem-write, dynamic-exec or environment use found.

  6. fixturepass

    ran on the 600-cell fixture in 3.14 s, returning summary, table, matrix, files, labels and 1 log line.

  7. resultpass

    returned the declared outputs: summary, table, matrix, files, labels.

  8. edgepass

    ran at the minimum corner (neighbors_k=5, niches_k=2) in 3.03 s; ran at the maximum corner (iter_max=500, neighbors_k=100, niches_k=30) in 3.31 s.

  9. no_mutationpass

    the fixture dataset's 4 files are byte-identical after every run (plugin_cache/, where ds.knn caches, is excluded by design).

Passing the gates is a statement about the gates, not about whether the code is safe to run.

What each gate checks