PlotVar on PCA: legends and pch issues

Dear mixOmics’ team/members,

I am currently using plotVar on PCA results, and I have 2 issues (perhaps correlated) on the following graph:

plotVar(pca_result,
col = list(ifelse(grepl(“expression”, colnames(my_data)), color.mixo(1), color.mixo(2))),
var.names = F,
pch = 1,
legend = T,
title = “Expression in blue, methylation in orange”)

As you can see, I have two groups of variables: expression and methylation data. I could separate them in two blocks (with PLS or rCCA), but I first would like to have only one block (with PCA) to show that the highest difference between my variables is on the omics’ type. Hence, I have coloured variables: blue for expression and orange for methylation.

First issue: I would like to have a legend indicating which colour corresponds to which omics’ type, but the only legend I am able to print is the one indicating that I have only one block ‘X’.

Second issue: as you can see, I have changed the colours, but I can’t change the colour of the center of each point, so even my blue points have an orange center. (the orange colour is probably related to the colour of the ‘X block’)

Could you please help me solving these issues?

Best regards,
Emile M.

  1. As you can read in the plotVar() documentation, the legend parameter is really only built for multiblock scenarios, and certainly not PCA. You would need to build your own custom legend (refer to ?legend from the graphics or ggplot2 package). You could then place this next to the plotVar() output (using par())
  2. I’ll make note of this minor bug. Resolving this is not a major priority however. Hence, I’d recommend just changing the value used in the pch parameter.

Thank you for your answer, your advice work well for me!

Best,
Emile