Skip to contents

Compute local Moran's I on UMAP/PCA neighborhoods for a given gene to detect spatial autocorrelation hotspots.

Usage

VisLocalMoran(
  object,
  gene,
  reduction = "umap",
  k = 15,
  palette = "C",
  point_size = 2,
  point_alpha = 0.8
)

Arguments

object

A Seurat object; UMAP/PCA is computed when absent.

gene

Gene name; must exist in assay data.

reduction

Reduction name ('umap' or 'pca'). Default: 'umap'.

k

Number of nearest neighbors. Default: 15.

palette

Viridis palette option for color/fill. Default: "C".

point_size

Point size. Default: 2.

point_alpha

Point alpha. Default: 0.8.

Value

A ggplot scatter of local Moran's I values.

Author

benben-miao

Examples

obj <- SeuratVisProExample(
    n_cells = 300,
    n_genes = 1000,
    n_clusters = 10,
    seed = 123,
    genes_mt = "^MT-",
    neighbor_dims = 10,
    cluster_res = 0.5,
    umap_dims = 10,
    spatial = FALSE)
#> Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck
#> 
#> Number of nodes: 300
#> Number of edges: 4508
#> 
#> Running Louvain algorithm...
#> Maximum modularity in 10 random starts: 0.9485
#> Number of communities: 10
#> Elapsed time: 0 seconds

p <- VisLocalMoran(
   obj,
   gene = 'G10',
   reduction = "umap",
   k = 15,
   palette = "C",
   point_size = 2,
   point_alpha = 0.8)
p