I’m trying to make a biplot from PLSDA results. I know I can use biplot function, but the customisation is really very limited. I cannot plot by grouping data or change colors.
Is there a way to create a biplot more customised? I would like to do something like that.
The current biplot function we have implemented is for pca functions only. Can you please give a reproducible example on how you made such plot for a plsda object?
#------------prepare loading data---------------------
plsda.loadings2<-plsda.loadings
plsda.loadings2$x<-“Element” #variables in my study are chemical elements, so variables group
plsda.loadings2[,“Deposit subtype”]<-“non” #this column is empty by I need it in order to have same columns that scores table
plsda.loadings2[,“Altered rocks”]<-"" #this column is empty by I need it in order to have same columns that scores table #------------prepare scores data---------------------
plsda.scores2<-plsda.scores
plsda.scores2$Type<-"" #observations column is empty because I label only variables
plsda.scores2$x<-“Sample” #group of samples
plsda.scores2<- mutate_if(plsda.scores2,is.numeric,~ . / 9) # scores values are modified in order to scale them to loadings
#-----merge scores and loadings--------------
biplot.data<-rbind(plsda.loadings2,plsda.scores2[,c(5,11,13,18:22)]) # merge
I hope that can help you.
Really this is not a biplot, it’s just a way to display scores and loadings in same plot.
Many thanks for the code. After install your “addon”, I am able to produce a biplot with PLS-DA.
However, I noticed that there were some other changes when running with mixOmics, for example, mypls$explained_variance was changed to mypls$prop_expl_var, and that created some issues my old code.
I also cannot run the perf function normally.
For the example:
data(nutrimouse)
X ← nutrimouse$gene
Y ← nutrimouse$lipid
MyResult.pls ← pls(X,Y, ncomp = 4)
perf.pls ← perf(MyResult.pls, validation = “loo”)
perf.pls$Q2.total now gives me NULL
Is there anyway that I can go back with the “original” function of mixOmics.
Many thanks,
Tuan
We did indeed add some substantial changes to the perf function. The measures can now be accessed via $measure where you can also see new measures as described in the docs.
However, I added a new issue to reflect these changes in the docs.
If you wish to install the snapshot of the package at the time this feature was implemented, you can simply do:
I managed to obtain a biplot for my PLSDA, but I am working with a huge number of variables, so the graph shows a cloud of arrows.
I would like to be able to select which variables are shown in the biplot, because I’m interested in some groups more than in others. Is this possible with the current version of the code?
I have tried sPLSDA in previous projects, but I am not looking for a way to select variables, maybe I didn’t explain myself very well.
I have a matrix of thousands of microbes, and I did PLSDA, and everything works fine, and I can create your biplots, but I can’t see anything interesting because I have too many variables, therefore, too many arrows in the plot.
What I want to do is to keep exactly the same PLSDA that includes thousands of microbes in the X matrix, but I want the plot to only show for example the methanogens. I know their names, and I wanted to be able to just feed the code with a vector of names, and have these appear in the biplot.