Skip to contents

Scatter plot with colour scaled by local cell density. Requires CellDensity to have been run.

Usage

DensityPlot(object, pt_size = 1, title = NULL, palette = NULL, y_down = TRUE)

Arguments

object

An SpatialCellData object with a density column.

pt_size

Numeric. Point size. Default 1.

title

Character or NULL.

palette

Character or character vector. Default NULL (global palette).

y_down

Logical. If TRUE (default), y increases downward, as in image coordinates (origin at the top left; QuPath, cellspecR), so the map has the orientation of the tissue image. Use FALSE for coordinates whose y axis points up.

Value

A ggplot object.

Examples

counts <- matrix(rnorm(100), nrow = 50,
                 dimnames = list(NULL, c("CD3", "CD8")))
coords <- data.frame(x = runif(50, 0, 100), y = runif(50, 0, 100))
obj <- CreateSpatialObject(counts, coords)
obj <- CellDensity(obj, radius = 20)
DensityPlot(obj)