Create a cell mask polygon based on dbscan spatial clusters of cell type(s) of interest

create_cell_masks(
  seurat,
  sample_key = NULL,
  label = NULL,
  label_class = NULL,
  eps = 30,
  minPts = 6,
  concavity = 3,
  lengthThreshold = 0,
  buffer = NULL
)

Arguments

seurat

a Seurat object containing Kandinsky data

sample_key

character string specifying a variable stored in the Seurat object to use as sample/batch annotation.

label

character string indicating meta data variable containing cell type annotation

label_class

character string indicating which cell type(s) to consider to create the cell mask

eps

size (radius) of the epsilon neighborhood. See dbscan documentation for more details.

minPts

number of minimum points required in the eps neighborhood for core points (including the point itself). See dbscan documentation for more details.

concavity

a relative measure of concavity. 1 results in a relatively detailed shape, Infinity results in a convex hull. You can use values lower than 1, but they can produce pretty crazy shapes. See concaveman documentation for more details.

lengthThreshold

when a segment length is under this threshold, it stops being considered for further detalization. Higher values result in simpler shapes. See concaveman documentation for more details.

buffer

numeric, size of spatial buffer to apply to the final cell mask. If NULL, no buffer will be applied. Default is NULL

Value

a sf data.frame object containing the mask polygon coordinates for each cell cluster defined with dbscan

Details

dbscan spatial density clustering is first applied to define independent clusters of cells. Concaveman algorithm is then applied separately to each cluster to draw a concave hull mask