bento.tl.fluxmap

bento.tl.fluxmap(sdata, points_key='transcripts', instance_key='cell_boundaries', n_clusters=range(2, 9), num_iterations=1000, min_count=50, train_size=1, res=1, random_state=11, plot_error=False)

Cluster flux embeddings using self-organizing maps (SOMs) and vectorize clusters as Polygon shapes.

Parameters:
  • sdata (SpatialData) – SpatialData object.

  • points_key (str, default “transcripts”) – Key for points element that holds transcript coordinates.

  • instance_key (str, default “cell_boundaries”) – Key for cell_boundaries instances.

  • n_clusters (Union[Iterable[int], int], default range(2, 9)) – Number of clusters to use. If iterable, will pick best number of clusters using the elbow heuristic evaluated on the quantization error.

  • num_iterations (int, default 1000) – Number of iterations to use for SOM training.

  • min_count (int, default 50) – Minimum count for a point to be included in clustering.

  • train_size (float, default 1) – Fraction of cells to use for SOM training.

  • res (float, default 1) – Resolution used for rendering embedding.

  • random_state (int, default 11) – Random state to use for SOM training.

  • plot_error (bool, default False) – Whether to plot quantization error.

Returns:

Updated SpatialData object with: - .points[f”{instance_key}_raster”]: Added “fluxmap” column denoting cluster membership. - .shapes[“fluxmap#”]: Added “fluxmap#” columns for each cluster rendered as (Multi)Polygon shapes.

Return type:

SpatialData