maxfuse.spatial_utils.get_neighborhood_composition

maxfuse.spatial_utils.get_neighborhood_composition(knn_indices, labels, log1p=False)[source]

Compute the composition of neighbors for each sample.

Parameters:
  • knn_indices (np.ndarray of shape (n_samples, n_neighbors)) – Each row represents the knn of that sample

  • labels (np.ndarray of shape (n_samples, )) – Cluster labels

  • log1p (bool, default=False) – Whether to apply log1p transformation

Returns:

comp (np.ndarray of shape (n_samples, n_neighbors)) – The composition (in proportion) of neighbors for each sample.