Skip to content
PointillViz Build & publish a tool
PointillViz

© 2026 PointillViz

All tools

BANKSY niches

No ratings yet by PointillViz reference tools

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

Download .pvtool · 61.1 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

Niches from each cell and its neighbourhood
Download

Readme

Which tissue domains, or niches, does the tissue divide into, based on what each cell and its neighbours express?

The tool runs BANKSY with the authors’ own Python package, pybanksy, and their default settings. BANKSY describes each cell by its own expression together with that of its spatial neighbours, and groups cells with similar descriptions into niches.

The counts are first normalized and reduced to the most variable genes, which gives each cell i its own expression x(i). The tool then averages the expression of the cell’s k nearest neighbours N(i), using weights w(i,j) that sum to 1 and, by default, decrease with distance:

By default, a third block is added: the azimuthal Gabor filter (AGF) g(i), which weights neighbouring cells by their direction around cell i. It therefore responds where expression changes from one side of the neighbourhood to the other, as at a tissue border. Each block is z-scored gene by gene, and the blocks are joined using the neighbourhood weight λ:

Without the AGF, m(i) receives the full weight λ. With λ = 0.8, the neighbourhood dominates and the niches follow tissue domains; with λ = 0.2, they resemble spatially informed cell types. The joined profiles are reduced to their principal components and clustered with the Leiden algorithm, and each cluster forms one niche.

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 labelled cells that belong to that cell type. Without a cell-type annotation, the columns show the niches’ top marker genes instead, colored by their marker z-scores.

Table. Each row represents one niche. Cells and % of cells give its size. Marker genes lists the five genes whose mean expression in the niche has the highest z-score relative to all cells, while Main cell types gives its three most common cell types with their shares. A download lists the niche of every cell.

With several sections, each cell’s neighbours come from its own section, and all sections share one set of niches.

References

Singhal V, Chou N, Lee J, et al. BANKSY unifies cell typing and tissue domain segmentation for scalable spatial omics data analysis. Nat Genet 56, 431-441 (2024).

Parameters

ParameterDefaultWhat it does
Neighbourhood weight (lambda) lambda_param Default: 0.8Range 0 to 1. Sets how much a cell’s neighbourhood counts against its own expression. The authors use 0.8 for tissue domains and 0.2 for spatially informed cell types; 0 ignores space.
Spatial neighbours (k_geom) k_geom Default: 15Range 5 to 30. Sets how many nearest cells form each cell’s neighbourhood. The authors use 15 for single-cell data.
AGF order (max_m) max_m Default: 1Range 0 to 1. Sets whether the azimuthal Gabor filter (AGF) is added: 1 adds it, 0 uses the neighbourhood’s mean alone. The AGF responds where expression changes across a neighbourhood, as at a border; the authors recommend it.
Neighbour weights nbr_weight_decay Default: Scaled Gaussian (the authors’ default) Sets how a neighbour’s weight falls with its distance.

Or: Reciprocal, Ranked (AGF order 0 only), Uniform

Z-score zscore_by Default: Per section (the authors’ multi-sample way) Sets over which cells each gene is z-scored when a run holds several sections. It changes nothing on one section. Per section evens out differences in a gene’s overall level between sections, which suits replicates of one tissue. Across all sections keeps them, which suits sections of different tissues.

Or: Across all sections

Principal components (pca_dims) pca_dims Default: 20Range 5 to 50. Sets how many principal components of the BANKSY matrix the clustering uses. The authors use 20.
Leiden resolution resolution Default: 0.7Range 0.05 to 3. Sets the resolution of the Leiden clustering: higher values give more, smaller niches, and lower values fewer, larger ones. 0.7 is the authors’ default. Not used when Number of niches is set.
Number of niches (max_labels) max_labels Default: 0Range 0 to 30. Sets a number of niches for the package to aim for, by searching for a resolution that gives it; 0 uses the resolution as set. The search can stop short of that number, and the summary then says so.
Expression neighbours (num_nn) num_nn Default: 50Range 10 to 100. Sets how many neighbours each cell has in the graph that Leiden partitions, in the space of the principal components. The authors use 50.
Variable genes (n_top_genes) n_top_genes Default: 2,000Range 50 to 5,000. Sets how many of the most variable genes are used. The authors use 2000.
Label refinement (iterations) refine_iterations Default: 0Range 0 to 5. Sets how many times each cell takes the niche of most of its 6 nearest cells; 0 is off. The authors offer it for domain segmentation and warn that too much of it erodes fine domains.

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, 61.1 kB packed and 288.1 kB unpacked, plugin.json at the root.

  2. manifestpass

    banksy-niches 1.0.1 by PointillViz reference tools; Python entry tool.py, outputs summary, labels, matrix, table.

  3. environmentpass

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

  4. entrypass

    tool.py imported in 12.44 s and defines run(ds, params).

  5. imports advisorypass

    1 source file, using anndata, banksy, banksy_utils, gc, gzip, matplotlib, numpy, pandas, pointillviz_tool, psutil, random, scanpy, scipy, threadpoolctl, warnings; no network, subprocess, filesystem-write, dynamic-exec or environment use found.

  6. fixturepass

    ran on the 600-cell fixture in 5.78 s, returning summary, table, matrix, files, labels and 113 log lines.

  7. resultpass

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

  8. edgepass

    ran at the minimum corner (k_geom=5, lambda_param=0.0, max_m=0, n_top_genes=50, num_nn=10, pca_dims=5, resolution=0.05) in 5.41 s; ran at the maximum corner (k_geom=30, lambda_param=1.0, max_labels=30, n_top_genes=5000, nbr_weight_decay='uniform', num_nn=100, pca_dims=50, refine_iterations=5, resolution=3.0, zscore_by='all') in 6.70 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