xia-lab / MetaboAnalystR

R package for MetaboAnalyst
Other
315 stars 156 forks source link

Error when doing PLSDA.CV #66

Closed Zhuxitong closed 1 year ago

Zhuxitong commented 5 years ago

when I was doing PLS-DA analysis, I met below problem:

> mSet<-PLSDA.CV(mSetObj = mSet, methodName = "T",compNum = 5, choice = "Q2")
Error in cvsegments(nobj, k = segments, type = segment.type) : 
  More segments than observations requested

At the begining,

mSet<-PLSR.Anal(mSet, reg=TRUE)

has no error. So what would be the problem?

Zhuxitong commented 5 years ago

Hi,

I think I found the problem.

In pls::plsr, the default segment number for cross-valiation is 10, but in my data, there are only 8 samples, so it's impossible to perform 10-fold cross-valiation. To make sure this, I tested below commands:

pls::plsr(cls ~ datmat, method = "oscorespls", ncomp = 5, validation = "CV")
&
pls::plsr(cls ~ datmat, method = "oscorespls", ncomp = 5, validation = "CV", segments = 5)

The second one works fine. So the problem left is that in the PLSDA.CV function, only 4 parameters are supported( mSetObj, methodName, compNum and choice). So how can I set the segments number parameter here without modify the source code?

jsychong commented 5 years ago

Hi, can you send me your dataset (email is jasmine.chong at mail.mcgill.ca) so I can figure out how to best add a parameter for this?

Zhuxitong commented 5 years ago

Hi, can you send me your dataset (email is jasmine.chong at mail.mcgill.ca) so I can figure out how to best add a parameter for this?

My datasets is very big (180Mb per sample and 8 samples in total). So it's not ok to send you. I think whatever a datasets with less than 10 samples would meet this problem.

When I add anthor 2 samples so here are 10 sanples, this problem never appears.

jessica-ewald commented 1 year ago

A more informative error message has been added to the web. MetaboAnalystR will be updated when we release version 4.0 soon.