Skip to contents

UI and server logic for the Spatial Clustering panel, enabling users to run BayesSpace clustering on spatial omics data, visualise spatial clusters, pseudobulk clusters, perform PCA and heatmap analysis, and download all results. Supports sample selection, cluster assignment, and combined clustering across samples.

Usage

RegionPanel_SpatialClustersTabUI(id, bulk.metadata, full.metadata, show = TRUE)

RegionPanel_SpatialClustersTabServer(
  id,
  full.intensity.matrix,
  full.metadata,
  bulk.metadata,
  anno = NULL,
  shared_data = NULL
)

Arguments

id

Shiny module id (for both UI and server)

bulk.metadata

Data frame of bulk sample metadata (UI, server)

full.metadata

Data frame of full sample metadata (UI, server)

show

Logical; whether to show the panel (default TRUE, UI)

full.intensity.matrix

Matrix of intensities (features x samples, server)

anno

Data frame of peak annotations (server, optional)

shared_data

Reactive or shared data object (server, optional)

Value

UI: A shiny tabPanel object for the spatial clustering tab. Server: None (side effects in Shiny module).

Details

  • Run BayesSpace clustering on one or more selected samples. Choose the number of clusters and MCMC iterations.

  • Visualise spatial cluster assignments for each sample, and add cluster labels to shared data for downstream analysis.

  • Pseudobulk clusters across samples and perform PCA to explore similarities between clusters.

  • View a similarity heatmap of pseudobulked clusters, with annotation bars for combined cluster assignments.

  • Perform combined clustering across all samples to identify shared cluster patterns.

  • Visualise combined clusters spatially across all samples in a unified plot.

  • Download all output plots (spatial clusters, PCA, heatmap, combined spatial) in publication-ready format.

  • Note: Clustering and pseudobulking may take several minutes depending on data size and number of samples.