Identify the cells bordering a group of cells of a particular phenotype, and calculate the number of clustered groups of this cell type.
identify_bordering_cells(
spe_object,
reference_cell,
feature_colname = "Cell.Type",
ahull_alpha = NULL,
n_to_exclude = 10,
plot_final_border = TRUE
)
SpatialExperiment object in the form of the output of
format_image_to_spe
.
String. Cells of this cell type will be used for border detection.
String that specifies the column of `reference_cell`.
Number specifying the parameter for the alpha hull algorithm. The larger the number, the more cells will be included in one cell cluster.
Integer. Clusters with cell count under this number will be deleted.
Boolean if plot the identified bordering cells.
A new SPE object is returned. The SPE object has a `Region` column with "Border", "Inside" and "Outside" categories. The returned object also has an attribute saving the number of clusters.
The bordering cell detection algorithm is based on computing an alpha hull (Hemmer et al., 2020), a generalization of convex hull (Green and Silverman, 1979). The cells detected to be on the alpha hull are identified as the bordering cells.
spe_border <- identify_bordering_cells(SPIAT::defined_image,
reference_cell = "Tumour", feature_colname = "Cell.Type", n_to_exclude = 10)
#> [1] "The alpha of Polygon is: 63.24375"
n_clusters <- attr(spe_border, "n_of_clusters") # get the number of clusters
n_clusters
#> [1] 3