mesa.multiomics.multiomics_spatial.get_global_neighborhood_composition

mesa.multiomics.multiomics_spatial.get_global_neighborhood_composition(knn_indices, labels, all_labels, percentage=True)

Compute the composition of neighbors for each sample. :type knn_indices: :param knn_indices: Each row represents the knn of that sample :type knn_indices: np.ndarray of shape (n_samples, n_neighbors) :type labels: :param labels: Cluster labels that appear in this particular region :type labels: np.ndarray of shape (n_samples, ) :type all_labels: :param all_labels: All unique cluster labels across the whole dataset :type all_labels: np.ndarray :type percentage: :param percentage: whether return cell-type percenrage or cell-type count :type percentage: bool, default=True

Returns:

comp – The composition (in proportion) of neighbors for each sample.

Return type:

np.ndarray of shape (n_samples, n_neighbors)