Calculates the number of cells of a target cell type within a pre-defined radius around cells of a reference cell type.

number_of_cells_within_radius(
  spe_object,
  reference_celltype,
  target_celltype,
  radius = 20,
  feature_colname
)

Arguments

spe_object

SpatialExperiment object in the form of the output of format_image_to_spe.

reference_celltype

String. Cell type to be used for reference cells.

target_celltype

String. Cell type to be used for target cells.

radius

Numeric. Radius around the reference cells.

feature_colname

String specifying the column with the desired cell type annotations.

Value

A list of dataframes with the number of target cells of each of the reference cells

Examples

n_in_radius <- number_of_cells_within_radius(SPIAT::defined_image,
reference_celltype = "Tumour", target_celltype="Immune1", radius = 50,
feature_colname = "Cell.Type")