PCA in DESeq2 - Can I get the genes contributing most to each component?
2
1
Entering edit mode
Emily ▴ 10
@emily-10732
Last seen 7.9 years ago

I am using the deseq2 function plotPCA to visualize the principal components of my count data. I would like to extract the list of geneIDs that are contributing most to each component. I can get the value of PC1 and PC2 for each sample using returnData=TRUE, but I would like to extract the top and bottom genes from each component. Any ideas for me? Thank you!

deseq2 pca • 5.5k views
ADD COMMENT
1
Entering edit mode
@mikelove
Last seen just now
United States

You can just perform the PCA yourself and then look at the loadings.

Just copy out the code from the plotPCA function:

https://github.com/Bioconductor-mirror/DESeq2/blob/master/R/plots.R#L165-L171

ADD COMMENT
0
Entering edit mode
Emily ▴ 10
@emily-10732
Last seen 7.9 years ago

Thanks for your help! It appears that the rowVars function:

rv <- rowVars(assay(object))

requires the matrixstats package that cannot be used with R version 3.2.2

Is there another way to do this or should I use an older version of R?

 

ADD COMMENT
0
Entering edit mode
apply(x, 1, var)
ADD REPLY
0
Entering edit mode

As Michael has pointed out, rowVars is just a faster way to perform apply(x, 1, var), but why do you say matrixStats can't be used with R version 3.2.2? It definitely can.

ADD REPLY
0
Entering edit mode

> install.packages('matrixStats')

--- Please select a CRAN mirror for use in this session ---

Error in download.file(url, destfile = f, quiet = TRUE) : 

  unsupported URL scheme

HTTPS CRAN mirror 

 

 1: 0-Cloud [https]             2: Austria [https]          

 3: China (Beijing 4) [https]   4: China (Hefei) [https]    

 5: Colombia (Cali) [https]     6: France (Lyon 2) [https]  

 7: Iceland [https]             8: Russia (Moscow 1) [https]

 9: Switzerland [https]        10: UK (Bristol) [https]     

11: UK (Cambridge) [https]     12: USA (CA 1) [https]       

13: USA (KS) [https]           14: USA (MI 1) [https]       

15: USA (TN) [https]           16: USA (TX) [https]         

17: USA (WA) [https]           18: (HTTP mirrors)           

 

 

Selection: 17

Warning: unable to access index for repository https://cran.fhcrc.org/src/contrib

Warning message:

package 'matrixStats' is not available (for R version 3.2.2) 

ADD REPLY
0
Entering edit mode

This isn't matrixStats specific, and I bet installing any other package via install.packages will also bite you in this way.

You can see that R is telling you that the error is "unsupported URL scheme", and I'm guessing that you can't install packages via https on your system. A google search for installing packages via https for your platform (I'm guessing you're on windows, or(?)) will help you sort it out.

To get you started, this post may or may not help.

ADD REPLY

Login before adding your answer.

Traffic: 709 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