Function Repository Resource:

NewickDendrogram

Source Notebook

Render a Newick tree as a dendrogram

Contributed by: John Cassel (Wolfram|Alpha Team)

ResourceFunction["NewickDendrogram"][newickTree]

displays a Newick tree as a Dendrogram.

ResourceFunction["NewickDendrogram"][newickString]

imports a Newick tree from a String and then displays it as a Dendrogram.

Details and Options

A dendrogram is a tree visualization useful for expressing clustering similarity.
The Newick tree is a popular format for representing a phylogenetic tree, which is a type of dendrogram.

Examples

Basic Examples (2) 

Display a Newick string as a dendrogram:

In[1]:=
ResourceFunction["NewickDendrogram"]["(a:8, (b:2, d:9):4, c:1)e:0"]
Out[1]=

Import a Newick tree using the resource function ImportNewickString and render the imported tree as a dendrogram:

In[2]:=
newickTree = ResourceFunction["ImportNewickString"][
   "(a:8, (b:2, d:9):4, c:1)e:0"];
ResourceFunction["NewickDendrogram"][newickTree]
Out[3]=

Scope (3) 

Trees of arbitrary depth are supported:

In[4]:=
ResourceFunction[
 "NewickDendrogram"]["(a:3, (d:18, (e:7, f:20)g:8, h:3), b:6)c:0"]
Out[4]=

If the Newick tree is not connected to a common ancestor node, multiple dendrograms are displayed:

In[5]:=
ResourceFunction[
 "NewickDendrogram"]["((a:3, b:2)node:0, (c:1, d:2)node2:1)"]
Out[5]=

Quite large trees can be rendered with legible substructure, at the cost of the resulting dendrogram being correspondingly large:

In[6]:=
ResourceFunction[
 "NewickDendrogram"]["(((('PDT000420560.1':0.0198508, ('PDT000133532.2':0.00971731, 'PDT000158341.2':0.00437849)NODE:0.0088589)NODE_000002:0.00329575, ((('PDT000034097.3':0.0146399, ('PDT000235705.2':0.00313825, 'PDT000247553.2':0.00294836)NODE_000003:0.00497259)NODE_000004:0.0138707, (('PDT000035464.1':0.0063772, 'PDT000035508.1':0.0064036)NODE_000005:0.00858051, ('PDT000579113.1':0.00421217, 'PDT000579112.1':0.00495026)NODE_000006:0.0159417)NODE_000007:0.00127682)NODE_000008:0.00392538, (('PDT000111577.2':0.000521048, 'PDT000201409.1':0.000878812)NODE_000009:0.00651095, ('PDT000050204.11':0.00943314, ('PDT000097379.2':0.0166698, ('PDT000050245.2':0.000985307, ('PDT000050242.2':0.000785888, (('PDT000050233.2':0.000614227, ('PDT000050226.2':0.000545162, ('PDT000295783.2':0.000237048, 'PDT000295779.2':0.000262852)NODE_000010:0.000254468)NODE_000011:0.00006744690000000001)NODE_000012:-0.0000259395, ('PDT000050195.2':0.000417441, (('PDT000111582.2':0.000380979, 'PDT000111584.2':0.000318881)NODE_000013:0.000066145, ('PDT000111575.2':0.000205089, ('PDT000111578.2':0.000388139, 'PDT000111585.2':0.000211741)NODE_000014:0.0000948711)NODE_000015:0.000168731)NODE_000016:0.0001556)NODE_000017:0.000019794)NODE_000018:0.0005216)NODE_000019:0.000230167)NODE_000020:0.00790221)NODE_000021:0.00679072)NODE_000022:-0.00465701)NODE_000023:0.0135222)NODE_000024:0.00530667)NODE_000025:0.00710352, ((('PDT000420342.2':0.00867207, 'PDT000658397.1':0.00987763)NODE_000026:0.00394882, ('PDT000420251.2':0.00930422, ('PDT000420494.2':0.00560881, ('PDT000420019.2':0.0000462236, 'PDT000420456.2':0.00005377640000000001)NODE_000027:0.00563134)NODE_000028:0.00290101)NODE_000029:0.00950324)NODE_000030:0.00631592, ((('PDT000715497.1':0.0019086, 'PDT000000595.5':0.00218771)NODE_000031:0.00245252, ('PDT000489474.1':0.000717467, (('PDT000489323.1':0.000221158, 'PDT000489407.1':0.000278742)NODE_000032:0.0000647109, ('PDT000489464.1':0.00012838, ('PDT000486139.2':0.000058193900000000005, 'PDT000489485.1':0.0000418061)NODE_000033:0.000171585)NODE_000034:0.000178041)NODE_000035:0.000435336)NODE_000036:0.00708397)NODE_000037:0.00195908, (('PDT000518591.1':0.00291175, 'PDT000536820.1':0.00208525)NODE_000038:0.0111476, ((('PDT000036539.2':0.00402592, ('PDT000112614.2':0.000261359, 'PDT000025487.3':0.000138601)NODE_000039:0.0022718)NODE_000040:0.00971232, ('PDT000005905.2':0.0136903, ('PDT000030344.3':0.00786456, ('PDT000036653.2':0.00390216, ('PDT000036538.2':0.00449639, ('PDT000102712.3':0.00265854, ('PDT000025482.3':0.00200228, ('PDT000246521.2':0.000733636, ('PDT000133698.2':0.000221947, (('PDT000362352.1':0.000106709, 'PDT000002741.3':0.00009327120000000001)NODE_000041:0.0000808958, ('PDT000576927.1':0.000163816, ('PDT000133699.2':0.0000323786, 'PDT000133700.2':0.0000676214)NODE_000042:0.000036183700000000004)NODE_000043:0.0000736729)NODE_000044:0.00009418600000000001)NODE_000045:0.000380775)NODE_000046:0.00135761)NODE_000047:0.000388642)NODE_000048:0.000351942)NODE_000049:0.000328401)NODE_000050:0.00142501)NODE_000051:0.000497992)NODE_000052:0.00152019)NODE_000053:0.000431489, ('PDT000119951.2':0.0169704, ('PDT000430625.1':0.00364419, (('PDT000025469.3':0.00121963, ('PDT000025479.3':0.000397895, (('PDT000025470.3':0.000206438, 'PDT000025480.3':0.000193482)NODE_000054:0.000048854800000000005, ('PDT000025474.3':0.000181545, ('PDT000025473.3':0.00022996, ('PDT000025472.3':0, 'PDT000025471.3':0)NODE_000055:0.00017004)NODE_000056:0.00006177440000000001)NODE_000057:0.000191907)NODE_000058:0.000151469)NODE_000059:0.000221088)NODE_000060:0.000023073800000000003, ('PDT000715488.1':0.000967287, (('PDT000065812.2':0.000721315, ('PDT000715489.1':0.000247055, 'PDT000715495.1':0.000252845)NODE_000061:0.000278345)NODE_000062:-0.00005042570000000001, ('PDT000025478.3':0.000876341, (('PDT000715499.1':0.00039311, 'PDT000356339.1':0.00050653)NODE_000063:0.000113079, (('PDT000715490.1':0.000260406, 'PDT000715496.1':0.000339534)NODE_000064:0.0000719736, ('PDT000152418.1':0.000273525, ('PDT000715498.1':0.000191038, ('PDT000715492.1':0.000170376, (('PDT000715494.1':0.000101269, ('PDT000356340.1':0.000033464100000000004, 'PDT000041260.2':0.00006653590000000001)NODE_000065:0.0000987064)NODE_000066:0.00003476370000000001, ('PDT000025481.3':0.000198834, (('PDT000025488.3':0.000059052500000000004, ('PDT000715487.1':0, 'PDT000715501.1':0)NODE_000067:0.00004094750000000001)NODE_000068:0.000056655300000000006, ('PDT000715491.1':0.000143976, ('PDT000025484.3':0.0000369894, ('PDT000715493.1':0.000033189700000000005, ('PDT000715500.1':0.000027748100000000003, 'PDT000083329.5':0.0000722519)NODE_000069:0.0000668003)NODE_000070:0.00007407050000000001)NODE_000071:0.0000245089)NODE_000072:-3.9250099999999995*^-6)NODE_000073:0.0000937248)NODE_000074:-0.0000648775)NODE_000075:0.000102293)NODE_000076:6.9989399999999994*^-6)NODE_000077:0.0000329868)NODE_000078:0.0000984883)NODE_000079:0.0000126595)NODE_000080:0.000159901)NODE_000081:-0.00006008200000000001)NODE_000082:0.000295401)NODE_000083:-0.00030214)NODE_000084:0.00261792)NODE_000085:0.010092)NODE_000086:-0.00601038)NODE_000087:0.00522493)NODE_000088:-0.00229636)NODE_000089:0.00492686)NODE_000090:0.00742719)NODE_000091:0.00795775)"]
Out[6]=

Version History

  • 1.0.0 – 22 April 2020

Related Resources

License Information