BANKSY niches
Which niches the tissue divides into, judged by what each cell and its neighbours express.
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 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 its own expression . The tool then averages the expression of the cell’s nearest neighbours , using weights that sum to 1 and, by default, decrease with distance:
By default, a third block is added: the azimuthal Gabor filter (AGF) , which weights neighbouring cells by their direction around cell . 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, 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
| Parameter | Default | What 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 summarylabelsPaints categories on the spatial viewmatrixReturns a heatmaptableReturns a tablefilesReturns files to downloadoptional
More tools
-

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

Smoothie
Which genes share a spatial pattern across the tissue, grouped into modules.
-

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.