R/average_percentage_of_cells_within_radius.R
average_percentage_of_cells_within_radius.Rd
Calculates the average percentage of cells of a target cell type within a radius from the cells with a reference cell type. The calculation is done per reference cell, so runtime will depend on the number of reference cells present. Output is a single value (the mean for the image).
average_percentage_of_cells_within_radius(
spe_object,
reference_celltype,
target_celltype,
radius = 100,
feature_colname
)
SpatialExperiment object in the form of the output of
format_image_to_spe
.
String specifying the cell type of reference cells.
String specifying the cell type for target cells
Integer specifying the radius of search for cells around the reference cells. Radii of ~100 are recommended. If too small, too few cells might be present.
String specifying the column with the desired cell type annotations.
A numeric vector and a plot are returned
average_percentage_of_cells_within_radius(SPIAT::defined_image, "Tumour",
"Immune3", radius = 100, "Cell.Type")
#> [1] 17.45713