SPADEResult#

class densitree.result.SPADEResult(labels_: ndarray, tree_: Graph, X_down: ndarray, down_idx: ndarray, n_features: int, feature_names: list[str] | None = None, _cluster_stats: DataFrame | None = None)[source]#

Bases: object

Rich output object from a SPADE run.

Parameters:
  • labels_ (ndarray[int], shape (n_cells,)) – Cluster assignment for every original cell.

  • tree_ (networkx.Graph) – MST connecting cluster centroids. Each node has size (int) and median (ndarray) attributes.

  • X_down (ndarray, shape (n_down, n_features)) – Downsampled cells used for clustering.

  • down_idx (ndarray[int], shape (n_down,)) – Indices into the original array for the downsampled cells.

  • n_features (int) – Number of features in the input data.

  • feature_names (list[str] or None) – Feature names. Auto-generated if None.

labels_: ndarray#
tree_: Graph#
X_down: ndarray#
down_idx: ndarray#
n_features: int#
feature_names: list[str] | None = None#
property cluster_stats_: DataFrame#
plot_tree(color_by: int | str | None = None, size_by: str = 'count', backend: str = 'matplotlib')[source]#

Visualize the SPADE tree.

Parameters:
  • color_by – Feature index (int) or name (str) to color nodes by median expression. None colors all nodes the same.

  • size_by'count' scales node size by cell count. Any other value uses uniform size.

  • backend'matplotlib' for static plots, 'plotly' for interactive.