Skip to contents

Use k-means clustering to cluster local indicators of spatial association. For other clustering use lisa.

Usage

lisaClust(
  cells,
  k = 2,
  r = NULL,
  imageID = "imageID",
  cellType = "cellType",
  spatialCoords = c("x", "y"),
  regionName = "region",
  cores = 1,
  window = "convex",
  window.length = NULL,
  whichParallel = "imimageID",
  sigma = NULL,
  lisaFunc = "K",
  minLambda = 0.05,
  BPPARAM = BiocParallel::SerialParam(),
  Rs = r
)

Arguments

cells

A SingleCellExperiment, SpatialExperiment or data frame that contains at least the variables x and y, giving the coordinates of each cell, imageID and cellType.

k

The number of regions to cluster.

r

A vector of the radii that the measures of association should be calculated.

imageID

The column which contains image identifiers.

cellType

The column which contains the cell types.

spatialCoords

The columns which contain the x and y spatial coordinates.

regionName

The output column for the lisaClust regions.

cores

Number of cores to use for parallel processing, or a BiocParallel MulticoreParam or SerialParam object.

window

Should the window around the regions be 'square', 'convex' or 'concave'.

window.length

A tuning parameter for controlling the level of concavity when estimating concave windows.

whichParallel

Should the function use parallization on the imageID or the cellType.

sigma

A numeric variable used for scaling when filting inhomogeneous L-curves.

lisaFunc

Either "K" or "L" curve.

minLambda

Minimum value for density for scaling when fitting inhomogeneous L-curves.

BPPARAM

{DEPRECATED} A BiocParalell MulticoreParam or SerialParam object.

Rs

A vector of the radii that the measures of association should be calculated.

Value

A matrix of LISA curves

Examples

library(spicyR)
library(SingleCellExperiment)
# Read in data
isletFile <- system.file("extdata", "isletCells.txt.gz", package = "spicyR")
cells <- read.table(isletFile, header = TRUE)
cellExp <- SingleCellExperiment(
    assay = list(intensities = t(cells[, grepl(names(cells), pattern = "Intensity_")])),
    colData = cells[, !grepl(names(cells), pattern = "Intensity_")]
)

# Cluster cell types
markers <- t(assay(cellExp, "intensities"))
kM <- kmeans(markers, 8)
colData(cellExp)$cluster <- paste("cluster", kM$cluster, sep = "")

# Generate LISA
cellExp <- lisaClust(cellExp,
    k = 2,
    imageID = "ImageNumber",
    cellType = "cluster",
    spatialCoords = c("Location_Center_X", "Location_Center_Y")
)
#> Generating local L-curves.