Newick representation:
(((A,B),(C,D)),E)Root;
:0.002321
[comment]
&&NHX
, followed by :key=value
pairsGN
- a text string, used for gene namesAC
- a text name, for sequence accession numbersB
- a decimal number, for branch support values (e.g. bootstrap)T
- taxon identifier, a numberS
- species name, a text stringD
- flag to indicate whether node is a gene duplication (T), a speciation (F), or
unknown (?)Example:
(
(
( A[&&NHX:S=Homo sapiens], B[&&NHX:S=Homo sapiens] )[&&NHX:D=T],
( C[&&NHX:S=Pan paniscus], D[&&NHX:S=Pan troglodytes] )[&&NHX:D=F],
) , E
);
The technique to ‘overload’ comments in square brackets to embed data is also used in other contexts, such as:
<?xml version="1.0" encoding="UTF-8"?>
<phyloxml xmlns="http://www.phyloxml.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.phyloxml.org http://www.phyloxml.org/1.10/phyloxml.xsd">
<phylogeny rooted="true">
<clade>
<clade>
<clade>
<events><duplications>1</duplications></events>
<clade>
<name>A</name>
<taxonomy><scientific_name>Homo sapiens</scientific_name></taxonomy>
</clade>
<clade>
<name>B</name>
<taxonomy><scientific_name>Homo sapiens</scientific_name></taxonomy>
</clade>
</clade>
<clade>
<events><speciations>1</speciations></events>
<clade>
<name>C</name>
<taxonomy><scientific_name>Pan paniscus</scientific_name></taxonomy>
</clade>
<clade>
<name>D</name>
<taxonomy><scientific_name>Pan troglodytes</scientific_name></taxonomy>
</clade>
</clade>
</clade>
<clade>
<name>E</name>
</clade>
</clade>
</phylogeny>
</phyloxml>
Nexus representation:
#NEXUS
begin taxa;
dimensions ntax=5;
taxlabels
A
B
C
D
E
;
end;
begin trees;
translate
1 A,
2 B,
3 C,
4 D,
5 E;
tree t1 = (((1,2),(3,4)),5);
end;
#!/usr/bin/perl
use Bio::Phylo::IO qw'parse';
print parse(
-format => 'nexus',
-file => 'tree.nex',
-as_project => 1,
)->to_xml;
This workflow was scripted using make for parallelization.
// load the external data
d3.csv("Arachnida.csv", function(error, data) {
// create a name: node map
var dataMap = data.reduce(function(map, node) {
map[node.name] = node;
return map;
}, {});
// populate the tree structure
var root;
data.forEach(function(node) {
var parent = dataMap[node.parent];
if ( parent ) {
( parent.children || ( parent.children = [] ) ).push(node);
}
else {
root = node;
}
});
});