A function to identify the neighbourhood of each cell. If sort = TRUE, the neighbourhoods are also sorted such that cells belonging to the same group as the central cell are arranged closer to it.
Arguments
- spe
SpatialExperiment object with logcounts, PCA, and 'putative cell type' groups included.
- samples
a character vector of sample names to which the cells belong. Length of vector must be equal to the number of cells in spatialExperiment object (i.e. the number of rows in colData(spe)).
- NN
an integer for the number of neighbourhood cells the function should consider. The value must be greater than or equal to 1. Default value is 30.
- cells
a character vector of cell IDs of each cell. Length of vector must be equal to the number of cells in SpatialExperiment object (i.e. the number of rows in colData(spe)).
- sort
a logical parameter for whether or not to sort the neighbourhood after region description. Default value is TRUE.
Value
a list containing two items:
1. nnCells, a character matrix of NN nearest neighbours - rows are cells and columns are their nearest neighbours ranged from closest to farthest neighbour. For sort = TRUE, the neighbours belonging to the same 'putative cell type' group as the cell are moved closer to it.
2. regXclust, a list of vectors for each cell's neighbourhood composition indicated by the proportion of 'putative cell type' groups it contains.