<p>There appear two basic issues here:</p>
<ol>
<li>The PCA would represent arbitrary lineage designation not a genetic quantification.</li>
<li>The PCA will weight the first, second ... fourth position equally, i.e. it is not hierarchical. This is very important for the analysis.</li>
</ol>
<p><em>Summary</em> The hierarchical -&gt; 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.</p>
<p>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.</p>
<p><em>Fixing it</em> You ask how to fix it</p>
<ol>
<li>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.</li>
<li>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.</li>
</ol>
<p>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.</p>

CC BY-SA 4.0
2022-07-26T01:06:48.127Z
I didn't expect this accurate and kind answer. I will keep that in mind. Thank you.
SG Kwon
CC BY-SA 4.0
2022-07-26T13:44:30.050Z
Hi @SGKwon you are very welcome, always here to help.
M__
CC BY-SA 4.0
2022-07-23T10:15:39.597Z
2022-07-23T13:54:36.427Z
2022-07-23T13:54:36.427Z
M__
<p>I have a phylogenetic tree.</p>
<p>Each branch ends have samples (s1, s2, ~ s16).</p>
<p><a href="https://i.sstatic.net/dYIsT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dYIsT.png" alt="enter image description here" /></a></p>
<p>What I want to do is, I want to make PCA analysis plot for each sample.</p>
<p>First I thought each sample has each lineage (expressed in image as (1,1,1,1)~(2,2,2,2)).</p>
<p>So with that coordinates, I can do PCA analysis.</p>
<p>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.</p>
<p>I am not sure if this kind of approach is suitable for making a PCA plot with a phylogenetic tree.</p>
<p>How can I make this work?</p>

CC BY-SA 4.0
2022-07-21T16:46:19.773Z
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?
Maximilian Press
CC BY-SA 4.0
2022-07-21T18:45:45.063Z
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__
CC BY-SA 4.0
2022-07-23T07:35:15.553Z
@MaximilianPress The sorting data from which the tree was generated is described here 
https://stackoverflow.com/questions/71953348/python-make-newick-format-using-dataframe-with-0s-and-1s 
Hope this helps...
SG Kwon
CC BY-SA 4.0
2022-07-23T07:37:34.223Z
@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.
SG Kwon
<phylogenetics><phylogeny><pca><tsne>
PCA analysis of samples in a phylogenetic tree
# PCA analysis of samples in a phylogenetic tree

(Asked by: username_0 on 2022-07-21)

I have a phylogenetic tree.

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

[![enter image description here](https://i.sstatic.net/dYIsT.png)](https://i.sstatic.net/dYIsT.png)

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?

**Tags:** phylogenetics, phylogeny, pca, tsne
> **Comments:**
> **username_1**: 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?  
> **username_2**: 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?  
> **username_0**: @MaximilianPress The sorting data from which the tree was generated is described here  https://stackoverflow.com/questions/71953348/python-make-newick-format-using-dataframe-with-0s-and-1s  Hope this helps...  
> **username_0**: @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.  

---

## 1 answers

### Answer by username_2 on 2022-07-23. Score: 1 | Accepted answer

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.

> **Comments:**
> **username_0**: I didn't expect this accurate and kind answer. I will keep that in mind. Thank you.  
> **username_2**: Hi @SGKwon you are very welcome, always here to help.  

---

