'group' must be a factor of length, from plotDiablo

I am getting an error:

**Error in .get.group(group, object, n_ind) : **
’group’ must be a factor of length 43

When running the following code

plotDiablo(diablo.final, ncomp = ncomp, group = Yvec
           , col.per.group = c("#4575B4", "#D73027") ) 

The Vector Yvec is length 43:

> Yvec
RUS031 RUS127 RUS057 RUS030 RUS115 RUS045 
     H      L      H      L      L      H 
RUS025 RUS003 RUS138 RUS044 RUS005 RUS042 
     H      L      L      L      L      H 
RUS051 RUS141 RUS052 RUS008 RUS145 RUS004 
     L      H      L      H      L      L 
RUS060 RUS134 RUS006 RUS139 RUS012 RUS041 
     H      L      L      L      H      L 
RUS014 RUS136 RUS010 RUS043 RUS020 RUS137 
     H      L      L      L      L      L 
RUS122 RUS087 RUS061 RUS067 RUS107 RUS095 
     H      H      L      L      L      H 
RUS110 RUS047 RUS058 RUS024 RUS140 RUS072 
     L      H      L      H      H      L 
Levels: H L
> length(Yvec)
[1] 43

The X matrices are:

> dim(diablo.final$X$sera)
[1] 43  9
> dim(diablo.final$X$glycansInd)
[1] 43  5
> dim(diablo.final$X$metab)
[1] 43 24

Does anyone have any idea of the circumstance that causes this error ?


G’day. It’s a bit tricky to diagnose your issue without any context but I’ll see what I can do. If you’re familiar with the use of breakpoints, I’d suggest placing one on line 74 of plotDiablo() and assessing what is being input into the .get.cols.and.groups() function.

Would you mind showing the sample names for each input block? A mismatch between names(Y) and the names of each predictor data frame may be the cause

I will try this. is there a way for me to attach a saved environment and I will attach one with the Y and X$… and you can see.