SpatialQuery.spatial_query.find_patterns_rand
- spatial_query.find_patterns_rand(max_dist=20, n_points=1000, min_support=0.5, min_size=0, if_display=True, figsize=(10, 5), return_cellID=False, seed=2023)[source]
Randomly generate points and use them to find surrounding patterns in spatial data.
- Parameters:
max_dist (float, default=20) – Maximum distance to consider a cell as a neighbor.
n_points (int, default=1000) – Number of random points to generate.
min_support (float, default=0.5) – Threshold of frequency to consider a pattern as a frequent pattern.
min_size (int, default=0) – Minimum neighborhood size for each random point to consider.
if_display (bool, default=True) – Display the random points with nearby frequent patterns if if_display=True.
figsize (tuple, default=(10, 5)) – Tuple of figure size for the display plot.
return_cellID (bool, default=False) – Indicate whether return cell IDs for each frequent pattern within the neighborhood of random points. By default do not return cell ID.
seed (int, default=2023) – Random seed for reproducibility.
- Returns:
- DataFrame with frequent pattern results. Columns include:
itemsets: frozenset of cell types in the frequent pattern
support: frequency of the pattern (proportion of random points with this pattern)
neighbor_id: set of cell indices belonging to the pattern (only if return_cellID=True)
- Return type:
pd.DataFrame