Dear list,
TL;DR: When I plot the newick tree ((((A,B),C,D),E),(((F,G),H),I));
shouldn't ((A,B),C,D) merge at the same level as ((F,G),H)?
Or in a phylogenetic tree it doesn't matter?
library(ape)
newickTree <- read.tree(text="((((A,B),C),E),(((F,G),H),I));")
plot(newickTree)
goes just fine but then, when I add D:
newickTree <- read.tree(text="((((A,B),C,D),E),(((F,G),H),I));")
plot(newickTree)
The merge between (A,B),C,D goes one level up (and consequently E too).
Very long version: I'm developing my own hierarchical clustering
algorithm
that outputs a matrix like the one bellow:
| Level 1 | Level 2 | Level 3 | Level 4 | Level 5 |
Level 6
------------------------------------------------------------------------------------------------------
1 | 1 | c(5,8) | c(2, 5, 8) | c(2, 5, 7, 8) | c(2, 5, 6,
7, 8)
| 1:10
2 | 2 | c(5,8) | c(1, 5, 8) | c(2, 5, 7, 8) | c(2, 5, 6,
7, 8)
| 1:10
3 | 3 | c(4,9) | c(3, 4, 9) | c(2, 5, 7, 8) | c(1, 2, 5,
7, 8)
| 1:10
4 | 4 | c(4,9) | c(3, 4, 9) | c(3, 4, 9, 10) | c(2, 5, 6,
7, 8)
| 1:10
5 | 5 | c(5,8) | c(1, 5, 8) | c(2, 5, 7, 8) | c(2, 5, 6,
7, 8)
| 1:10
6 | 6 | c(5,8) | c(2, 5, 8) | c(2, 5, 7, 8) | c(1, 2, 5,
7, 8)
| 1:10
7 | 7 | c(5,8) | c(2, 5, 8) | c(2, 5, 7, 8) | c(1, 2, 5,
7, 8)
| 1:10
8 | 8 | c(5,8) | c(2, 5, 8) | c(2, 5, 7, 8) | c(2, 5, 6,
7, 8)
| 1:10
9 | 9 | c(4,9) | c(3, 4, 9) | c(2, 5, 7, 8) | c(2, 5, 6,
7, 8)
| 1:10
10| 10 | c(4,9) | c(3, 4, 9) | c(3, 4, 9, 10) | c(2, 5, 6, 7,
8) |
1:10
I want to plot a dendrogram based on this and the best idea I had was to
convert that matrix to a newick tree format and use ape to read it and
plot
as a dendrogram.
So the corresponding newick tree would be
newickTree <-
read.tree(text="(((((5,8),1,2),7),6),(((4,9),3),10));")
plot(newickTree)
But the levels are wrong.. I was expecting this:
newickTree <-
read.tree(text="(((((5:1,8:1):1,1:2,2:2):1,7:3):1,6:4):1,(((4:1,9:1):1,3:2):1,10:3):2);")
plot(newickTree)
I know that I can just specify the heights and solve my problem but that
would make my code more complex. One idea I had reading the last thread
(Making ultrametric trees) was to make every height = 1 and read it with
chronos()
newickTree <-
read.tree(text="((((A:1,B:1):1,C:1,D:1):1,E:1):1,(((F:1,G:1):1,H:1):1,I:1):1);")
dendr <- chronos(newickTree)
plot(dendr)
but it doesn't look right..
Sorry for the newbie questions.. I just wanted a way to make my algorithm
output a dendrogram.
Thanks in advance.