- spac.spatial_analysis._neighborhood_profile_core(coord, phenotypes, n_phenotypes, distances_bins, normalize=None)[source]
Calculate the neighborhood profile for every cell in a region.
- Parameters:
coord (numpy.ndarray) – The coordinates of the cells in the region. Should be a 2D array of shape (n_cells, 2) representing x, y coordinates.
phenotypes (numpy.ndarray) – The phenotypes of the cells in the region.
n_phenotypes (int) – The number of unique phenotypes in the region.
distances_bins (list) – The bins defining the distance ranges for the neighborhood profile.
normalize (str or None, optional) – If ‘total_cells’, normalize the neighborhood profile based on the total number of cells in each bin. If ‘bin_area’, normalize the neighborhood profile based on the area of every bin.
- Returns:
A 3D array containing the neighborhood profile for every cell in the region. The dimensions are (n_cells, n_phenotypes, n_intervals).
- Return type:
numpy.ndarray
Notes
The function calculates the neighborhood profile for each cell, which represents the distribution of neighboring cells’ phenotypes within different distance intervals.
The ‘distances_bins’ parameter should be a list defining the bins for the distance intervals. It is assumed that the bins are incremental, starting from 0.