reconstruct_tree
Reconstruct a lineage tree from a dataset's character matrix using methods such as greedy, neighbor-joining, or UPGMA to infer cell relationships.
Instructions
Reconstruct a lineage tree from a dataset's character matrix.
The tree is written into tdata.obst[key_added] as a rooted networkx DiGraph.
Methods:
"greedy": Cassiopeia-Greedy (fast, top-down; good default).
"nj": Neighbor-Joining (distance-based).
"upgma": UPGMA (distance-based, ultrametric).
"ilp": Steiner-tree ILP (exact; requires Gurobi; small trees only).
"hybrid": greedy top + ILP bottom (requires Gurobi).
Args: dataset_id: Dataset handle (must contain a character matrix in obsm). method: One of greedy, nj, upgma, ilp, hybrid. key_added: obst key for the new tree (defaults to the method name). characters_key: obsm key holding the character matrix. priors: Whether to use mutation priors from uns["priors"] if present. extra_options: Advanced solver kwargs passed through (e.g. {"root": "midpoint"} for nj, {"top_solver": "greedy"} for hybrid).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | No | greedy | |
| priors | No | ||
| key_added | No | ||
| dataset_id | Yes | ||
| extra_options | No | ||
| characters_key | No | characters |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| method | Yes | ||
| message | No | ||
| n_leaves | Yes | ||
| tree_key | Yes | Key under tdata.obst holding the new tree. | |
| parsimony | No | Total parsimony score, if computable. | |
| dataset_id | Yes | ||
| n_internal_nodes | Yes |