Skip to contents

Get contour from density

Usage

getContour(
  spe,
  coi = NULL,
  equal.cell = FALSE,
  bins = NULL,
  binwidth = NULL,
  breaks = NULL,
  id = "cell_type"
)

Arguments

spe

A SpatialExperiment object.

coi

A character vector of cell types of interest (COIs).

equal.cell

Logical. Whether to use produce contour levels so that there are roughly the same number of cells of the COI at each level.

bins

An integer. Number of contour levels.

binwidth

A numeric scale of the smoothing bandwidth.

breaks

A numeric scale referring to the breaks in ggplot2:::contour_breaks.

id

A character. The name of the column of colData(spe) containing the cell type identifiers. Set to cell_type by default. Only needed when equal.cell = TRUE.

Value

A SpatialExperiment object. An sf object of the contour region of the specified level is stored in the metadata of the SpatialExperiment object.

Examples


data("xenium_bc_spe")

spe <- gridDensity(spe)

coi <- "Breast cancer"

spe <- getContour(spe, coi = coi)
#> Using bins = 10 to draw contours.