Skip to contents

Global Moran’s I is defined as

I=ni=1nj=1nwiji=1nj=1nwij(xix)(xjx)i=1n(xix)2, I = \frac{n}{\sum_{i=1}^n \sum_{j=1}^n w_{ij}} \frac{\sum_{i=1}^n \sum_{j=1}^n w_{ij} (x_i - \bar{x})(x_j - \bar{x})}{\sum_{i=1}^n (x_i - \bar{x})^2},

where nn is the number of spots or locations, ii and jj are different locations, or spots in the Visium context, xx is a variable with values at each location, and wijw_{ij} is a spatial weight, which can be inversely proportional to distance between spots or an indicator of whether two spots are neighbors, subject to various definitions of neighborhood.

Local Moran’s I (Anselin 1995) is defined as

Ii=(n1)(xix)j=1nwij(xjx)i=1n(xix)2. I_i = (n-1)\frac{(x_i - \bar{x})\sum_{j=1}^n w_{ij} (x_j - \bar{x})}{\sum_{i=1}^n (x_i - \bar{x})^2}.

It’s similar to global Moran’s I, but the values at locations ii are not summed and there’s no normalization by the sum of spatial weights.

Below is a list of vignettes that use local Moran’s I. The links point to the sections that use local Moran’s I. The corresponding Google Colab notebooks are also linked to. The list is sorted by technology.

Vignette Colab Notebook Description
Spatial analysis with 10X example Visium dataset Colab Notebook Perform local Moran’s I on QC metrics and gene expression in mouse olfactory bulb dataset from 10X website.
Spatial Visium exploratory data analysis Colab Notebook Perform Moran’s I on gene Myh2 (myosin heavy chain 2) in mouse skeletal muscle dataset
CosMX NSCLC analysis Colab Notebook Perform local Moran’s I on QC metrics and on marker genes in a human non-small cell lung cancer dataset
Xenium breast cancer analysis Colab Notebook Perform local Moran’s I on QC metrics and marker genes in a human breast cancer dataset
MERFISH mouse liver analysis Colab Notebook Perform local Moran’s I on QC metrics in a mouse liver dataset
10X v3 Basic Colab Notebook Apply local Moran’s I to QC metrics and marker genes in non-spatial human PBMC scRNA-seq dataset, with k nearest neighbor graph in gene expression PCA space rather than histological space

References

Anselin, Luc. 1995. “Local Indicators of Spatial Association—LISA.” Geogr. Anal. 27 (2): 93–115.