How to plot PCA on two or more variables
1
2
Entering edit mode
4.9 years ago

Hi,

I am working on the expression datasets that has multiple-variables. I am using the FactoMineR and pca3d libraries for this purpose and was able to distinguish two factor levels belonging to a one variable column. However, I am not able to perform the PCA on the two variable columns that has different factor levels. Please let me know how can I do the PCA on multi-variable.

Below is the code I have ran with the one variable column;

Neg_Dct
## Column [1-4 and 269-272] of the data set contains variables/categorical data##
df = Neg_Dct[,-c(1:4, 269:272)]


library(FactoMineR)
nb_1 = estim_ncpPCA(df,ncp.max=5)
res.comp_1 = imputePCA(df,ncp=2)
res.pca_1 = PCA(res.comp_1$completeObs)

library(pca3d)
Node <- res.comp_1$completeObs
pca <- prcomp(Node, scale.=TRUE)
gr <- factor(Neg_Dct[,272])
summary(gr)
B_1   B_2 
 31     132 

#2D plot##
pca3d(pca, group=gr)

#2D plot##
pca2d(pca, group=gr)

Thank you,

Toufiq

pca3d FactoMineR R PCA variables • 4.5k views
ADD COMMENT
0
Entering edit mode

@ Kevin Blighe,

Thank you very much for the suggestions. Can I also perform 3D visualisation using the pcatools?

Sometimes, it does not show the Reply button to write back so I had to add the text in the comment section.

ADD REPLY
1
Entering edit mode

You cannot perform 3-D visualisation using PCAtools; however, I may implement it in the future. I provide some basic code for a 3-d PCA here: A: PCA plot from read count matrix from RNA-Seq

To respond my original answer, I think that you can use the ADD COMMENT button alone, no? It looks like you posted a new answer (but I moved it).

ADD REPLY
0
Entering edit mode

@ Kevin Blighe ,

Noted. Thank you very much. This is helpful.

ADD REPLY
7
Entering edit mode
4.9 years ago

Use PCAtools (I am the developer), where you can have as many levels as you want, and represent them as both different shapes and / or colours: 4.2.3 Change shape based on tumour grade, remove connectors, and add titles

kkkk

ADD COMMENT

Login before adding your answer.

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