# PCA analysis of samples in a phylogenetic tree

I have a phylogenetic tree.

Each branch ends have samples (s1, s2, ~ s16).

What I want to do is, I want to make PCA analysis plot for each sample.

First I thought each sample has each lineage (expressed in image as (1,1,1,1)~(2,2,2,2)).

So with that coordinates, I can do PCA analysis.

But on the second thought, the difference between (1,1,1,1) and (1,1,1,2) is much less than that of (1,1,1,1) and (2,1,1,1), but in the analysis, the difference between them will be same.

I am not sure if this kind of approach is suitable for making a PCA plot with a phylogenetic tree.

How can I make this work?

• I don't understand. Do you want to somehow represent the phylogenetic information as an ordination plot instead? If that's the case you would be better off going back to your starting data from which the tree was generated, computing distances, and using those for ordination (PCoA probably, or if it's variant data you could just do PCA on that). You don't say anything about having character data for the tips. Maybe this would be clarified by understanding what you mean when you say "sample". Are you trying to replace the phylogeny, or represent something on top of the phylogeny? Jul 21, 2022 at 16:46
• What is the tree type, Phylogram or a dendrogram? Your picture suggests a dendrogram. Expressed in image as (1,1,1,1)~(2,2,2,2) ... this is a bit weird, oh I see its a valuation of the nodes. It is not clear what the value '1' represents mutation?
– M__
Jul 21, 2022 at 18:45
• @MaximilianPress The sorting data from which the tree was generated is described here stackoverflow.com/questions/71953348/… Hope this helps... Jul 23, 2022 at 7:35
• @M__ (1,1,1,1) means lineage 1-1-1-1 if you understand this. I have assigned the samples with the lineage hierarchy represented as 1 or 2. Jul 23, 2022 at 7:37

There appear two basic issues here:

1. The PCA would represent arbitrary lineage designation not a genetic quantification.
2. The PCA will weight the first, second ... fourth position equally, i.e. it is not hierarchical. This is very important for the analysis.

Summary The hierarchical -> unweighted PCA will cause analytical problems and should not be used, given it is ultimately arbitrary. If there was a tree specialist reviewing your work it would not be accepted.

The reason is that position one in the hierarchical cluster defines the entire data set - it cuts it in half, whilst position 4 defines a small a very small subtree. PCA will not see the hierarchy it will see position 1 as of equal worth to position 4. Therefore PCA will start associating arbitrary designated position 4 e.g. branch 2, with each other. Thus 1,1,1,2 is a long way from 2,1,1,2 but PCA will miss that it will think the shared '2' means their closer than they really are and find it of equal distance to e.g. 1,2,1,2 - which or course it isn't.

Fixing it You ask how to fix it

1. You can go back to the original data and use that to create a PCA based on SNPs ... this has been done for other genetic data types, but cannot done reinterpreting a tree. Using this approach there will be a problem with back mutation, but its a parsimony analysis and you would simply state your assumption - ultimately the influence of back mutation concerns the genetic distance between all taxa in the analysis and if thats not big, the error will be small.
2. Alternatively if you had a phylogram you could construct a genetic matrix and use genetic distance instead. Thats a separate question because its quite complicated.

tSNE is often used to refine a multivariate analysis and I think thats what you getting at, PCA followed by tSNE is valid. A tree isn't any regular multivariate analysis, its a tightly defined approximation within clear mathematical boundaries measuring/reconstructing evolutionary divergence. A tree specialist will see this, whilst a general multivariate stats specialist will miss it.

• I didn't expect this accurate and kind answer. I will keep that in mind. Thank you. Jul 26, 2022 at 1:06
• Hi @SGKwon you are very welcome, always here to help.
– M__
Jul 26, 2022 at 13:44