mesa.multiomics.multiomics_spatial.get_spatial_knn_indices

mesa.multiomics.multiomics_spatial.get_spatial_knn_indices(locations, n_neighbors=15, method='kd_tree')

Compute k-nearest neighbors of locations.

Parameters:
  • locations (np.ndarray of shape (n_samples, 2)) – Data matrix

  • n_neighbors (int) – Number of nearest neighbors

  • method (str, default='kd_tree') – Method to use when computing the nearest neighbors, one of [‘ball_tree’, ‘kd_tree’, ‘brute’]

Returns:

knn_indices – Each row represents the knn of that sample

Return type:

np.ndarray of shape (n_samples, n_neighbors)