Insert PCA in design model for adjusting
1
0
Entering edit mode
mheydarpour ▴ 10
@mheydarpour-9430
Last seen 2.6 years ago

I have a Gene-Expression file contain 18,000 genes (RPKM) for 150 patients of Breast Cancer (Normalized).

I would like to calculate the first 4 principle component (PCA1, PCA2, PCA3,PCA4) of this data and then insert them in the model along with "gender" and "age" for adjusting in Limma. Could you please advise how to do that.

design=model.matrix(~0+age+gender+PCA1+PCA2+PCA3+PCA4+treatment)

PCA • 671 views
2
Entering edit mode
@james-w-macdonald-5106
Last seen 5 hours ago
United States

Let's assume your matrix of RPKM is set up with genes in rows and samples in columns, which is how these things usually go. Further, assume this matrix is called 'my.rpkms'.

pca <- prcomp(t(my.rpkms))
design <- model.matrix(~0+age+gender+treatment)
design <- cbind(design, pca\$x[,1:4])

0
Entering edit mode

Thanks James for your great reply! How I can get the values of each PCA as an output and plot them?