Hi all,
How to compare the values of two nodes and how can I get the difference between two nodes from a Dendrogram? Is there any method available in R for comparing two nodes?
Hi all,
How to compare the values of two nodes and how can I get the difference between two nodes from a Dendrogram? Is there any method available in R for comparing two nodes?
Not an R solution but you can do this type of calculations using BioPerl (look at node depth in Bio::TreeIO module) or ETE (Python).
You can identify the point with the identify() method, which actually works for many other plots too. Say, I have a matrix with two columns, and plot the second against the first column, I can then interactively click points with identify() where double click ends the selection. Example code:
> plot(h2[,1], h2[,2])
> identify(h2)
[1] 2
> h2[2,]
[1] "93" "95"
You probably want the distance between the two nodes as calculated in the distance matrix. Note that the distance matrix is what you're plotting in a dendrogram.
d = dist(M)
dd = as.matrix(d)
dd[which(labels(d)=='sample.1'), which(labels(d)=='sample.2')]
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Exactly the answer I would want to see when I read this question. It is indeed the distance matrix that one needs/uses when plotting/analyzing dendrograms. Thanks, David, for raising this important point.