Remove nodes from a Newick tree based on labels or patterns.
Input:
- A Newick tree file.
Notes:
- Target nodes can be specified by
--node,--name-list, or--regex. - With
-D/--descendants, all descendants of selected internal nodes are also included in the pruning set. - With
--invert, specified nodes (along with their ancestors and descendants) are kept, and everything else is removed. - Topology changes:
- If a node removal leaves its parent with only one child, the parent is collapsed.
- Internal nodes that lose all children are also removed.
Examples:
-
Remove specific nodes by name
necom nwk prune input.nwk -n Homo -n Pan -
Remove nodes using a list in a file
necom nwk prune input.nwk -l remove.txt -
Keep a clade and remove everything else (invert mode)
necom nwk prune input.nwk -i -n Hominidae