Faulty elllipse matching in plotIndiv() triggered by ind.names?

Hi there,

I am trying to plot the PCA of a transposed MS feature matrix using the following code

tp<- as.factor(xdata_group_fill$timepoint)
tfmat<-pca(t(fmat), center=TRUE, scale=TRUE)
plotIndiv(tfmat,
comp = c(1, 2), # Specify components to plot
ind.names = T, # Show row names of samples
group = tp,
col.per.group = timepoint_colors, # Use the colors defined for each timepoint
ellipse = TRUE,
title = ‘ABC transporters, PCA comp 1 - 2’,
legend = TRUE,
legend.title = ‘Timepoint’)

If i set ind.names=T the plot is correct (left image). As you can see the ellipses are correctly matched with the samples. Now if I set ind.names= F, i get incorrect matching (right image) where there seems to be a swap in point colors and ellipse end up wrongly matched…

Do you have any clue what causes this error and how I could solve it? Appreciate any help!

Kind regards,

Timothy

hi @TCD1999,

It is possible that the arguments clash between col.per.group and group.

I tried this and it works ok, just by setting group and ind.names.

## plot of individuals for objects of class 'pca'
# ----------------------------------------------------
data(nutrimouse)
X <- nutrimouse$lipid
nutri.pca <- pca(X, ncomp = 3)

# ellipse with respect to genotype
# names also indicate genotype
plotIndiv(nutri.res,
          ellipse = TRUE, ellipse.level = 0.9,
          group = nutrimouse$genotype, ind.names = nutrimouse$genotype)

We may have a bug between the ellipse colors and the colors as an input. I’ll flag this as a bug, but it will take a long time for us to get to this, unfortunately.

Kim-Anh