Search
Question: HOW to define the "parLabVc" indices in ropls package.
0
gravatar for yuan.guo001
5 months ago by
yuan.guo0010 wrote:

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]"

ADD COMMENTlink modified 5 months ago by etienne.thevenot0 • written 5 months ago by yuan.guo0010
0
gravatar for etienne.thevenot
5 months ago by
France
etienne.thevenot0 wrote:

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 COMMENTlink written 5 months ago by etienne.thevenot0

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 REPLYlink written 5 months ago by yuan.guo0010

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 REPLYlink written 5 months ago by etienne.thevenot0

It works. Thank you so much

ADD REPLYlink written 5 months ago by yuan.guo0010
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 186 users visited in the last hour