Calculate the Moran's I statistic for spatial autocorrelation of a dataset. Spatial autocorrelation is multi-directional and multi-dimensional, it has a value from -1 to 1.
Arguments
- seu_obj
A seurat object.
- features
A character vector specifying the features (genes or probes) to include in the analysis. If
NULL
(the default), all features inseu_obj
are used.
Value
A data frame.
A data frame with Moran's I values for each feature (gene or control probe), along with sample ID, platform, gene/probe name, and type (Gene or Control). Each row corresponds to a feature, and columns include the sample identifier, platform used, Moran's I value, gene/probe name, and the type indicating whether it's a Gene-targeting probe or a Control probe.
Details
The function first processes gene-targeting probes by converting the input data into a SingleCellExperiment
object, then into a SpatialFeatureExperiment
object;
Spatial coordinates are specified and used to further process the data, including normalization and nearest neighbor graph construction. Subsequently, Moran's I is calculated for each feature using the Voyager
package. The same process is repeated for control probes. The results for both gene-targeting and control probes are combined into a single data frame.
The spatial autocorrelation analysis provides Moran's I values for each feature, indicating the degree of spatial clustering. This is performed separately for gene-targeting probes and control probes, allowing for a comparison of spatial patterns in gene expression and background noise.