Date: 2026-04-28

# Introduction to Clustering of Local Indicators of Spatial Assocation (LISA) curves

Nicolas Canete1*, Ellis Patrick1,2** and Alex Run Qin1,2***

1Westmead Institute for Medical Research, University of Sydney, Australia
2School of Mathematics and Statistics, University of Sydney, Australia

*nicolas.canete@sydney.edu.au
**ellis.patrick@sydney.edu.au
***alex.qin@sydney.edu.au

#### 28 April 2026

#### Abstract

Identify and visualise regions of cell type colocalization in multiplexed imaging data that has been segmented at a single-cell resolution.

#### Package

lisaClust 1.20.0

# Contents

# 1 Installation

    if (!require("BiocManager")) {
      install.packages("BiocManager")
    }
    BiocManager::install("lisaClust")

    # load required packages
    library(lisaClust)
    library(spicyR)
    library(ggplot2)
    library(SingleCellExperiment)
    library(SpatialDatasets)

# 2 Overview

Clustering local indicators of spatial association (LISA) functions is a methodology for identifying consistent spatial organisation of multiple cell-types in an unsupervised way. This can be used to enable the characterization of interactions between multiple cell-types simultaneously and can complement traditional pairwise analysis. In our implementation our LISA curves are a localised summary of an L-function from a Poisson point process model. Our framework `lisaClust` can be used to provide a high-level summary of cell-type colocalization in high-parameter spatial cytometry data, facilitating the identification of distinct tissue compartments or identification of complex cellular microenvironments.

# 3 Quick start

## 3.1 Generate toy data

To illustrate our `lisaClust` framework, we consider a very simple toy example where two cell-types are completely separated spatially. We simulate data for two different images.

    set.seed(51773)
    x <- round(c(
      runif(200), runif(200) + 1, runif(200) + 2, runif(200) + 3,
      runif(200) + 3, runif(200) + 2, runif(200) + 1, runif(200)
    ), 4) * 100
    y <- round(c(
      runif(200), runif(200) + 1, runif(200) + 2, runif(200) + 3,
      runif(200), runif(200) + 1, runif(200) + 2, runif(200) + 3
    ), 4) * 100
    cellType <- factor(paste("c", rep(rep(c(1:2), rep(200, 2)), 4), sep = ""))
    imageID <- rep(c("s1", "s2"), c(800, 800))

    cells <- data.frame(x, y, cellType, imageID)

    ggplot(cells, aes(x, y, colour = cellType)) +
      geom_point() +
      facet_wrap(~imageID) +
      theme_minimal()

## 3.2 Create Single Cell Experiment object

First we store our data in a `SingleCellExperiment` object.

    SCE <- SingleCellExperiment(colData = cells)
    SCE
    ## class: SingleCellExperiment
    ## dim: 0 1600
    ## metadata(0):
    ## assays(0):
    ## rownames: NULL
    ## rowData names(0):
    ## colnames: NULL
    ## colData names(4): x y cellType imageID
    ## reducedDimNames(0):
    ## mainExpName: NULL
    ## altExpNames(0):

## 3.3 Running lisaCLust

We can then use the convenience function `lisaClust` to simultaneously calculate local indicators of spatial association (LISA) functions and perform k-means clustering. The number of clusters can be specified with the `k =` parameter. In the example below, we’ve chosen `k = 2`, resulting in a total of 2 clusters. The cell type column can be specified using the `cellType =` argument. By default, `lisaClust` uses the column named `cellType`.

The clusters identified by `lisaClust` are stored in `colData` of the `SingleCellExperiment` object as a new column called `regions`.

    SCE <- lisaClust(SCE, k = 2)
    colData(SCE) |> head()
    ## DataFrame with 6 rows and 5 columns
    ##           x         y cellType     imageID      region
    ##   <numeric> <numeric> <factor> <character> <character>
    ## 1     36.72     38.58       c1          s1    region_2
    ## 2     61.38     41.29       c1          s1    region_2
    ## 3     33.59     80.98       c1          s1    region_2
    ## 4     50.17     64.91       c1          s1    region_2
    ## 5     82.93     35.60       c1          s1    region_2
    ## 6     83.13      2.69       c1          s1    region_2

## 3.4 Plot identified regions

`lisaClust` also provides the convenient `hatchingPlot` function to visualise the different regions that have been demarcated by the clustering. `hatchingPlot` outputs a `ggplot` object where the regions are marked by different hatching patterns. In a real biological dataset, this allows us to plot both regions and cell-types on the same visualization.

In the example below, we can visualise our stimulated data where our 2 cell types have been separated neatly into 2 distinct regions based on which cell type each region is dominated by. `region_2` is dominated by the red cell type `c1`, and `region_1` is dominated by the blue cell type `c2`.

    hatchingPlot(SCE, useImages = c("s1", "s2"))

## Using other clustering methods.

While the `lisaClust` function is convenient, we have not implemented an exhaustive suite of clustering methods as it is very easy to do this yourself. There are just two simple steps.

### 3.4.1 Generate LISA curves

We can calculate local indicators of spatial association (LISA) functions using the `lisa` function. Here the LISA curves are a localised summary of an L-function from a Poisson point process model. The radii that will be calculated over can be set with `Rs`.

    lisaCurves <- lisa(SCE, Rs = c(20, 50, 100))

    head(lisaCurves)
    ##           20_c1     20_c2     50_c1     50_c2    100_c1     100_c2
    ## cell_1 5.556700 -2.764143 15.631209 -6.910357 11.733097  -9.198914
    ## cell_2 4.833149 -2.764143 13.940407 -6.910357  9.532662  -8.543440
    ## cell_3 5.918476 -2.764143  9.008588 -6.910357  9.157887  -7.813862
    ## cell_4 4.109597 -2.764143 11.907928 -6.910357  8.404425  -8.140036
    ## cell_5 3.024270 -2.764143 10.159278 -6.910357  9.006286  -8.283564
    ## cell_6 7.986742 -2.764143  8.675070 -6.910357 12.859615 -13.820714

### 3.4.2 Perform some clustering

The LISA curves can then be used to cluster the cells. Here we use k-means clustering. However, other clustering methods like SOM could also be used. We can store these cell clusters or cell “regions” in our `SingleCellExperiment` object.

    # Custom clustering algorithm
    kM <- kmeans(lisaCurves, 2)

    # Storing clusters into colData
    colData(SCE)$custom_region <- paste("region", kM$cluster, sep = "_")
    colData(SCE) |> head()
    ## DataFrame with 6 rows and 6 columns
    ##           x         y cellType     imageID      region custom_region
    ##   <numeric> <numeric> <factor> <character> <character>   <character>
    ## 1     36.72     38.58       c1          s1    region_2      region_2
    ## 2     61.38     41.29       c1          s1    region_2      region_2
    ## 3     33.59     80.98       c1          s1    region_2      region_2
    ## 4     50.17     64.91       c1          s1    region_2      region_2
    ## 5     82.93     35.60       c1          s1    region_2      region_2
    ## 6     83.13      2.69       c1          s1    region_2      region_2

# 4 Keren et al. breast cancer data.

Next, we apply our `lisaClust` framework to two images of breast cancer obtained by Keren et al. (2018).

## 4.1 Read in data

We will start by reading in the data from the `SpatialDatasets` package as a `SingleCellExperiment` object. Here the data is in a format consistent with that outputted by CellProfiler.

    kerenSPE <- SpatialDatasets::spe_Keren_2018()

## 4.2 Generate LISA curves

This data includes annotation of the cell-types of each cell. Hence, we can move directly to performing k-means clustering on the local indicators of spatial association (LISA) functions using the `lisaClust` function, remembering to specify the `imageID`, `cellType`, and `spatialCoords` columns in `colData`. For the purpose of demonstration, we will be using only images 5 and 6 of the `kerenSPE` dataset.

    kerenSPE <- kerenSPE[,kerenSPE$imageID %in% c("5", "6")]

    kerenSPE <- lisaClust(kerenSPE,
      k = 5
    )

These regions are stored in `colData` and can be extracted.

    colData(kerenSPE)[, c("imageID", "region")] |>
      head(20)
    ## DataFrame with 20 rows and 2 columns
    ##           imageID      region
    ##       <character> <character>
    ## 21154           5    region_4
    ## 21155           5    region_4
    ## 21156           5    region_4
    ## 21157           5    region_3
    ## 21158           5    region_3
    ## ...           ...         ...
    ## 21169           5    region_3
    ## 21170           5    region_3
    ## 21171           5    region_1
    ## 21172           5    region_3
    ## 21173           5    region_1

## 4.3 Examine cell type enrichment

`lisaClust` also provides a convenient function, `regionMap`, for examining which cell types are located in which regions. In this example, we use this to check which cell types appear more frequently in each region than expected by chance.

Here, we clearly see that healthy epithelial and mesenchymal tissue are highly concentrated in region 1, immune cells are concentrated in regions 2 and 4, whilst tumour cells are concentrated in region 3.

We can further segregate these cells by increasing the number of clusters, i.e., increasing the parameter `k =` in the `lisaClust()` function. For the purposes of demonstration, let’s take a look at the `hatchingPlot` of these regions.

    regionMap(kerenSPE,
      type = "bubble"
    )

## 4.4 Plot identified regions

Finally, we can use `hatchingPlot` to construct a `ggplot` object where the regions are marked by different hatching patterns. This allows us to visualize the 5 regions and 17 cell-types simultaneously.

    hatchingPlot(kerenSPE, nbp = 300)

# 5 References

Keren, L, M Bosse, D Marquez, R Angoshtari, S Jain, S Varma, S Yang, et al. 2018. “A Structured Tumor-Immune Microenvironment in Triple Negative Breast Cancer Revealed by Multiplexed Ion Beam Imaging.” Cell 174 (6): 1373–1387.e19.

# Appendix

# A sessionInfo()

    sessionInfo()
    ## R version 4.6.0 RC (2026-04-17 r89917)
    ## Platform: x86_64-pc-linux-gnu
    ## Running under: Ubuntu 24.04.4 LTS
    ##
    ## Matrix products: default
    ## BLAS:   /home/biocbuild/bbs-3.23-bioc/R/lib/libRblas.so
    ## LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.12.0  LAPACK version 3.12.0
    ##
    ## locale:
    ##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
    ##  [3] LC_TIME=en_GB              LC_COLLATE=C
    ##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
    ##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
    ##  [9] LC_ADDRESS=C               LC_TELEPHONE=C
    ## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
    ##
    ## time zone: America/New_York
    ## tzcode source: system (glibc)
    ##
    ## attached base packages:
    ## [1] stats4    stats     graphics  grDevices utils     datasets  methods
    ## [8] base
    ##
    ## other attached packages:
    ##  [1] SpatialDatasets_1.9.0       SpatialExperiment_1.22.0
    ##  [3] ExperimentHub_3.2.0         AnnotationHub_4.2.0
    ##  [5] BiocFileCache_3.2.0         dbplyr_2.5.2
    ##  [7] SingleCellExperiment_1.34.0 SummarizedExperiment_1.42.0
    ##  [9] Biobase_2.72.0              GenomicRanges_1.64.0
    ## [11] Seqinfo_1.2.0               IRanges_2.46.0
    ## [13] S4Vectors_0.50.0            BiocGenerics_0.58.0
    ## [15] generics_0.1.4              MatrixGenerics_1.24.0
    ## [17] matrixStats_1.5.0           ggplot2_4.0.3
    ## [19] spicyR_1.24.0               lisaClust_1.20.0
    ## [21] BiocStyle_2.40.0
    ##
    ## loaded via a namespace (and not attached):
    ##   [1] spatstat.sparse_3.1-0       bitops_1.0-9
    ##   [3] EBImage_4.54.0              httr_1.4.8
    ##   [5] RColorBrewer_1.1-3          numDeriv_2016.8-1.1
    ##   [7] tools_4.6.0                 doRNG_1.8.6.3
    ##   [9] backports_1.5.1             R6_2.6.1
    ##  [11] HDF5Array_1.40.0            mgcv_1.9-4
    ##  [13] rhdf5filters_1.24.0         withr_3.0.2
    ##  [15] sp_2.2-1                    gridExtra_2.3
    ##  [17] coxme_2.2-22                ClassifyR_3.16.0
    ##  [19] textshaping_1.0.5           cli_3.6.6
    ##  [21] spatstat.explore_3.8-0      sandwich_3.1-1
    ##  [23] labeling_0.4.3              sass_0.4.10
    ##  [25] nnls_1.6                    mvtnorm_1.3-7
    ##  [27] S7_0.2.2                    spatstat.data_3.1-9
    ##  [29] systemfonts_1.3.2           ggupset_0.4.1
    ##  [31] svglite_2.2.2               dichromat_2.0-0.1
    ##  [33] RSQLite_2.4.6               simpleSeg_1.14.0
    ##  [35] spatstat.random_3.4-5       car_3.1-5
    ##  [37] dplyr_1.2.1                 scam_1.2-22
    ##  [39] Matrix_1.7-5                ggbeeswarm_0.7.3
    ##  [41] abind_1.4-8                 terra_1.9-11
    ##  [43] lifecycle_1.0.5             multcomp_1.4-30
    ##  [45] yaml_2.3.12                 carData_3.0-6
    ##  [47] rhdf5_2.56.0                SparseArray_1.12.0
    ##  [49] grid_4.6.0                  blob_1.3.0
    ##  [51] promises_1.5.0              crayon_1.5.3
    ##  [53] bdsmatrix_1.3-7             shinydashboard_0.7.3
    ##  [55] lattice_0.22-9              KEGGREST_1.52.0
    ##  [57] magick_2.9.1                cytomapper_1.24.0
    ##  [59] pillar_1.11.1               knitr_1.51
    ##  [61] dcanr_1.28.0                rjson_0.2.23
    ##  [63] boot_1.3-32                 estimability_1.5.1
    ##  [65] codetools_0.2-20            glue_1.8.1
    ##  [67] V8_8.2.0                    spatstat.univar_3.1-7
    ##  [69] data.table_1.18.2.1         MultiAssayExperiment_1.38.0
    ##  [71] vctrs_0.7.3                 png_0.1-9
    ##  [73] Rdpack_2.6.6                gtable_0.3.6
    ##  [75] cachem_1.1.0                xfun_0.57
    ##  [77] rbibutils_2.4.1             S4Arrays_1.12.0
    ##  [79] mime_0.13                   coda_0.19-4.1
    ##  [81] reformulas_0.4.4            survival_3.8-6
    ##  [83] pheatmap_1.0.13             iterators_1.0.14
    ##  [85] tinytex_0.59                TH.data_1.1-5
    ##  [87] nlme_3.1-169                bit64_4.8.0
    ##  [89] filelock_1.0.3              bslib_0.10.0
    ##  [91] svgPanZoom_0.3.4            vipor_0.4.7
    ##  [93] otel_0.2.0                  DBI_1.3.0
    ##  [95] raster_3.6-32               tidyselect_1.2.1
    ##  [97] emmeans_2.0.3               bit_4.6.0
    ##  [99] compiler_4.6.0              curl_7.1.0
    ## [101] httr2_1.2.2                 h5mread_1.4.0
    ## [103] DelayedArray_0.38.0         bookdown_0.46
    ## [105] scales_1.4.0                rappdirs_0.3.4
    ## [107] tiff_0.1-12                 stringr_1.6.0
    ## [109] digest_0.6.39               goftest_1.2-3
    ## [111] fftwtools_0.9-11            spatstat.utils_3.2-2
    ## [113] minqa_1.2.8                 rmarkdown_2.31
    ## [115] XVector_0.52.0              htmltools_0.5.9
    ## [117] pkgconfig_2.0.3             jpeg_0.1-11
    ## [119] lme4_2.0-1                  fastmap_1.2.0
    ## [121] rlang_1.2.0                 htmlwidgets_1.6.4
    ## [123] ggthemes_5.2.0              shiny_1.13.0
    ## [125] ggh4x_0.3.1                 farver_2.1.2
    ## [127] jquerylib_0.1.4             zoo_1.8-15
    ## [129] jsonlite_2.0.0              BiocParallel_1.46.0
    ## [131] RCurl_1.98-1.18             magrittr_2.0.5
    ## [133] Formula_1.2-5               Rhdf5lib_2.0.0
    ## [135] Rcpp_1.1.1-1.1              viridis_0.6.5
    ## [137] ggnewscale_0.5.2            stringi_1.8.7
    ## [139] MASS_7.3-65                 plyr_1.8.9
    ## [141] parallel_4.6.0              deldir_2.0-4
    ## [143] Biostrings_2.80.0           splines_4.6.0
    ## [145] tensor_1.5.1                locfit_1.5-9.12
    ## [147] igraph_2.3.0                ggpubr_0.6.3
    ## [149] spatstat.geom_3.7-3         ggsignif_0.6.4
    ## [151] rngtools_1.5.2              reshape2_1.4.5
    ## [153] BiocVersion_3.23.1          evaluate_1.0.5
    ## [155] BiocManager_1.30.27         nloptr_2.2.1
    ## [157] foreach_1.5.2               tweenr_2.0.3
    ## [159] httpuv_1.6.17               tidyr_1.3.2
    ## [161] purrr_1.2.2                 polyclip_1.10-7
    ## [163] ggforce_0.5.0               broom_1.0.12
    ## [165] xtable_1.8-8                rstatix_0.7.3
    ## [167] later_1.4.8                 viridisLite_0.4.3
    ## [169] class_7.3-23                tibble_3.3.1
    ## [171] lmerTest_3.2-1              memoise_2.0.1
    ## [173] beeswarm_0.4.0              AnnotationDbi_1.74.0
    ## [175] concaveman_1.2.0