Compute x/y coordinates and edges for a taxonomic tree defined by
nodes (as returned by build_tree_nodes()).
Arguments
- nodes
A data frame with columns tsn, parentTsn,
taxon, level, and selected.
Value
A list with elements:
- nodes
The input nodes (possibly filtered) with rank_index/x.
- edges
A data frame of parent/child TSN pairs.
- coords
A data frame giving x/y coordinates for each TSN.
- leaf_tsns
The TSNs of selected taxa that act as leaves.
or NULL if a layout cannot be constructed.
Details
The layout:
maps taxonomic ranks to x positions via rank_levels
prunes ranks above the least common ancestor (LCA) of the
selected taxa
lays out leaves vertically in order of a DFS walk
positions internal nodes at the mean y of their children