Quantitative Spatial Analysis - CirroBioApps/quantitative-spatial-analysis GitHub Wiki

A powerful approach for biomedical research is spatial analysis, where gene and/or protein expression can be measured for a large number of cells while capturing their physical coordinates in space.

This free and open source software package provides an interactive interface for performing quantitative analysis of spatial datasets.

Key Elements

  • Interactive selection of physical regions of interest
  • Unsupervised clustering to identify cell types shared across regions
  • Neighborhood analysis to identify contiguous groupings of similar mixtures of cell types
  • Interactive annotation of cell types and neighborhoods
  • Visualization of spatial patterns across regions
  • Quantitative comparison of cell distributions across neighborhoods, clusters, and regions

Input Data

Spatial datasets currently supported:

  • Spatial Proteomics:
  • Spatial Transcriptomics:
    • 10X Xenium

The backend used for data storage and analysis is Cirro. Upload datasets to your Cirro account to analyze them with this toolkit.

Run Comparative Analysis

1. Log In

Open the app at https://spatialanalysis.streamlit.app/ and select the appropriate organization for logging into Cirro.

A link will then be provided which will authenticate the session -- closing or refreshing the page will end the session.

2. Annotate Regions

First select the Cirro Project containing the data of interest and then select the specific dataset (e.g. "Xeniumranger V1 hSkin Melanoma Add on FFPE") by clicking on the checkbox to the left of the dataset name.

Note that analysis outputs from a particular dataset (e.g. StarDist or Proseq segmentation) will be grouped in this list along with their primary source data.

Once the dataset is selected, details of that dataset will be presented along with links to view the dataset in Cirro and the "Pick Region" button.

Use the lasso tool to outline the region of interest, provide a name, and click "Save Region".

Screen Recording 2025-03-06 at 10 24 19 PM

Region annotations are saved in the Cirro Project alongside the source dataset. Use the Cirro interface directly to rename or delete regions, or share them with collaborators.

3. Analyze Regions

Use the "Dataset Type" dropdown to view the "Combined Analysis" display.

Quantitative analysis of spatial data may be performed on multiple regions from one or more source datasets. However, only a single measurement modality - Xenium or PhenoCycler may be analyzed independently, but not in combination.

  • Select the regions of interest using the dropdown menu at the top of the page
  • Provide a descriptive name of the analysis
  • Modify any of the analysis parameters as needed
  • Click "Run" to launch the analysis

Explore Analysis Results

Select a completed analysis using the checkbox to the left of its name.

1. UMAP Embedding

In the UMAP display, every point is a cell and the distance between points is related to the similarity of measurements (gene or protein abundance). By inspecting how distinct each cluster of cells is in UMAP space, you can evaluate whether the analysis should be repeated with a different clustering resolution. Larger clustering resolution thresholds will yield a larger number of clusters, and vice versa.

2. Compare Features Across Clusters

By inspecting which features are more abundant in different clusters, the user can develop a biological understanding of what cell types are represented in each cluster. This helps provide more meaningful labels for the numeric labels provided by the unsupervised clustering.

3. Annotate Clusters

The user may upload a spreadsheet with custom annotations of cell clusters. Multiple clusters may be assigned the same label, which can be used to combine those clusters in the quantitative comparison tools shown below. Any number of annotation columns may be provided, as long as the cluster column is retained.

NOTE: Annotation tables are not saved within the application, and must be saved by the user in some other location.

4. Annotate Neighborhoods

In a similar manner, the user may provide annotations with more meaningful names for the neighborhoods which were identified by unsupervised clustering.

5. View Spatial Coordinates

The spatial coordinates of cells from a particular region may be plotted, using any of the provided annotations. Groups of cells may be optionally filtered out of the display, and the visual layout may be modified interactively.

6. Compare Cell Counts

A quantitative summary of the distribution of cells across regions, clusters, and neighborhoods may be explored by the user. In addition to simple plots, the underlying data may be exported as CSVs for analysis in other statistical or plotting environments.