# Performing PCA for the samples and for the genes

I have 10 samples from a RNAseq experiment (5 control, 5 disease), I have performed a cluster analysis for the samples and for the genes (4000 genes aprox) to see how they cluster (to see which samples are similar and which genes have similar expressions). I was wondering if in terms of statistics it makes any sense to perform a PCA of the samples instead of the genes?

• I think doing PCA on RNAseq samples is something people do - you can probably just use the prcomp function in R. However, I'm not sure how much information you can get in a PCA with just 10 samples. – user438383 Oct 15 '20 at 12:26
• People usually do PCA on RNAseq samples, but they use genes as variables. But I want to do it using samples as variables, and I am not sure if that makes sense in terms of statistics. – Mee Oct 15 '20 at 12:35
• Why do you specifically want to do a PCA using samples? Can you do it on genes and plot the loading of samples? Since you have thousands of genes and only 10 samples, it doesn't seem you can do it on samples. – Phoenix Mu Oct 15 '20 at 12:48

First of all, I am not a statistician but have been performing RNA-seq analysis for a while, here is my take:

• I think performing PCA on the samples makes sense in terms of mathematics. What I mean is you can compute eigenvectors and subsequently principal components either on your genes or on your samples.

• I don't think performing PCA on the samples makes sense in terms of statistics in RNA-seq context (and probably in any other context): Your genes (features) describe your samples and not the other way around. So the computed PCs should describe/explain your samples and not the other way around. You would not perform PCA on your samples (individual cells in scRNA-seq) even in the case of scRNA-seq, where number of samples sometimes exceeds the number of genes, there PCA is performed on genes and the resulting few PCs are used for downstream analysis, usually clustering and visualization, both used to infer about samples (cells).

If you use, say, R's prcomp, you can use my_pca_object$x to get PC coordinates for the samples, and my_pca_object$rotation to get how much each gene contributes to each PCA. (You might need to transpose your transformed count file to get it to work right)

It is quite possible to make a PCA plot with the samples. Follow this tutorial : https://hbctraining.github.io/DGE_workshop/lessons/03_DGE_QC_analysis.html