HOW to define the "parLabVc" indices in ropls package.
1
0
Entering edit mode
@yuanguo001-15824
Last seen 6.6 years ago

Hi, I am using package"ropls" to generate PCA plot. And I want to change the  labels of observations on the plot, which is defaulted as the row name of m data set. 

But, I do not know how to define the labels ("indices of "x") that I want to display in my PCA plot. 

following the argument in the manual: 

"parLabVc,   Optional character vector for the labels of observations on the plot; default is NA [ie row names of ’x’, if available, or indices of ’x’, otherwise, will be used]"

R ropls • 1.7k views
ADD COMMENT
0
Entering edit mode
@etiennethevenot-8285
Last seen 22 months ago
France

Hi,

Below is an example of labels ("s1", "s2", ..., "sN"), where N is the total number of samples. You can use any character vector of length N. Does it answer your question?

Etienne.

> library(ropls)
> data(sacurine)

> pcaModel <- opls(sacurine[["dataMatrix"]])
> plot(pcaModel, parLabVc = paste0("s", 1:nrow(sacurine[["dataMatrix"]])), typeVc = "x-score")

ADD COMMENT
0
Entering edit mode

Hi Etienne,

thank you for your answer. My observations belong to 5 groups. Can I assign each group with symbols of "circles", "triangles" and so on, respectively? That will be more clean that just like"S1,S2,S3,S4......." on the plot

Thank you for your help.

Yuan

 

ADD REPLY
0
Entering edit mode

You cannot use symbols (but special characters work). A better option would be to use colors according to your classes (use a factor in the parColFcVn argument):

> library(ropls)
> data(sacurine)
> pcaModel <- opls(sacurine[["dataMatrix"]])
> plot(pcaModel, typeVc = "x-score", parLabVc = paste0("S", 1:nrow(sacurine[["dataMatrix"]])), parAsColFcVn = as.factor(rep_len(paste0("G", 1:5), length.out = nrow(sacurine[["dataMatrix"]]))))

ADD REPLY
0
Entering edit mode

It works. Thank you so much

ADD REPLY

Login before adding your answer.

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