This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Analyse A Dendrogram In R?

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?

r

3 answers

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')]

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.

Log in to answer this question.