# Spatial Statistics for Proteomics: How to Quantify Cellular Neighborhoods and Tissue Architecture

Spatial proteomics generates high-dimensional measurements of protein expression while preserving the two-dimensional coordinates of each cell within a tissue section. The analytical challenge is to move from visual pattern recognition to quantitative descriptions of cellular neighborhoods and tissue architecture. This article explains how to apply spatial statistics, including Ripley's K, Besag's L, and neighborhood analysis, to imaging mass cytometry (IMC) and other spatial proteomics datasets. The practical outcome is a reproducible workflow for computing spatial metrics, interpreting their biological meaning, and reporting results with appropriate statistical rigor.

## The Problem with Visual Inspection of Spatial Proteomics Data

Tissue sections stained with multiplexed antibody panels produce images that contain dozens of protein markers simultaneously. The human eye can identify obvious patterns such as dense immune infiltrates or tumor-stroma boundaries, but visual assessment has severe limitations for research applications. First, the number of possible cell-cell relationships grows combinatorially with the number of cell types identified. A panel that distinguishes ten cell types generates 55 pairwise relationships to evaluate. Second, visual assessment is subjective and difficult to standardize across multiple images, patients, or research sites. Third, subtle but biologically meaningful spatial patterns may not be apparent to the eye at all.

Spatial statistics provide a formal language for describing tissue architecture. These methods quantify whether cells of a given type are clustered, dispersed, or randomly distributed relative to one another. They also measure the frequency with which specific cell types occur in proximity, which supports inference about cellular neighborhoods and functional niches. The recent maturation of single-cell technologies has created new opportunities to profile spatial, proteomic, and transcriptomic information in individual cells, but these advances come with computational challenges for integrative analysis across multiple data types. Spatial statistics are one component of the analytical toolkit needed to address these challenges.

## Core Spatial Statistics for Proteomics Data

### Point Patterns and Spatial Coordinates

Spatial proteomics data typically consist of a set of cells, each with a centroid coordinate (x, y) and a vector of protein expression values. The coordinates define a point pattern within a bounded region, which is the tissue section or a region of interest within it. The first step in any spatial analysis is to confirm that the coordinate system is consistent across all images in the dataset. Different acquisition platforms may produce different pixel sizes, and images may need to be registered if multiple rounds of staining were performed.

The choice of region boundary matters for spatial statistics. Edge effects occur when cells near the boundary of the image have fewer neighbors than cells in the interior, simply because the image cuts off the tissue. Most spatial statistics include edge corrections, but the corrections assume that the boundary is known and that the point pattern is homogeneous within the region. If the tissue section has large empty areas such as necrosis or folding artifacts, these should be excluded from the analysis region before computing spatial statistics.

### Ripley's K Function

Ripley's K function is a foundational tool for quantifying spatial clustering or dispersion at multiple scales. For a given radius r, K(r) measures the expected number of points within distance r of a randomly chosen point, divided by the overall point density. Under complete spatial randomness, K(r) equals the area of a circle with radius r, which is πr². Values above this expectation indicate clustering, while values below indicate dispersion or regularity.

The K function is often transformed to the L function, where L(r) = sqrt(K(r)/π). This transformation stabilizes the variance and makes the expected value under randomness equal to r, which simplifies interpretation. Besag's L is commonly used in spatial proteomics studies because it provides a straightforward visual reference: positive deviations from the diagonal line indicate clustering, and negative deviations indicate dispersion.

For bivariate analysis, the cross-K function measures the spatial relationship between two different cell types. If K_ab(r) exceeds the expected value, cell type a and cell type b are more likely to be found near each other than expected by chance. If K_ab(r) is below the expected value, the two cell types are segregated. This bivariate extension is particularly useful for questions about immune cell infiltration into tumors or the proximity of cancer-associated fibroblasts to neoplastic cells.

### Neighborhood Analysis

Neighborhood analysis takes a different approach by defining a fixed radius around each cell and counting the number and types of neighboring cells within that radius. This produces a neighborhood composition vector for each cell, which can then be clustered to identify recurring cellular neighborhoods across the tissue. For example, a tertiary lymphoid structure might be defined as a neighborhood enriched in B cells, T cells, and dendritic cells within a characteristic radius.

The choice of radius is a critical parameter in neighborhood analysis. A radius that is too small captures only direct cell-cell contacts, while a radius that is too large averages over the entire tissue and obscures local structure. Researchers should test multiple radii and examine how the resulting neighborhoods change. The radius should be biologically motivated, such as the typical distance over which paracrine signaling operates, but the justification should be stated explicitly in the methods.

### Mixed Effects and Multiple Regions of Interest

Clinical spatial proteomics studies often image multiple regions from the same tumor or tissue sample. This design raises a statistical question: how should spatial summary statistics from multiple images be combined to produce a single patient-level value? A simple approach is to average the summary statistics across images, possibly weighting by the number of cells in each image. More sophisticated ensemble testing approaches simulate random weights to aggregate summaries, test for association with outcomes, and combine the resulting P-values.

Research on this question shows that the optimal strategy varies by dataset and outcome. A weighted average based on the number of cells in each image often provides high statistical power and controls type I error effectively. When the size of the imaged regions varies, incorporating this variation into the weighted aggregation may improve power in cases where the varying size is informative. Ensemble testing approaches offer high power and type I error control across a range of simulated conditions. Researchers should evaluate multiple aggregation strategies instead of defaulting to an unweighted mean.

## At a Glance: Choosing a Spatial Statistic

| Spatial Statistic | Question Answered | Data Requirements | Common Use Case |
|---|---|---|---|
| Univariate Ripley's K or Besag's L | Are cells of one type clustered or dispersed? | Single cell type coordinates, region boundary | Assessing immune cell aggregation or tumor cell dispersion |
| Bivariate cross-K or cross-L | Are two cell types colocalized or segregated? | Two cell type coordinates, region boundary | Testing whether regulatory T cells are near cytotoxic T cells |
| Neighborhood analysis | What cell types co-occur within a fixed radius? | All cell type labels, coordinates, chosen radius | Defining cellular neighborhoods and tissue niches |

## Practical Workflow for Spatial Statistics on IMC Data

### Step 1: Data Preparation and Quality Control

The input to spatial statistics is a cell table with columns for x coordinate, y coordinate, and cell type label. The cell type labels come from a clustering or classification step applied to the single-cell protein expression data. The quality of the spatial analysis depends entirely on the quality of the cell segmentation and classification. Poor segmentation that splits one cell into multiple objects or merges multiple cells into one object will distort the spatial coordinates and produce misleading statistics.

Quality control should include visual inspection of the segmentation masks overlaid on the original images. Check for cells that are implausibly large or small, cells at the image boundary, and regions where the tissue is folded or damaged. The Harpy workflow for spatial proteomics data includes quality control steps at each stage of processing and can accelerate segmentation and feature extraction through parallel processing. This workflow is designed to handle gigapixel-sized datasets that are common in whole-slide spatial proteomics.

### Step 2: Define the Analysis Region

The analysis region should exclude areas that are not informative for the biological question. This includes tissue folds, necrosis, staining artifacts, and regions outside the tissue. Many spatial statistics packages allow the user to define a polygonal window that restricts the analysis to valid tissue areas. The window definition should be recorded for each image so that the analysis is reproducible.

Edge corrections are essential when the analysis region is small relative to the radii being tested. The most common edge corrections are the border method, which excludes points too close to the boundary, and the isotropic correction, which adjusts the weight of each pair based on the fraction of the circle that falls inside the window. The choice of edge correction should be reported in the methods.

### Step 3: Compute Univariate and Bivariate Statistics

For each cell type of interest, compute the univariate L function across a range of radii. The range should extend from the minimum distance between cell centroids to about one quarter of the smallest dimension of the analysis region. Beyond this range, edge effects dominate and the estimates become unreliable.

For bivariate analysis, compute the cross-L function for each pair of cell types that is relevant to the biological question. Testing all possible pairs creates a multiple testing problem, so the analysis should be guided by hypotheses about specific cell-cell interactions. For example, a study of pancreatic cancer progression might focus on the proximity of cancer-associated fibroblasts to pancreatic intraepithelial neoplasia lesions, based on evidence that these fibroblasts are located close to the lesions and that their signaling changes during progression.

### Step 4: Generate Null Distributions

The interpretation of K and L functions requires a null distribution that represents the expected pattern under a specific null hypothesis. The most common null hypothesis is complete spatial randomness, where cells are placed independently and uniformly within the analysis region. Monte Carlo simulation generates many random point patterns with the same number of points and the same window, and the L function is computed for each simulation. The observed L function is then compared to the envelope of the simulated values.

A limitation of complete spatial randomness as a null model is that it does not account for the fact that cells cannot overlap and that tissue has a finite packing density. A more realistic null model might use a hard-core process that enforces a minimum distance between points. The choice of null model should be justified based on the biology of the tissue and the specific question being asked.

### Step 5: Aggregate Across Images

When multiple images are available for the same sample, the spatial summary statistics must be aggregated to produce a sample-level value. The simplest approach is to compute the mean of the L function across images at each radius. A weighted mean that accounts for the number of cells in each image is often more appropriate, as images with more cells provide more precise estimates.

For studies that associate spatial statistics with clinical outcomes, the aggregation method should be evaluated carefully. The research on multiple regions of interest in multiplexed spatial proteomics data shows that a weighted average based on cell count often offers the highest power and controls type I error effectively. Ensemble testing approaches that simulate random weights and combine P-values can provide additional robustness, particularly when the size of the imaged regions varies.

### Step 6: Report Results with Uncertainty

Spatial statistics should be reported with measures of uncertainty. For a single image, the Monte Carlo envelope provides a visual representation of the null distribution. For multiple images, the variation across images provides a natural measure of between-sample heterogeneity. Confidence intervals for the aggregated statistics can be computed using bootstrap resampling across images.

The methods section should report the software packages used, the version numbers, the parameters for each statistic, the range of radii tested, the edge correction method, the null model, and the aggregation method. This level of detail is necessary for reproducibility and for comparison across studies.

## Software Options for Spatial Statistics

### R and Bioconductor Packages

The R programming language has a rich ecosystem for spatial statistics. The [Bioconductor project](https://bioconductor.org/) provides packages for the analysis of high-throughput genomic data, including spatial omics data, with an emphasis on reproducible and documented workflows. Packages such as spatstat provide comprehensive tools for point pattern analysis, including K and L functions, edge corrections, and Monte Carlo tests.

Bioconductor packages are distributed with versioned releases and extensive documentation, which supports reproducible analysis. The project maintains standards for package quality and provides training materials for users. Researchers who are new to spatial statistics in R should start with the official package vignettes, which provide worked examples on real datasets.

### Python Workflows

Python has become a popular choice for spatial proteomics analysis, particularly for large datasets that require efficient processing. The Harpy workflow is a Python-based tool that can process gigapixel-sized spatial proteomics datasets with accelerated segmentation and feature extraction. It integrates with existing spatial single-cell analysis tools in both the Python and R ecosystems, which allows researchers to combine Harpy with other analysis packages.

Harpy includes quality control steps at each stage of processing and supports scalable clustering of cells and pixels for cell type identification. Processing can be performed locally or on high-performance computing servers, which makes it suitable for both small pilot studies and large clinical cohorts. The workflow is available on GitHub and archived on Zenodo for reproducibility.

### Galaxy and nf-core for Workflow Management

For researchers who prefer graphical interfaces or standardized pipelines, the [Galaxy Training Network](https://training.galaxyproject.org/) provides accessible tutorials for bioinformatics analysis, including spatial omics workflows. Galaxy allows users to run analyses through a web interface without writing code, which lowers the barrier for researchers who are not experienced programmers.

The [nf-core project](https://nf-co.re/docs) provides community-developed pipelines that follow standardized practices for reproducibility. These pipelines are built on the Nextflow workflow manager and can be run on local machines or cloud infrastructure. While nf-core pipelines are more commonly used for bulk and single-cell sequencing data, the project's documentation on pipeline standards and configuration is useful for researchers who want to build reproducible spatial analysis workflows.

### Training and Foundational Skills

Spatial statistics require basic programming skills, particularly in R or Python. The [Carpentries](https://carpentries.org/lessons) provides lessons on foundational computing, data analysis, shell, Git, and programming that are relevant for researchers entering this field. The [EMBL-EBI Training](https://www.ebi.ac.uk/training) program offers learning pathways for bioinformatics data resources and practical analysis education. These training resources help researchers build the skills needed to implement spatial statistics correctly and reproducibly.

## Common Failure Patterns in Spatial Statistics

### Ignoring Edge Effects

The most common error in spatial statistics is ignoring edge effects. Cells near the boundary of the image have fewer neighbors simply because the image cuts off the tissue. Without edge correction, the K function will underestimate clustering near the boundary and overestimate dispersion. This bias is particularly severe for small images or for analyses that use large radii.

The solution is to use edge-corrected estimators and to restrict the analysis to radii that are small relative to the size of the analysis region. The border method is simple but discards data near the boundary. The isotropic correction uses all data but requires more computation. The choice of edge correction should be reported and justified.

### Using an Inappropriate Null Model

Complete spatial randomness is the default null model in many software packages, but it is often not appropriate for tissue data. Cells have a minimum physical size and cannot overlap, which creates a regular pattern at very small scales. The tissue also has structure, such as epithelial layers or blood vessels, that creates non-random patterns at larger scales.

A more appropriate null model might condition on the observed distribution of a reference cell type. For example, to test whether immune cells are clustered relative to tumor cells, the null model should preserve the tumor cell positions and randomize only the immune cell positions. This approach, called toroidal shift or random labeling, tests the specific hypothesis of interest instead of the general hypothesis of complete spatial randomness.

### Overinterpreting Small Effects

Spatial statistics can detect statistically significant deviations from randomness that are biologically meaningless. With thousands of cells in an image, even a small deviation from the null model will produce a significant P-value. The magnitude of the effect, beyond the P-value, should be interpreted in the context of the biology.

A useful approach is to compare the observed spatial statistic to the range of values that would be expected under biologically plausible alternative models. For example, if the observed L function shows clustering at a radius of 20 micrometers, the researcher should ask whether this clustering is consistent with known biological structures such as immune aggregates or tertiary lymphoid structures.

### Aggregating Images Incorrectly

When multiple images are available for the same sample, the aggregation method can substantially affect the results. An unweighted average gives equal weight to images with few cells and images with many cells, which can be misleading if the images differ in quality or cellularity. A weighted average based on cell count is often more appropriate.

The research on multiple regions of interest shows that the optimal aggregation strategy varies by dataset. Researchers should evaluate multiple approaches and report the sensitivity of their conclusions to the aggregation method. Ensemble testing approaches that combine P-values from multiple random weightings can provide robustness when the optimal strategy is unclear.

### Failing to Correct for Multiple Testing

Spatial proteomics datasets contain many cell types, and testing all pairwise combinations creates a multiple testing problem. If a panel identifies 15 cell types, there are 105 pairwise combinations to test. At a significance level of 0.05, approximately five false positives would be expected by chance alone.

The analysis should be guided by hypotheses about specific cell-cell interactions, and the number of tests should be limited accordingly. If many tests are performed, the P-values should be adjusted using methods such as the Benjamini-Hochberg procedure to control the false discovery rate.

## Records and Measurements for Spatial Analysis

### What to Record for Each Analysis

Reproducible spatial analysis requires detailed records of the data processing and analysis steps. The following information should be recorded for each dataset:

- The acquisition platform and antibody panel used for the spatial proteomics experiment
- The segmentation algorithm and parameters used to identify cells
- The clustering or classification method used to assign cell type labels
- The coordinates of the analysis region boundary for each image
- The spatial statistics computed, including the range of radii and the edge correction method
- The null model and the number of Monte Carlo simulations
- The aggregation method used to combine statistics across images
- The software packages and version numbers used for each step

This information should be stored in a structured format, such as a metadata file or a lab notebook, so that the analysis can be reproduced by other researchers.

### Quality Control Metrics

Quality control metrics for spatial analysis include the number of cells per image, the cell density, the distribution of cell sizes, and the fraction of cells near the image boundary. These metrics should be reported for each image so that readers can assess the reliability of the spatial statistics.

The Harpy workflow includes quality control steps at each stage of processing, which helps identify problems early in the analysis. Visual inspection of the segmentation masks and the cell type labels overlaid on the images is an essential quality control step that cannot be replaced by automated metrics.

### Between-Sample Variation

Spatial statistics often show substantial variation between samples from the same condition. This variation can be biological, reflecting genuine differences in tissue architecture between patients, or technical, reflecting differences in tissue processing, staining, or imaging. The between-sample variation should be quantified and reported, as it affects the statistical power for detecting differences between conditions.

For clinical studies, the number of images per sample and the number of samples per condition should be chosen based on the expected between-sample variation. Pilot data can be used to estimate this variation and to perform power calculations for the spatial statistics of interest.

## Limitations of Spatial Statistics for Proteomics

### The Resolution Problem

Spatial proteomics platforms vary in their spatial resolution. Imaging mass cytometry typically achieves a resolution of about 1 micrometer, which is sufficient to resolve individual cells but not subcellular structures. The spatial statistics are therefore limited to the cellular level, and conclusions about subcellular localization cannot be drawn from these data.

The resolution also affects the minimum radius that can be meaningfully interpreted. Radii smaller than the typical cell diameter capture within-cell structure instead of cell-cell interactions. The analysis should use radii that are appropriate for the resolution of the platform.

### The Missing Third Dimension

Tissue sections are two-dimensional slices of a three-dimensional organ. The spatial relationships observed in a single section may not reflect the true three-dimensional architecture of the tissue. Cells that appear to be neighbors in a two-dimensional section may be separated in the third dimension, and cells that are true neighbors in three dimensions may not appear in the same section.

This limitation is inherent to all two-dimensional spatial analyses. The interpretation of spatial statistics should acknowledge that the results describe the two-dimensional tissue architecture as sampled by the section, not the full three-dimensional organization.

### The Choice of Cell Type Labels

Spatial statistics operate on cell type labels, which are the output of a clustering or classification step. The choice of clustering algorithm, the number of clusters, and the marker panel all affect the cell type labels and therefore the spatial statistics. Different clustering solutions can produce different spatial patterns, and the results should be interpreted in the context of the clustering approach.

A sensitivity analysis that varies the clustering parameters can help assess the robustness of the spatial findings. If the spatial statistics change substantially with small changes in the clustering parameters, the conclusions should be tempered accordingly.

### The Challenge of Integration with Other Omics

Spatial proteomics data are often collected alongside other types of single-cell data, such as single-cell RNA sequencing or spatial transcriptomics. Integrating these data types is computationally challenging but can provide a more complete picture of cellular states and interactions. The recent advances in single-cell omics technologies have expanded to include spatial transcriptomics and CRISPR screening, which creates opportunities for integrative analysis.

The integration of spatial proteomics with other data types requires careful alignment of cell identities and spatial coordinates. The semi-supervised learning framework used in pancreatic cancer research demonstrates how spatial transcriptomics and single-cell RNA sequencing can be integrated with imaging proteomics to characterize cell state transitions during tumorigenesis. These integrative approaches are powerful but require specialized computational expertise.

## Safety and Regulatory Context for Spatial Proteomics Research

### Data Management and Privacy

Spatial proteomics data from human tissue samples are subject to data protection regulations, including the General Data Protection Regulation in the European Union and the Health Insurance Portability and Accountability Act in the United States. Researchers must ensure that patient identifiers are removed from the data and that the data are stored securely. The data management plan should specify who has access to the data, how the data are stored, and how long the data will be retained.

### Reproducibility Standards

Funding agencies and journals increasingly require that spatial proteomics data and analysis code be deposited in public repositories. The [NCBI](https://www.ncbi.nlm.nih.gov/) provides data resources for the storage and retrieval of biological data, including sequence data and associated metadata. Researchers should deposit their data in appropriate repositories and provide the analysis code so that other researchers can reproduce the results.

The nf-core project provides standards for reproducible bioinformatics pipelines, and the Galaxy Training Network offers tutorials for accessible workflow analysis. These resources support the goal of reproducible spatial proteomics analysis.

### Professional Escalation Criteria

Researchers should seek expert consultation when they encounter the following situations:

- The spatial statistics produce results that are inconsistent with known biology or with visual inspection of the images
- The segmentation or cell type classification produces implausible results that cannot be resolved with standard quality control
- The dataset is too large for the available computational resources, requiring specialized workflows such as Harpy
- The study involves integration of multiple omics data types, requiring specialized computational expertise
- The statistical analysis requires methods that are not implemented in the researcher's familiar software environment

In these situations, collaboration with a bioinformatics specialist or a statistician with experience in spatial analysis is recommended. The EMBL-EBI Training program and the Carpentries lessons can help researchers build the skills needed to address these challenges independently.

## A Decision Framework for Selecting Spatial Statistics in Proteomics Studies

Choosing the right spatial statistic for a proteomics dataset is not a one-size-fits-all decision. The biological question, the tissue type, the imaging platform, and the downstream analytical goals all influence which metric will produce interpretable and defensible results. This section provides a practical decision framework that researchers can apply before committing to a specific analytical approach.

### Define the Primary Biological Question First

The first decision point is to articulate the exact biological question in operational terms. Spatial statistics answer different questions, and the choice of metric should follow directly from the question being asked. Three common question types map to distinct analytical approaches.

The first question type asks whether a single cell type exhibits a non-random spatial distribution. This is a univariate question that is answered with Ripley's K or Besag's L. For example, a researcher might ask whether tumor cells are more clustered than expected by chance within a tissue section. The output is a function of radius that describes the scale at which clustering or dispersion occurs.

The second question type asks whether two cell types are spatially associated. This is a bivariate question answered with the cross-K or cross-L function. The researcher specifies a reference cell type and a target cell type, then tests whether the target cells are enriched or depleted near the reference cells. This approach is appropriate for questions about immune cell infiltration into tumors or the proximity of stromal cells to epithelial structures.

The third question type asks what cellular neighborhoods exist in the tissue. This is a multivariate question answered with neighborhood analysis. The researcher defines a radius, computes the composition of cells within that radius for every cell, and clusters the resulting composition vectors to identify recurring neighborhood types. This approach is appropriate for questions about tissue organization and the identification of functional niches.

### Match the Statistic to the Data Structure

The structure of the dataset imposes constraints on which statistics can be computed reliably. The number of cells per image, the number of images per sample, and the spatial resolution of the platform all matter.

For datasets with fewer than 100 cells of a given type, univariate K and L functions will have wide confidence intervals and limited power to detect clustering. In this case, neighborhood analysis may be more appropriate because it does not require as many cells to produce a meaningful composition vector. The neighborhood composition can be computed for each cell regardless of the total number of cells in the image.

For datasets with multiple images per sample, the aggregation strategy becomes a critical decision. The research on multiple regions of interest in multiplexed spatial proteomics data shows that a weighted average based on the number of cells in each image often offers the highest power and controls type I error effectively. When the size of the imaged regions varies, incorporating this variation into the weighted aggregation may yield additional power in cases where the varying size is informative. Ensemble testing approaches that simulate random weights can provide robustness when the optimal strategy is unclear.

For datasets that span multiple tissue sections or patients, the between-sample variation must be quantified. Spatial statistics often show substantial variation between samples from the same condition, and this variation affects the statistical power for detecting differences between conditions. Pilot data should be used to estimate this variation and to perform power calculations before committing to a full analysis.

### Consider the Computational and Technical Constraints

The computational cost of spatial statistics varies substantially across methods. Univariate K and L functions are computationally efficient and can be computed for millions of cells with standard hardware. Bivariate cross-K functions require pairwise distance calculations between two cell types, which scales with the product of the two cell counts. Neighborhood analysis requires computing the distance from every cell to every other cell within the chosen radius, which can be computationally intensive for large datasets.

The Harpy workflow addresses scalability challenges for gigapixel-sized spatial proteomics datasets. It can rapidly apply state-of-the-art segmentation and feature extraction via parallel processing, and each analysis step is accompanied by appropriate quality control steps. Scalable clustering of cells and pixels allows identification of cell types, processed up to 27 times faster than previously reported. Processing and visualization can be performed locally or on high-performance computing servers.

The choice of software environment also matters. R and Bioconductor packages provide comprehensive tools for point pattern analysis, including K and L functions, edge corrections, and Monte Carlo tests. Python workflows such as Harpy integrate well with existing spatial single-cell analysis tools in both the Python and R software ecosystems. Researchers should choose the environment that best matches their existing skills and the computational resources available.

### Apply a Structured Decision Process

The following decision process can be applied to any spatial proteomics dataset. The process is designed to be iterative, with each step informing the next.

First, write down the primary biological question in operational terms. Specify the cell types involved, the spatial scale of interest, and the expected pattern if the hypothesis is true. This statement will guide the choice of statistic and the interpretation of results.

Second, assess the data structure. Count the number of cells per image, the number of images per sample, and the number of samples per condition. Identify any images with low cellularity, poor segmentation quality, or large empty areas that should be excluded from the analysis.

Third, select the primary statistic based on the biological question and the data structure. Use the At a Glance table in this article as a starting point, but adjust the choice based on the specific constraints of the dataset.

Fourth, compute the statistic and generate a null distribution. The null model should be chosen to test the specific hypothesis of interest. For bivariate questions, the null model should preserve the positions of the reference cell type and randomize only the target cell type.

Fifth, assess the sensitivity of the results to key parameters. Vary the radius range, the edge correction method, and the null model. If the conclusions change substantially with small changes in these parameters, the results should be interpreted with caution.

Sixth, aggregate across images using a method that accounts for the number of cells in each image. Evaluate the sensitivity of the conclusions to the aggregation method, and report the range of results across methods.

### Record the Decision Rationale

The decision framework should be documented as part of the analysis record. For each dataset, record the biological question, the data structure assessment, the chosen statistic, the null model, the parameters tested, and the rationale for each choice. This documentation supports reproducibility and allows other researchers to understand why specific analytical decisions were made.

The methods section of any resulting publication should report the software packages and version numbers, the segmentation algorithm and parameters, the cell type classification method, the spatial statistics computed, the range of radii tested, the edge correction method, the null model and number of simulations, and the aggregation method for multiple images. This level of detail is necessary for reproducibility and for comparison across studies.

### Common Decision Errors and How to Avoid Them

A common error is choosing a statistic based on what is familiar instead of what is appropriate for the biological question. Researchers who have used Ripley's K in one context may default to it in a new context where neighborhood analysis would be more informative. The decision framework should be applied deliberately to avoid this bias.

Another common error is failing to account for the data structure when choosing an aggregation method. An unweighted average across images gives equal weight to images with few cells and images with many cells, which can be misleading if the images differ in quality or cellularity. The research on multiple regions of interest shows that a weighted average based on cell count is often more appropriate.

A third error is overinterpreting small effects that are statistically significant but biologically meaningless. With thousands of cells in an image, even a small deviation from the null model will produce a significant P-value. The magnitude of the effect should be interpreted in the context of the biology, and the observed statistic should be compared to the range of values expected under biologically plausible alternative models.

### Escalation Criteria for Complex Analyses

Some spatial proteomics analyses require specialized expertise beyond the standard workflow. Researchers should seek expert consultation when the dataset involves integration of multiple omics data types, when the computational requirements exceed available resources, or when the statistical methods required are not implemented in the researcher's familiar software environment.

The integration of spatial proteomics with spatial transcriptomics and single-cell RNA sequencing is a particularly complex analytical challenge. The semi-supervised learning framework used in pancreatic cancer research demonstrates how these data types can be integrated to characterize cell state transitions during tumorigenesis. These integrative approaches are powerful but require specialized computational expertise.

The EMBL-EBI Training program and the Carpentries lessons can help researchers build the skills needed to address these challenges independently. The Galaxy Training Network provides accessible tutorials for bioinformatics analysis, including spatial omics workflows, through a web interface that does not require programming experience.

## Frequently Asked Questions

### What is the difference between Ripley's K and Besag's L?

Ripley's K function measures the expected number of points within a given radius of a randomly chosen point, divided by the point density. Besag's L is a transformation of K, defined as the square root of K divided by pi. The L function has the advantage that its expected value under complete spatial randomness is equal to the radius, which makes it easier to interpret visually. Positive deviations of L from the expected value indicate clustering, and negative deviations indicate dispersion.

### How do I choose the radius for neighborhood analysis?

The radius should be biologically motivated and based on the scale of the cellular interactions being studied. A radius of 10 to 20 micrometers captures direct cell-cell contacts and short-range paracrine signaling. A radius of 50 to 100 micrometers captures larger structures such as immune aggregates or tumor niches. Researchers should test multiple radii and examine how the resulting neighborhoods change. The chosen radius should be reported in the methods with a justification.

### What is the minimum number of cells needed for spatial statistics?

There is no fixed minimum number of cells, but the reliability of spatial statistics increases with the number of cells. With fewer than 100 cells of a given type, the estimates of clustering or dispersion will have wide confidence intervals and may not be meaningful. The Monte Carlo envelope provides a visual assessment of whether the observed pattern is distinguishable from randomness given the number of cells.

### How do I handle multiple images from the same patient?

The spatial summary statistics from multiple images should be aggregated to produce a patient-level value. A weighted average based on the number of cells in each image is often appropriate. The research on multiple regions of interest shows that this approach often offers high statistical power and controls type I error effectively. Ensemble testing approaches that simulate random weights can provide additional robustness when the optimal aggregation strategy is unclear.

### What edge correction should I use?

The choice of edge correction depends on the size of the analysis region and the range of radii being tested. The border method excludes points that are too close to the boundary, which is simple but discards data. The isotropic correction adjusts the weight of each pair based on the fraction of the circle that falls inside the window, which uses all data but requires more computation. The choice should be reported in the methods.

### Can spatial statistics be applied to other spatial omics data?

Yes, the same spatial statistics can be applied to any data that provides spatial coordinates for individual cells or features. This includes spatial transcriptomics, multiplexed immunofluorescence, and other imaging-based omics technologies. The key requirement is a set of coordinates and a categorical label for each point. The interpretation of the statistics depends on the biology of the system being studied.

### How do I test whether two cell types are colocalized?

The bivariate cross-L function tests whether two cell types are more or less likely to be found near each other than expected by chance. The null model should preserve the positions of one cell type and randomize the positions of the other cell type, which tests the specific hypothesis of colocalization. The observed cross-L function is compared to the Monte Carlo envelope to assess statistical significance.

### What should I report in the methods section?

The methods should report the software packages and version numbers, the segmentation algorithm and parameters, the cell type classification method, the spatial statistics computed, the range of radii tested, the edge correction method, the null model and number of simulations, and the aggregation method for multiple images. This level of detail is necessary for reproducibility and for comparison across studies.

## Related Bioinformatics Guides

- [Genomic Data Analysis Tools: A Comparative Guide for Researchers](/knowledge/bioinformatics/genomic-data-analysis-tools-a-comparative-guide-for-researchers)
- [Spatial Proteomics vs. Single-Cell Proteomics: Choosing the Right Approach](/knowledge/bioinformatics/spatial-proteomics-vs-single-cell-proteomics-choosing-the-right-approach)
- [Spatial Transcriptomics Data Analysis: A Guide to Preprocessing, Integration, and Interpretation](/knowledge/bioinformatics/spatial-transcriptomics-data-analysis-a-guide-to-preprocessing-integration-and-interpretation)
- [Spatial Transcriptomics Workflow: From Sample Preparation to Data Analysis](/knowledge/bioinformatics/spatial-transcriptomics-workflow-from-sample-preparation-to-data-analysis)
- [Proteomics Mass Spectrometry: From Sample Preparation to Data Analysis](/knowledge/bioinformatics/proteomics-mass-spectrometry-from-sample-preparation-to-data-analysis)

## References and Further Reading

- [NCBI Data Resources](https://www.ncbi.nlm.nih.gov/). National Center for Biotechnology Information.
- [EMBL-EBI Training](https://www.ebi.ac.uk/training). European Bioinformatics Institute.
- [Bioconductor](https://bioconductor.org/). Bioconductor Project.
- [Galaxy Training Network](https://training.galaxyproject.org/). Galaxy Project.
- [nf-core Documentation](https://nf-co.re/docs). nf-core.
- [The Carpentries Lessons](https://carpentries.org/lessons). The Carpentries.
- [Integrative single-cell analysis.](https://pubmed.ncbi.nlm.nih.gov/30696980). Nature reviews. Genetics, 2019.
- [Single-cell omics: experimental workflow, data analyses and applications.](https://pubmed.ncbi.nlm.nih.gov/39060615). Science China. Life sciences, 2025.
- [Scalable analysis of whole slide spatial proteomics with Harpy.](https://pubmed.ncbi.nlm.nih.gov/41826800). Bioinformatics (Oxford, England), 2022.
- [Statistical analysis of multiple regions-of-interest in multiplexed spatial proteomics data.](https://pubmed.ncbi.nlm.nih.gov/39428129). Briefings in bioinformatics, 2024.
- [PanIN and CAF transitions in pancreatic carcinogenesis revealed with spatial data integration.](https://pubmed.ncbi.nlm.nih.gov/39116880). Cell systems, 2024.

> This article is educational and does not replace validated analysis plans, institutional policy, clinical interpretation, or specialist review.