swnn.adaptive_tree¶
- swnn.adaptive_tree(adj_max, group_lbs, stage_lbs=None, stage_ord=None, ignore_pa=(), ext_sep='_')¶
Adaptatively build the developmental tree from the stagewise-KNN graph.
- Parameters
adj_max (
spmatrix
) – sparse.csc_matrix, shape = (n_points, n_points) adjacent matrix of single points (cells)group_lbs (
Sequence
) – np.array, shape = (n_points,) group labels specifying each cluster in each stage. e.g. ‘stage1_1’ specifies the cluster 1 in stage1.stage_lbs (
Optional
[Sequence
]) – np.array, shape = (n_points,) stage labels, better be explicitly assigned. If None, this will be extracted from group_lbs, and may cause unexpected results.stage_ord (
Optional
[Sequence
]) – np.array, shape = (n_stages,) order of stages, better provided by user; if None, it will be decided automatically.ignore_pa (list or set) – parent nodes to be ignored; empty tuple by default.
ext_sep (str) – parse string for automatically extract the stage-labels from group_lbs
- Returns
edgedf (pd.DataFrame) – a DataFrame with each row representing an edge, columns are [‘node’, ‘parent’, ‘prop’], where ‘prop’ is the proportion of nodes that have voted for the current parent.
group_lbs – refined group-labels for each sample (e.g. single-cell)
Examples
>>> edgedf, group_lbs = adaptive_tree(adj_max, group_lbs, stage_ord=stages)