cluster_neighbourhoods#
- cluster_neighbourhoods(domains_to_analyse, label_name, populations_to_analyse=None, neighbourhood_source=None, include_boundaries=None, exclude_boundaries=None, boundary_exclude_distance=0, network_type='Delaunay', force_labels_to_include=[], labels_to_ignore=[], k_hops=3, max_edge_distance=inf, min_edge_distance=0, number_of_nearest_neighbours=10, neighbourhood_label_name='Neighbourhood ID', cluster_method='kmeans', cluster_parameters={'n_clusters': 8})#
A function to cluster neighbourhoods based on the enrichment of labels within the neighbourhoods of objects using a network connectivity.
- Parameters:
- domains_to_analyselist or object
A list of muspan domains or a single muspan domain to be analyzed.
- label_namestr
The name of the label to be used for clustering.
- populations_to_analysearray-like, query-like, or None, optional
Populations to be analyzed within the domains. If None, defaults to the neighbourhood_source.
- neighbourhood_sourcearray-like, query-like, or None, optional
Source of neighbourhoods within the domains. If None, defaults to populations_to_analyse.
- include_boundariesarray-like, query-like, or None, optional
Boundaries to include in the analysis. If None, no boundaries are included.
- exclude_boundariesarray-like, query-like, or None, optional
Boundaries to exclude from the analysis. If None, no boundaries are excluded.
- boundary_exclude_distancefloat, optional
Distance to exclude from the boundaries. Default is 0.
- network_typestr, optional
Type of network to generate. Default is ‘Delaunay’.
- force_labels_to_includelist, optional
Labels to forcefully include in the analysis. Default is an empty list.
- labels_to_ignorelist, optional
Labels to ignore in the analysis. Default is an empty list.
- k_hopsint, optional
Number of hops for neighbourhood calculation. Default is 3.
- max_edge_distancefloat, optional
Maximum edge distance for network generation. Default is np.inf.
- min_edge_distancefloat, optional
Minimum edge distance for network generation. Default is 0.
- number_of_nearest_neighboursint, optional
Number of nearest neighbours for network generation. Default is 10.
- neighbourhood_label_namestr, optional
Name for the neighbourhood label. Default is ‘Neighbourhood ID’.
- cluster_methodstr, optional
Clustering method to use. Default is ‘kmeans’.
- cluster_parametersdict, optional
Parameters for the clustering method. Default is {‘n_clusters’: 8}.
- Returns:
- neighbourhood_enrichment_matrixnumpy.ndarray
Matrix representing the enrichment of neighbourhoods.
- consistent_global_labelslist
List of consistent global labels across all domains.
- unique_cluster_labelsnumpy.ndarray
Array of unique cluster labels.