CellScope.ts.generate_tree_structured

CellScope.ts. generate_tree_structured (fea, T, step0 = None, step1 = None, cell_type = None)

The generate_tree_structured function constructs a tree-like representation of cell clustering, identifying hierarchical relationships between clusters across different levels, and generates UMAP-based visualizations for each cluster.

Parameters

  • fea (np.ndarray):

    The feature matrix of shape (n_cells, n_genes).

  • T (np.ndarray):

    A matrix of clustering labels for different levels of clustering.

  • step0 (int, optional, default=None):

    The starting level for the tree-structured visualization. If None, it is automatically determined.

  • step1 (int, optional, default=None):

    The ending level for the tree-structured visualization. If None, it is determined based on the highest ARI score.

  • cell_type (np.ndarray, optional, default=None):

    A 1D array of cell type labels. Required if step1 is not provided.

Return

  • Y_initial (np.ndarray):

    The initial 2D UMAP embedding of all cells.

  • label_step0 (np.ndarray):

    Clustering labels at the starting level (step0).

  • Y_1 (list of np.ndarray):

    A list of UMAP embeddings for clusters at the first level.

  • Title_1 (list):

    A list of titles for the first-level clusters.

  • Y_all (list of np.ndarray):

    A list of UMAP embeddings for clusters at all levels.

  • Title_all (list):

    A list of titles for clusters at all levels.

  • index_1 (list):

    A list of indices corresponding to cells in each cluster at the first level.

  • index_all (list):

    A list of indices corresponding to cells in each cluster at all levels.

  • step0 (int):

    The final starting level for the tree-structured visualization.

  • step1 (int):

    The final ending level for the tree-structured visualization.