Skip to content

Extracting Clades

This script demonstrates how the getNodeByLabel, getMRCA, and getClade methods on the Tree class can be wrapped in a function to find and extract clades relating a subset of tips.

The particular function here takes a Newick string and list of desired taxa. We use TypeScript here as this would likely be part of a larger application needing type safety. Just remove type annotations and change the compiler in codepen to run it in JavaScript.

See the Pen extract-subtree by Leo Featherstone (@LeoFeatherstone) on CodePen.