Skip to main content

Overview

BANKSY is a spatial omics algorithm that incorporates neighborhood information for clustering spatial transcriptomics data. By augmenting each cell’s expression profile with a summary of its spatial neighborhood, BANKSY can:
  • Improve cell-type assignment in noisy data
  • Distinguish subtly different cell types stratified by microenvironment
  • Identify spatial domains sharing the same microenvironment
The RunBanksy() function in SeuratWrappers brings BANKSY directly into the Seurat workflow.
Citation: Vipul Singhal, Nigel Chou, Joseph Lee, Yifei Yue, Jinyue Liu, Wan Kee Chock, Li Lin, Yun-Ching Chang, Erica Mei Ling Teo, Jonathan Aow, Hwee Kuan Lee, Kok Hao Chen & Shyam Prabhakar. BANKSY unifies cell typing and tissue domain segmentation for scalable spatial omics data analysis. Nature Genetics, 2024. doi: 10.1038/s41588-024-01664-3

Installation

Install the Banksy package from GitHub before using RunBanksy():
Also install SeuratWrappers if you haven’t already:

The lambda parameter

The amount of neighborhood information incorporated is controlled by lambda in [0, 1]:
  • Low lambda (e.g., 0.2) — BANKSY operates in cell-typing mode, emphasizing intrinsic gene expression
  • High lambda (e.g., 0.8) — BANKSY finds spatial domains, emphasizing microenvironment similarity

Parameters

object
Seurat
required
A Seurat object with gene expression data. If spatial coordinates are stored natively (e.g., from Load10X_Spatial()), they are extracted automatically. Otherwise, provide coordinates via dimx/dimy.
lambda
numeric
required
Spatial weight parameter between 0 and 1. Controls the balance between own expression and neighborhood context. Low values favor cell-type clustering; high values favor spatial domain segmentation.
assay
character
default:"'RNA'"
Assay in the Seurat object to use as input.
slot
character
default:"'data'"
Slot within the assay to pull expression data from (e.g., 'data', 'counts').
use_agf
boolean
default:"FALSE"
Whether to use the Azimuthal Gene Function (AGF), a higher-order neighborhood summary.
dimx
character
default:"NULL"
Column name of the x spatial coordinate in the object metadata. Required when spatial coordinates are not stored natively in the Seurat object.
dimy
character
default:"NULL"
Column name of the y spatial coordinate in the object metadata.
dimz
character
default:"NULL"
Column name of the z spatial coordinate in the object metadata (for 3D data).
ndim
integer
default:"2"
Number of spatial dimensions to extract when using Seurat’s native spatial framework.
features
character
default:"'variable'"
Features to include in the BANKSY matrix. Options: 'variable' (uses VariableFeatures()), 'all' (all features), or a character vector of specific feature names.
group
character
default:"NULL"
Column name of a grouping variable in metadata (e.g., 'orig.ident'). Required for multi-sample analysis. Tells BANKSY to stagger spatial coordinates by group so that cells from different samples do not overlap during neighborhood computation.
split.scale
boolean
default:"TRUE"
Whether to perform within-group scaling. Useful when analyzing multiple samples with minor technical differences.
k_geom
numeric
default:"15"
Number of nearest neighbors to use when computing the spatial neighborhood.
spatial_mode
character
default:"'kNN_median'"
Kernel for neighborhood computation. Options:
  • kNN_median — k-nearest neighbors with median-scaled Gaussian kernel
  • kNN_r — k-nearest neighbors with 1/r kernel
  • kNN_rn — k-nearest neighbors with 1/r^n kernel
  • kNN_rank — k-nearest neighbors with rank Gaussian kernel
  • kNN_unif — k-nearest neighbors with uniform kernel
  • rNN_gauss — radial nearest neighbors with Gaussian kernel
n
numeric
default:"2"
Exponent of radius for the kNN_rn spatial mode.
sigma
numeric
default:"1.5"
Standard deviation of the Gaussian kernel for rNN_gauss spatial mode.
alpha
numeric
default:"0.05"
Determines the radius used in rNN_gauss spatial mode.
k_spatial
numeric
default:"10"
Number of neighbors to use in radial nearest-neighbor (rNN) modes.
assay_name
character
default:"'BANKSY'"
Name for the new BANKSY assay added to the Seurat object.
M
numeric
default:"NULL"
Advanced usage. Highest azimuthal harmonic to compute.

Workflow: Seurat spatial framework

Use this approach when your Seurat object already contains spatial coordinates (e.g., loaded via Load10X_Spatial() or from SeuratData).
1

Load libraries and data

2

Preprocess

Filter low-quality beads and normalize:
3

Run BANKSY

The function sets the default assay to BANKSY and populates scale.data with the scaled BANKSY matrix.
Do not call ScaleData() on the BANKSY assay after RunBanksy(). RunBanksy() already populates scale.data with the lambda-weighted scaled matrix. Calling ScaleData() again negates the effect of lambda.
4

Dimensionality reduction

5

Clustering

6

Visualize

7

Find markers

Switch back to the original assay for differential expression:

Workflow: Explicit spatial coordinates

Use this approach when spatial coordinates are stored as metadata columns rather than in a native Seurat spatial slot.
1

Create Seurat object with coordinate metadata

2

Normalize

3

Run BANKSY with explicit coordinates

Pass the metadata column names via dimx and dimy:
4

PCA, clustering, and visualization

Multi-sample analysis

When analyzing multiple spatial datasets jointly (without strong batch effects), provide the group argument to prevent cells from different samples from being treated as spatial neighbors.
Providing group causes RunBanksy() to stagger the spatial coordinates by sample before computing neighborhoods. The staggered coordinates are stored in the metadata as staggered_sdimx and staggered_sdimy for inspection.

Spatial integration with Harmony

For multi-sample data with strong batch effects, combine BANKSY with Harmony:

Additional resources