The customization of shape and color was wrongly applied in plotIndiv()

Hi All,

I’m new here. Recently, I encountered a problem when using mixOmics for transcriptomics data analysis. Please check my code and figures below.


X is gene\sample matrix

Y is factors of sample group information

mms.plsda ← plsda( X,
Y,
ncomp = mms.plsda.ncomp)

mms.plsda_plot.final ← plotIndiv(mms.plsda,
comp = c(1:2),
rep.space = ‘X-variate’,
style = ‘ggplot2’,
group = Y,
pch = Y,
pch.levels = rep(mms_pch_palette,times=fgp),
ind.names = TRUE,
col.per.group = mms_color_palette,
ellipse = FALSE,
ellipse.level = 0.85,
background = background.mms.plsda,
legend = TRUE,
legend.title = “”,
legend.position = “bottom”,
size.legend = rel(1.5),
point.lwd = 1,
X.label = paste0(“X-variate 1: “,toString(round(mms.plsda[[“prop_expl_var”]][[“X”]][[“comp1”]]*100,1)),”% expl. var”),
size.xlabel = rel(2),
Y.label = paste0(“X-variate 2: “,toString(round(mms.plsda[[“prop_expl_var”]][[“X”]][[“comp2”]]*100,1)),”% expl. var”),
size.ylabel = rel(2),
size.axis = rel(1.8),
title = paste0(mms.title,“_PLS-DA Plot”),
size.title = rel(2.0))

the figure created is below:

You may tell that the shape/color/background do not match in the box as well as in the legend.
I extracted the coordinates from mms.plsda and put it in ggplot2 with the same customization, would get the right figure below.

Does anyone know what’s the possible reason and how to fix it? Thanks.

PS.
I’m using mixOmics (6.26.0) in RStudio (2023.12.1+402) with R-4.3.2 in Windows 11 23H2.

Here is the figure from ggplot2 (As a new user, I can only put 1 figure in a post)

hi @zzl136,
It would be hard for me to debug as I dont have your data, and I feel you are overcomplicating the arguments in the function and so the legend / colours dont match anymore.

See:
The examples in ?plotIndiv (if you are interested in ellipses, then put ellipse = TRUE, but try keep the arguments to a minimum)

See the example in ?background.predict if you want the background color of prediction.

Kim-Anh