thibautjombart / treespace

Explore spaces of phylogenetic trees
https://thibautjombart.github.io/treespace/
Other
27 stars 9 forks source link

question about plot3d/MDS? #10

Closed drelo closed 1 year ago

drelo commented 1 year ago

Dear all, I loaded several trees and plotted it with plotGrovesD3 and plot3d. My question is the following one, following this procedure...

BIGscape <- treespace(BIG, nf=6)    # distance treespace
BIG.groves <- findGroves(BIGscape, nclust=8) # Groves
plot3d(BIG.groves$treespace$pco$li[,1],  BIG.groves$treespace$pco$li[,2], BIG.groves$treespace$pco$li[,3],  col=colours, type="s", size=3.5,  xlab="", ylab="", zlab="")

The plot3d ends like a 3d visualization of principal components right? Or should I describe it as a form of hierarchical clustering? I was thinking about the legend figure and was worried that I got it wrong. Thanks

Andrés

MichelleKendall commented 1 year ago

Hi,

So there are two steps in your example:

  1. Applying the function treespace performs the principal co-ordinates analysis (equivalently "multi dimensional scaling" or "principal components analysis" - they are all equivalent here because the distances are Euclidean). Then BIGscape$pco$li[,1], BIGscape$pco$li[,2] and BIGscape$pco$li[,3] are the first three principal components. In your example, they are also saved after the findGroves function as BIG.groves$treespace$pco$li[,1], BIG.groves$treespace$pco$li[,2] and BIG.groves$treespace$pco$li[,3] so yes, your example is a 3D plot where the co-ordinates of each point correspond to those of the first three principal components.

  2. Applying the function findGroves performs the hierarchical clustering, classifying the trees into 8 clusters in your example. The result of that is in BIG.groves$groups. It's not clear to me if you are then colouring your 3D plot according to these 8 clusters. If you are, then the legend figure ought to say as much, but if the colouring is about something different then you don't need to mention the hierarchical clustering, and actually you probably don't need the findGroves step at all.

Hope that's helpful, let me know if I can clarify anything further.

Cheers,

Michelle

drelo commented 1 year ago

Thanks for your help and clarification. Your first point clarified my issue. Yeah, I used findGroves as a shortcut to use directly the plot3d part of the code, I just checked and I could have used BIGscape$pco$li directly, thanks for the advice. Cheers Andrés