the bars represent the loading weights associated with each OTU (in my case) and the colours indicate the group with the higher mean for that OTU (plotLoadings(MyResult.splsda2, contrib = ‘max’, method = ‘mean’)).
Your interpretation is correct. We assign by default the colors as indicated the legend (there is no calculation per say). We do not allow users to choose those colors currently.
My supervisor has asked me to add p-values to my loading plot which I am not sure if makes sense, or how I would do it?
The p-values (from which test?) wont make much sense given that the variables are selected together, rather than being evaluated independently in sPLS-DA. It may also make the plot a bit crowded. You can extract the matrix with all the information used to produce this plot by saving it into an object and tweak as you please! I show the code below to give an example:
X = as.matrix(liver.toxicity$gene)
Y = as.factor(paste0('treatment_' ,liver.toxicity$treatment[, 4]))
splsda.liver = splsda(X, Y, ncomp = 2, keepX = c(20, 20))
# contribution on comp 1, based on the median.
# Colors indicate the group in which the median expression is maximal
myplot = plotLoadings(splsda.liver, comp = 1, method = 'median', contrib = 'max')