Skip to contents

The Delaunay triangulation of the cells is computed and every triangle whose circumradius is smaller than alpha is kept; the union of the kept triangles is the tissue region. This follows the boundary step of the real-data analyses: compute it from all cells of the section (not only the cell type analyzed), so that the density of one cell type is modeled over the whole tissue rather than over its own convex hull.

Usage

denmark_alpha_shape(
  x,
  y,
  alpha = NULL,
  alpha_mult = 3,
  keep = c("largest", "all"),
  fill_holes = TRUE
)

Arguments

x, y

Cell coordinates (all cells of the section).

alpha

Circumradius threshold; the default is alpha_mult times the median Delaunay edge length.

alpha_mult

Multiplier for the default alpha (3, as in the analyses).

keep

"largest" keeps the largest connected piece of tissue, "all" keeps every piece.

fill_holes

Fill holes inside the tissue.

Value

An sfc polygon (package sf) with the attribute "alpha".

Examples

toy <- denmark_toy_data()
tissue <- denmark_alpha_shape(toy$x, toy$y)
attr(tissue, "alpha")
#> [1] 0.1068794
sf::st_area(tissue)
#> [1] 8.538532