Newick format

{{Short description|Notation for tree data structures}}

{{Redirect|Nwk||NWK (disambiguation){{!}}NWK}}

{{Infobox file format

| name = Newick format

| icon =

| iconcaption =

| screenshot =

| caption =

|_noextcode = on

| extensions = {{code|.tree}}

|_nomimecode = on

| mime = text/x-nh

| type_code =

| uniform_type =

| conforms_to =

| magic =

| developer =

| released = {{start date and age|df=yes|paren=yes|1986|06|24}}

| latest_release_version =

| latest_release_date =

| genre = graph-theoretical trees

| container_for =

| contained_by =

| extended_from =

| extended_to =

| standard =

| open = Yes

| url =

}}

In mathematics and phylogenetics, Newick tree format (or Newick notation or New Hampshire tree format) is a way of representing graph-theoretical trees with edge lengths using parentheses and commas. It was adopted by James Archie, William H. E. Day, Joseph Felsenstein, Wayne Maddison, Christopher Meacham, F. James Rohlf, and David Swofford, at two meetings in 1986, the second of which was at Newick's restaurant[https://www.newicks.com/ Newick's Lobster House home page] in Dover, New Hampshire, US. The adopted format is a generalization of the format developed by Meacham in 1984 for the first tree-drawing programs in Felsenstein's PHYLIP package.{{cite web|url=https://phylipweb.github.io/phylip/newicktree.html|title=The Newick tree format}}

Examples

The following tree:

Image:NewickExample.svg

could be represented in Newick format in several ways

({{Not a typo|,,}}(,)); no nodes are named

(A,B,(C,D)); leaf nodes are named

(A,B,(C,D)E)F; all nodes are named

(:0.1,:0.2,(:0.3,:0.4):0.5); all but root node have a distance to parent

(:0.1,:0.2,(:0.3,:0.4):0.5):0.0; all have a distance to parent

(A:0.1,B:0.2,(C:0.3,D:0.4):0.5); distances and leaf names (popular)

(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F; distances and all names

((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A; a tree rooted on a leaf node (rare)

Newick format is typically used for tools like PHYLIP and is a minimal definition for a phylogenetic tree.

Rooted, unrooted, and binary trees

When an unrooted tree is represented in Newick notation, an arbitrary node is chosen as its root. Whether rooted or unrooted, typically a tree's representation is rooted on an internal node and it is rare (but legal) to root a tree on a leaf node.

A rooted binary tree that is rooted on an internal node has exactly two immediate descendant nodes for each internal node.

An unrooted binary tree that is rooted on an arbitrary internal node has exactly three immediate descendant nodes for the root node, and each other internal node has exactly two immediate descendant nodes.

A binary tree rooted from a leaf has at most one immediate descendant node for the root node, and each internal node has exactly two immediate descendant nodes.

Grammar

A grammar for parsing the Newick format (roughly based on {{cite web |last1=Olsen |first1=Gary |date=30 August 1990 |title=Interpretation of "Newick's 8:45" Tree Format |url=https://phylipweb.github.io/phylip/newick_doc.html}}):

= The grammar nodes =

Tree: The full input Newick Format for a single tree

Subtree: an internal node (and its descendants) or a leaf node

Leaf: a node with no descendants

Internal: a node and its one or more descendants

BranchSet: a set of one or more Branches

Branch: a tree edge and its descendant subtree.

Name: the name of a node

Length: the length of a tree edge.

= The grammar rules =

Note, "|" separates alternatives.

TreeSubtree ";"

SubtreeLeaf | Internal

LeafName

Internal → "(" BranchSet ")" Name

BranchSetBranch | Branch "," BranchSet

BranchSubtree Length

Nameempty | string

Lengthempty | ":" number

Whitespace (spaces, tabs, carriage returns, and linefeeds) within number is prohibited. Whitespace within string is often prohibited. Whitespace elsewhere is ignored. Sometimes the Name string must be of a specified fixed length; otherwise the punctuation characters from the grammar (semicolon, parentheses, comma, and colon) are prohibited. The TreeSubtree ";" production is instead the TreeBranch ";" production in those cases where having the entire tree descended from nowhere is permitted; this captures the replaced production as well because Length can be empty.

Note that when a tree having more than one leaf is rooted from one of its leaves, a representation that is rarely seen in practice, the root leaf is characterized as an Internal node by the above grammar. Generally, a root node labeled as Internal should be construed as actually internal if and only if it has at least two Branches in its BranchSet. One can make a grammar that formalizes this distinction by replacing the above Tree production rule with

TreeRootLeaf ";" | RootInternal ";"

RootLeafName | "(" Branch ")" Name

RootInternal → "(" Branch "," BranchSet ")" Name

The first RootLeaf production is for a tree with exactly one leaf. The second RootLeaf production is for rooting a tree from one of its two or more leaves.

= Notes =

  • An unquoted {{mono|string}} may not contain blanks, parentheses, square brackets, single_quotes, colons, semicolons, or commas. Underscore characters in unquoted {{mono|string}}s are converted to blanks.
  • A {{mono|string}} may also be quoted by enclosing it in single quotes. Single quotes in the original string are represented as two consecutive single quote characters.
  • Whitespace may appear anywhere except within an unquoted {{mono|string}} or a {{mono|Length}}
  • Newlines may appear anywhere except within a {{mono|string}} or a {{mono|Length}}.
  • Comments are enclosed in square brackets. They can appear anywhere newlines are allowed. Comments starting with {{code|&}} are generally computer-generated for additional data. Some dialects allow nested comments.

Dialects

= New Hampshire X format =

The New Hampshire X (NHX) format is an extension to Newick that adds key-value data (gene duplication, etc.) to Newick nodes. This is done by putting the additional data in square brackets [&&NHX:key=value:...] in the node labels. The brackets are used because they represent comments in the Nexus file format, so any parser not understanding these additional information will ignore them.{{cite web |last1=Zmasek |first1=Christian M. |title=The New Hampshire X Format (NHX) |url=https://www.cs.mcgill.ca/~birch/birchhomedir/doc/atv/NHX.pdf |date=1999}}

= Extended Newick =

While the standard Newick notation is limited to phylogenetic trees, Extended Newick (Perl Bio::PhyloNetwork) can be used to encode explicit phylogenetic networks.{{Cite journal|last1=Cardona|first1=Gabriel|last2=Rosselló|first2=Francesc|last3=Valiente|first3=Gabriel|date=2008-03-27|title=A perl package and an alignment tool for phylogenetic networks|journal=BMC Bioinformatics|volume=9|pages=175|doi=10.1186/1471-2105-9-175|issn=1471-2105|pmc=2330044|pmid=18371228 |doi-access=free }} In a phylogenetic network, which is a generalization of a phylogenetic tree, a node either represents a divergence event (cladogenesis) or a reticulation event such as hybridization, introgression, horizontal (lateral) gene transfer or recombination. Nodes that represent a reticulation event are duplicated, annotated by introducing the # symbol into the Newick format, and numbered consecutively (using integer values starting with 1).

For example, if leaf Y is the product of hybridisation (x) between lineages leading to C and D in the tree above,

:File:ExtendedNewickExample.png

{{Image frame|content=

{{clade|newick1=(A,B,((C,Y)c,D)e)f}}

{{clade|newick1=(A,B,(C,(Y,D)d)e)f}}

|caption=Two trees in standard Newick|link=|align=|pos=|mode=|max-width=|dir=}}

one can express this situation by defining two trees in standard Newick notation

(A,B,((C,Y)c,D)e)f; and (A,B,(C,(Y,D)d)e)f; standard Newick, all nodes are named (internal nodes lowercase, leaves upper case)

or in extended Newick notation

(A,B,((C,(Y)x#H1)c,(x#H1,D)d)e)f; extended Newick, all nodes are named; 1 is the integer identifying the hybrid node x

The {{code|x#H1}} here is a hybrid node. It will be joined by the program into a single node when drawn.

This is the picture drawn by Dendroscope for this example:

:File:Dendroscope-network.png

The production rules above is modified by the following for labelling hybrid nodes (in general, nodes representing reticulation events):{{Cite journal|last1=Cardona|first1=Gabriel|last2=Rosselló|first2=Francesc|last3=Valiente|first3=Gabriel|date=2008|title=Extended Newick: it is time for a standard representation of phylogenetic networks|journal=BMC Bioinformatics|language=en|volume=9|pages=532|doi=10.1186/1471-2105-9-532|pmc=2621367|pmid=19077301|ref={{harvid|Cardona et al.|2008}} |doi-access=free }}

LeafName Hybrid

Hybridempty | "#" Type integer -- The #i part is an obligatory identifier for a hybrid node

Typeempty | string -- type of reticulation, e.g., H = hybridisation, LGT = lateral gene transfer, R = recombination.

In the visualization of LGT events, for a given reticulate node, one incoming edge is usually drawn as an "acceptor" edge and all other incoming edges are drawn as "transfer" edges. Some programs (e.g. Dendroscope and SplitsTree) allow exactly one copy of the reticulate node to be labeled with {{code|##}} to indicate that it corresponds to the acceptor edge.

Extended Newick is backward-compatible: a hybrid node would simply be interpreted as a few strangely-named nodes for legacy parsers.

= Rich Newick format =

The Rich Newick format, also known as the Rice Newick format, is a further extension of Extended Newick.{{cite web |last1=Barnett |first1=Robert Matthew |title=Rich Newick Format |url=https://wiki.rice.edu/confluence/display/PHYLONET/Rich+Newick+Format |website=Rice University Wiki |date=16 February 2012}} It adds support for:

  • Unrooted phylogenies. This is simply done by writing an unrooted tree as usual (i.e., pick an arbitrary root at a binary branch point) and prefixing {{code|[&U]}} to the string. {{code|[&R]}}, on the other hand, can be used to force a rooted tree.
  • Bootstrap values and probabilities. This is done by adding additional {{code|:[bootstrap]:[prob]}} fields after the length; fields can be left empty as long as the colons are present. This may be backward-incompatible.

= Ad hoc extensions =

Some other programs, like NWX, uses comments starting with {{code|&}} to encode additional information in an ad hoc manner:{{cite web |last1=Yu|first1=Guangchuang |title=Chapter 1 Importing Tree with Data |website=Data Integration, Manipulation and Visualization of Phylogenetic Tree |url=https://yulab-smu.github.io/treedata-book/chapter1.html}}

  • MrBayes and BEAST add additional information like probability, length in years, standard deviation for values to the nodes. They also use {{code|[%U]}}.

Visualization

{{Main|List of phylogenetic tree visualization software}}

Many tools have been published to visualize Newick tree data. Specific examples include the ETE toolkit ("Environment for Tree Exploration"){{Cite journal|last1=Huerta-Cepas|first1=Jaime|last2=Serra|first2=François|last3=Bork|first3=Peer|date= June 2016 |title=ETE 3: Reconstruction, Analysis, and Visualization of Phylogenomic Data|journal=Molecular Biology and Evolution|language=en|volume=33|issue=6|pages=1635–1638|doi=10.1093/molbev/msw046|issn=0737-4038|pmc=4868116|pmid=26921390}} and T-REX.{{Cite journal|last1=Boc|first1=Alix|last2=Diallo|first2=Alpha Boubacar|last3=Makarenkov|first3=Vladimir | date = July 2012 |title=T-REX: a web server for inferring, validating and visualizing phylogenetic trees and networks|journal=Nucleic Acids Research|volume=40|issue=Web Server issue|pages=W573–579|doi=10.1093/nar/gks485|issn=1362-4962|pmc=3394261|pmid=22675075}} Phylogenetic software packages such as SplitsTree and the tree-viewer Dendroscope as well as the online tree viewing tool IcyTree can handle standard and extended Newick notation, while the phylogenetic network software PhyloNet makes use of both the Extended Newick and Rich Newick format.

See also

References

{{reflist}}