Newick and NEXUS Phylogenetic Formats

  • Newick and NEXUS are widely used file formats for representing, storing, and exchanging phylogenetic trees and related evolutionary data. Phylogenetic trees describe evolutionary relationships among organisms, genes, proteins, or other biological entities. They are essential in molecular evolution, comparative genomics, taxonomy, population genetics, epidemiology, and evolutionary biology. Newick provides a compact representation of tree topology and branch lengths, whereas NEXUS offers a more comprehensive framework for storing phylogenetic trees together with sequence data, character matrices, taxonomic information, and analysis settings.
  • The Newick format, also known as the New Hampshire format, represents a phylogenetic tree using a nested system of parentheses, commas, labels, colons, and semicolons. Its structure reflects the branching relationships among taxa. Parentheses group descendants that share a common ancestral node, commas separate branches, and labels identify terminal taxa or internal nodes. A colon introduces a bStockholm and other multiple-alignment formatsranch length, which commonly represents an estimated amount of evolutionary change or another measure of distance along a branch. A semicolon marks the end of a tree description.
  • A simple Newick tree may look like this:

((Human,Chimpanzee),Gorilla);

  • In this example, Human and Chimpanzee are represented as more closely related to each other than either is to Gorilla. The parentheses indicate that Human and Chimpanzee share a more recent common ancestral node, while Gorilla branches from an earlier node. The tree describes relationships through its topology rather than specifying the exact historical sequence of evolutionary events.
  • Newick files can also include branch lengths. For example:

((Human:0.02,Chimpanzee:0.02):0.03,Gorilla:0.05);

  • The values following the colons represent branch lengths. Depending on the analysis, they may represent genetic distances, expected substitutions per site, or another measure of evolutionary change. These values are not necessarily equivalent to chronological time. Their interpretation depends on the evolutionary model, data, and method used to estimate the tree. If a molecular clock or calibrated time-tree analysis has been performed, branch lengths may instead be expressed in units related to time.
  • Newick also supports labels for internal nodes, which may represent ancestral groups or statistical support values. For example:

((Human,Chimpanzee)95,Gorilla);

  • Here, 95 is an internal-node label that might represent a bootstrap support value. However, Newick itself does not define the statistical meaning of such labels. Different software packages may interpret internal labels as support values, ancestral names, or other annotations. Researchers should therefore document how these values were generated and interpreted.
  • A more complete Newick example containing branch lengths and internal-node labels is:

((Human:0.02,Chimpanzee:0.02)95:0.03,Gorilla:0.05)100;

  • In this representation, Human and Chimpanzee form a group with a branch length of 0.03 connecting their common node to the next ancestral node. The value 95 is an internal-node label that may represent support for the Human–Chimpanzee grouping, while 100 labels the root node. The exact meaning of these labels depends on the conventions used by the program that generated the file.
  • Newick is compact and widely supported, but it has limitations. It generally represents a single tree at a time and does not provide a standardized framework for storing the original sequence alignment, character data, analysis parameters, or detailed metadata. It also has limited support for complex annotations, uncertainty, and relationships that cannot be represented as a simple bifurcating tree. Extended Newick conventions and related formats can represent some additional information, such as hybridization or reticulate evolutionary relationships, but their syntax and compatibility vary among applications.
  • The NEXUS format was developed to provide a more comprehensive way of storing phylogenetic and evolutionary datasets. A NEXUS file can contain multiple types of information in one document, including DNA or protein sequence alignments, morphological character matrices, taxon names, phylogenetic trees, and analysis-related settings. It is organized into logical sections called blocks. Each block begins with a BEGIN statement and ends with an END or ENDBLOCK statement. The file usually begins with the #NEXUS declaration, which identifies it as a NEXUS document.
  • A simplified NEXUS file may look like this:

#NEXUS

BEGIN TAXA;

    DIMENSIONS NTAX=3;

    TAXLABELS Human Chimpanzee Gorilla;

END;

BEGIN TREES;

    TREE example_tree = ((Human,Chimpanzee),Gorilla);

END;

  • The TAXA block defines the taxa included in the dataset, while the TREES block stores one or more phylogenetic trees. The TREE statement introduces a tree, and the expression following the equals sign uses Newick-like tree notation. The NEXUS format therefore allows phylogenetic tree descriptions to be incorporated into a larger structured dataset.
  • One of the important advantages of NEXUS is that it can store sequence alignments and other character data alongside phylogenetic trees. The DATA or CHARACTERS block can describe the number of taxa, the number of characters, the datatype, and the character matrix. For example:

#NEXUS

BEGIN DATA;

    DIMENSIONS NTAX=3 NCHAR=6;

    FORMAT DATATYPE=DNA MISSING=? GAP=-;

    MATRIX

    Human       ATGCTA

    Chimpanzee  ATGCTA

    Gorilla     ATGCCA

    ;

END;

BEGIN TREES;

    TREE example_tree = ((Human,Chimpanzee),Gorilla);

END;

  • In this example, the DATA block contains a DNA alignment with three taxa and six nucleotide positions. The FORMAT statement identifies the data type and defines symbols for missing data and alignment gaps. The MATRIX section contains the aligned sequences. The TREES block stores the associated phylogenetic tree. This organization makes NEXUS useful for workflows in which researchers need to preserve the connection between sequence data and the evolutionary tree inferred from those data.
  • NEXUS supports several additional blocks for describing and organizing evolutionary information. The TAXA block defines the taxa included in a dataset, while CHARACTERS stores discrete or continuous character information. The DATA block combines taxon and character information in a matrix. The TREES block stores phylogenetic trees, and the SETS block can define groups of taxa, characters, or other data subsets. The ASSUMPTIONS block can describe assumptions about character treatment, such as character ordering or weighting. Other blocks, including NOTES, CODONS, and application-specific blocks, may store additional information. The exact blocks supported depend on the NEXUS specification and the software implementing it.
  • NEXUS can also contain multiple trees, which is useful when comparing alternative evolutionary hypotheses or preserving trees generated during different stages of an analysis. For example:

#NEXUS

BEGIN TAXA;

    DIMENSIONS NTAX=4;

    TAXLABELS Human Chimpanzee Gorilla Orangutan;

END;

BEGIN TREES;

    TREE tree_1 = ((Human,Chimpanzee),(Gorilla,Orangutan));

    TREE tree_2 = ((Human,Gorilla),(Chimpanzee,Orangutan));

END;

  • The file contains two alternative tree topologies. Researchers can use such representations to compare evolutionary relationships, examine competing hypotheses, or store selected trees from a phylogenetic analysis. NEXUS can also represent a designated default or reference tree using additional tree-related statements supported by the relevant software.
  • Newick and NEXUS are closely related in their use of parenthetical tree notation, but they serve different purposes. Newick is primarily a compact tree representation, making it convenient for transferring phylogenetic trees between programs. NEXUS is a more comprehensive data container that can combine trees with sequence alignments, morphological characters, taxon definitions, and other information. A NEXUS tree statement commonly contains a Newick-like expression, allowing the two formats to be used together in many phylogenetic workflows.
  • Newick files commonly use extensions such as .nwk, .newick, or .tree, although extensions are not completely standardized. NEXUS files commonly use .nex or .nexus. Both are text-based formats and can be inspected with ordinary text editors. However, researchers should not assume that every file using a particular extension follows exactly the same conventions. Software packages may support different subsets of the formats or use additional annotations.
  • Several bioinformatics tools can read, write, analyse, and convert Newick and NEXUS files. Biopython provides the Bio.Phylo module for phylogenetic tree processing. It can read Newick and NEXUS files, inspect tree structures, calculate branch-related information, and write trees to supported formats. The following Python example reads a Newick tree and displays its terminal taxa:

from Bio import Phylo

# Read a Newick tree

tree = Phylo.read(“tree.nwk”, “newick”)

# Display the tree

Phylo.draw_ascii(tree)

# Print terminal taxa

for terminal in tree.get_terminals():

    print(terminal.name)

Biopython can also read a NEXUS file containing a phylogenetic tree:

from Bio import Phylo

# Read a tree from a NEXUS file

tree = Phylo.read(“analysis.nex”, “nexus”)

# Display the tree

Phylo.draw_ascii(tree)

# Print the number of terminal taxa

  • print(“Number of taxa:”, len(tree.get_terminals()))
  • For workflows involving multiple trees, the Phylo.parse function can be used to iterate through the trees in a file:

from Bio import Phylo

# Read multiple trees from a NEXUS file

trees = Phylo.parse(“multiple_trees.nex”, “nexus”)

for index, tree in enumerate(trees, start=1):

    print(“Tree:”, index)

    print(“Number of taxa:”, len(tree.get_terminals()))

  • The R programming language also provides extensive support for phylogenetic formats. The ape package is widely used for reading, manipulating, analysing, and visualizing phylogenetic trees. Its read.tree() function reads Newick files, while read.nexus() reads NEXUS files. The following example demonstrates basic tree retrieval and visualization:

library(ape)

# Read a Newick tree

tree <- read.tree(“tree.nwk”)

# Display the tree

plot(tree)

# Display terminal taxa

print(tree$tip.label)

A NEXUS tree can be read using:

library(ape)

# Read a NEXUS file

tree <- read.nexus(“analysis.nex”)

# Display the phylogenetic tree

plot(tree)

# Print taxon labels

print(tree$tip.label)

  • Other useful tools include DendroPy, which provides Python-based phylogenetic data structures and tree-processing functions; IQ-TREE, which performs maximum-likelihood phylogenetic inference and supports common tree formats; RAxML and related phylogenetic software; MrBayes, which performs Bayesian phylogenetic inference and uses NEXUS-based input conventions; and FigTree, which is used to visualize and inspect phylogenetic trees. Tree viewers and analysis tools may interpret support values, branch lengths, rooting, and annotations differently, so users should check the documentation of each application.
  • Newick and NEXUS files are used in a wide range of evolutionary and comparative analyses. In molecular phylogenetics, they store trees inferred from DNA, RNA, or protein sequence alignments. In species evolution, they represent relationships among organisms and help investigate diversification, speciation, and common ancestry. In comparative genomics, gene trees can be used to study gene duplication, gene loss, orthology, and paralogy. In epidemiology, phylogenetic trees can help investigate pathogen evolution and transmission patterns, provided that sampling design and other epidemiological evidence are considered. In population genetics, trees can represent relationships among sampled sequences or inferred ancestral lineages.
  • These formats are also important in phylogenetic methods such as maximum likelihood, Bayesian inference, distance-based reconstruction, and maximum parsimony. They allow researchers to store inferred trees, compare alternative topologies, and exchange results between programs. NEXUS is especially useful when the analysis involves both molecular sequence data and morphological or other character information. Newick is particularly convenient when only the resulting tree needs to be transferred or visualized.
  • Correct interpretation of phylogenetic files requires attention to several important details. A tree may be rooted or unrooted, and the root determines how evolutionary direction and ancestry are interpreted. Newick notation does not always make rooting status explicit in a universally consistent way, so researchers should check the conventions used by the generating software. Branch lengths must also be interpreted carefully because they may represent genetic distance, expected substitutions per site, chronological time, or another quantity. A tree without branch lengths may describe only topology.
  • Taxon labels must be consistent across sequence alignments, metadata, and tree files. Differences in spelling, spaces, punctuation, capitalization, or identifiers can prevent software from matching taxa correctly. Some programs use underscores in place of spaces, while others preserve labels or apply their own quoting conventions. Researchers should also check whether internal-node labels represent bootstrap values, posterior probabilities, ancestral names, or other information. These values are not interchangeable and should be interpreted according to the analysis method.
  • Phylogenetic files may also contain unresolved nodes, polytomies, duplicate taxa, missing branch lengths, or alternative tree representations. A polytomy indicates that a node has more than two descendant branches; it may represent an unresolved evolutionary relationship or a genuine multifurcation under the assumptions of a particular analysis. Some programs automatically resolve or modify such structures, potentially changing the interpretation of the original tree. Therefore, files should be validated before conversion or downstream analysis.
  • For reproducible phylogenetic research, it is important to preserve the original input alignment, the resulting tree, taxon definitions, analysis settings, evolutionary model, software name and version, and relevant support statistics. Researchers should document whether the tree was rooted, how branch lengths were estimated, and how internal-node labels were generated. When converting between Newick and NEXUS, they should check that taxon labels, branch lengths, rooting information, internal-node annotations, and multiple-tree content have been retained. Not all metadata can be represented in both formats, and some conversions may discard information.
  • Newick and NEXUS remain fundamental formats in phylogenetic bioinformatics. Newick offers a compact and widely compatible way to represent evolutionary tree structures, while NEXUS provides a flexible framework for storing trees together with sequence and character data. Understanding their syntax, organization, conventions, limitations, and software support enables researchers to exchange phylogenetic information accurately and conduct reproducible evolutionary analyses.
Author:

Leave a Reply

Your email address will not be published. Required fields are marked *