PCA plot for TOP 500 genes + prcomp
0
0
Entering edit mode
5.7 years ago
mkh ▴ 60

Hi all,

Do you know how do I plot PCA for top500 genes by prcomp() the same as PCAplot in Desq2?

I would like to plot the PCA for top 500 genes for PCA3 and PCA4.

Thanks

RNA-Seq • 5.1k views
ADD COMMENT
1
Entering edit mode

IIRC prcomp gives you a rotation matrix, from which you can get genes that contribute the most to PC3 and PC4. You could then use that subset to plot.

ADD REPLY
0
Entering edit mode

pcaExplorer is a cool package which can do it.

You can find more information here: pcaExplorer

ADD REPLY
4
Entering edit mode

As per Ram, you can easily do it with the rotation matrix from prcomp. For example:

pca <- prcomp(x)

# indices of top 500 genes on PC1 by absolute value
values1 <- order(abs(pca$rotation[,1]), decreasing=TRUE)[1:500]

# indices of top 500 genes on PC2 by absolute value
values2 <- order(abs(pca$rotation[,2]), decreasing=TRUE)[1:500]

et cetera

Note that DESeq2's plotPCA() function removes genes based on low variance prior to performing PCA. So, which do you want:

  1. remove genes based on low variance prior to performing PCA (via prcomp())?
  2. identify the top 500 genes contributing to variance in your dataset along PC3 and PC4 after you have performed PCA on your entire dataset (as per my code, above)?
ADD REPLY
0
Entering edit mode

This is very helpful, thanks! I'm really new to prcomp and am having trouble figuring out what the x represents? Do you perhaps have a longer stretch of code I could look at? Thanks!

ADD REPLY
1
Entering edit mode

In this case, x represents your input data-matrix. By the way, my PCAtools package was accepted to Bioconductor since this post, and will be officially released at the end of this month. Details here: https://github.com/kevinblighe/PCAtools

ADD REPLY
1
Entering edit mode

It is awesome!!! Thank you!

ADD REPLY

Login before adding your answer.

Traffic: 2370 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6