npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@euphrasiologist/lwphylo

v1.5.1

Published

A lightweight, low level javascript library to plot phylogenies from Newick files.

Downloads

1,228

Readme

lwPhylo

A lightweight, low level javascript library to plot phylogenies from a Newick file. It uses no dependencies on any other package, but is designed to be given to the D3 library for visualisation.

Website

Visit https://euphrasiologist.github.io/lwPhylo/ to see examples and live rendering of trees. Can even paste your own in.

Functionality

Newick trees can be parsed using the readTree() function. This object can then be wrapped in three main functions; rectangleLayout() to produce a "regular" phylogenetic tree, radialLayout() to produce a circular phylogeny, and unrooted() to produce an unrooted tree via the equal angle layout algorithm.

Need a tree to experiment with? randomTree(nTips, { maxBranchLength, labelPrefix, seed }) generates a random bifurcating tree in the same node shape as readTree(), ready to pass straight into any of the layout functions. toNewick(tree) serializes one of these parsed tree objects back to a Newick string.

ladderize(tree, { ascending }) and rotate(tree, nodeId) change tip order by reordering a node's children in place — ladderize sorts every clade by descendant tip count (smallest first by default), rotate flips the child order at one node (the root, if no id is given).

drawPhylogeny(input, options) accepts either a Newick string or an already-parsed tree object (from readTree()/randomTree()) as input. Passing the same parsed tree object back in across re-renders — e.g. after mutating it with rotate() — keeps node ids stable, which onNodeClick (below) relies on. Options, in addition to layout/width/height/tipLabels/labelFontSize/highlightTips:

  • tipRadius — px radius of tip circles.
  • internalNodeCircles (bool) + internalNodeRadius — draw a circle at every internal node.
  • nodeLabels (bool) + nodeLabelFontSize — draw text labels (e.g. clade/support values) at internal nodes that have one.
  • scaleBartrue for an auto-sized branch-length scale bar, a number for an explicit length in branch-length units, or { length, x, y, label } for full control.
  • alignTipLabels (bool, rect & radial layouts) — align tip labels to a common column/ring, with dashed guide lines back to each tip's true position.
  • onNodeClick(node, event) — fires when an internal node circle is clicked (requires internalNodeCircles: true).
  • container (DOM element or CSS selector) + rotateOnClick (bool) — the batteries-included version of click-to-rotate: with both set, drawPhylogeny mounts the SVG into container itself and, on every internal-node click, rotates that clade and redraws back into the same container — no manual render loop needed:
    drawPhylogeny(newickString, { layout: "rect", container: "#tree", rotateOnClick: true });
    rotateOnClick auto-enables internalNodeCircles unless you set it explicitly. A supplied onNodeClick still fires too, before the rotate. Without a container, rotateOnClick throws — there'd be nowhere to put the redrawn SVG. For finer control (e.g. wrapping the SVG in your own zoom/pan <g>, as the demo site does), skip container/rotateOnClick and drive it yourself with onNodeClick + rotate() as shown in the demo's own source.

Acknowledgements

Original implementation of tree layout schemes are found here: https://github.com/ArtPoon/ggfree.

Citation

Brown, M (2020). lwPhylo: A lightweight, low level javascript library to plot phylogenies from a Newick file, version 1.1.2