Hi guys I just can not figure out how to use the selectLab option in the biplot of PCAtools. I tried creating a logical vector (withF for every sample I don't want to have a lab for) as well as a vector with all the sample_ids that should have a label. But nothing works nd I can't wrap my head around how to make it work.
Thanks a lot for any comments! Sebastian
Can you explain a bit more what the problem is? From what I know
selectLab
must be a subset ofpca()$yvars
so most commonly the column names of the matrix that was used forpca()
.If you use the example data of
?biplot
then a possible choice could bebiplot(p, selectLab = c("sample28"))
.With Kevin Blighe you have the expert (author of the tool) here at biostars.
Hey, indeed, it should just be a character vector of samples that you want to label. If you do not define the
lab
variable, then the default labels are:So, if you use
selectLab
, be careful about what you are passing tolab
, too.Thanks for your answers, unfortunately it doesn't work.
Maybe I am wrong to assume that I can use the option to label only some of the data-points in the PCA? If I hand it a character vector with just a few of the row names from my metadata it doesn't work though but instead disables all labels.
Is it correct that selectLab allows you to show labels only for a few, selected data points instead of labels for every point or am I just totally wrong with this?
Example of what im trying to do:
It definitely works, but is designed specifically for sample IDs, which should be unique.
Using the data from the vignette:
For 'grouped' variable names, as is perhaps your
genotype
data, the way to go would be viacolby
orshape
.Ah, ok. This explains it! It seems that selectLab is expecting the exact labels to include, not the corresponding row names / samples.
If I give selectLab a character vector with all metadata chars to include it works. Actually it needs a little workaround still with as.character(metadata) as otherwise it prints factor levels.
This works fine now. Thanks a lot for your help! (will put this into an answer to the question below)
What is the content of
data_PCA$metadata$genotype
?data_PCA$metadata$genotype contains a character vector that I use as a label. If I use it without the selectLab option all runs fine but labels are shown for each data point which is a bit overwhelming. Thats why im trying to limit the label just to a few selected points.