Skip to contents

Calculate the the average nearest neighbor (ANN) index of a specified type of cells. The index indicates the clustering effect of a point pattern. The pattern can be clustering, random or dispersion.

Usage

average_nearest_neighbor_index(
  sce_object,
  reference_cell,
  feature_colname,
  p_val = 5e-06
)

Arguments

sce_object

SingleCellExperiment object in the form of the output of format_image_to_sce.

reference_cell

String. Cells of this type are used as reference cells.

feature_colname

String. Specify the selected column for `reference_cell`.

p_val

Numeric. The p value threshold to determine the significance of a pattern.

Value

A list with the pattern type and a p value

Details

ANN index is a statistical test to test for the presence of clusters of cells, (Clark and Evans, 1954). The ANN index evaluates the spatial aggregation or dispersion effect of objects based on the average distances between pairs of the nearest objects and can be used to test for the clustering of specific cell types (e.g. immune or tumor cells). Next, the z score and p-value of the ANN index is calculated to validate the significance of the pattern.

Examples

average_nearest_neighbor_index(SPIAT::defined_image, "Tumour", "Cell.Type")
#> $pattern
#> [1] "Clustered"
#> 
#> $`p-value`
#> [1] 7.11006e-32
#>