Problem with perf() function on PLS-DA

Hello! I am attempting to carry out performance assessment on a PLS-DA dataset:

En.GenNoC.plsda.perf <- perf(En.GenNoC.plsda, validation = 'Mfold', folds = 2, progressBar = TRUE, nrepeat = 10)

But keep returning the following error:

Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent

Here is the code I had used to transform my filtered data to plsda format:

En.GenNoC.plsda <- plsda(En.GenNoC.keep, SamplesNoC, logratio = 'CLR', ncomp = 8)

where X = En.GenNoC.keep, Y = SamplesNoC.

Below are the dimensions of X (genus reads per sample), which is a list:

> dim(En.GenNoC.keep)
[1] 8 433

> is.list(En.GenNoC.keep)
[1] TRUE

And Y is a factor of sample types with length 8:

> is.factor(SamplesNoC)
[1] TRUE

> length(SamplesNoC)
[1] 8

I am confused by the error message as length of dimnames would be 2 since there a set of dimnames each for the rows and columns:

> length(dimnames(En.GenNoC.keep))
[1] 2

> length(dimnames(En.GenNoC.keep)[2])
[1] 1

There would be no dimnames(Y) as Y is a factor:

> length(dimnames(SamplesNoC))
[1] 0

I had compared my code and data format to the Koren PLS-DA example from the mixOmics workshop and could not find anything different. By the simplicity of the error message, I am probably overlooking something simple, but I’m at a loss as to what needs to be done so I’d appreciate any advice possible.

Thanks very much!

Hi @dscheah,

Thanks for using mixOmics.

Please note that PLSDA is not a data format, but a supervised discriminant model which takes a numeric matrix as X (while your example provides a list). The output of this model is a mixo_plsda (formerly known as plsda) object. The perf function then takes this object and assesses the performance of the PSLDA model.

You can always refer to ?mixOmics::perf.mixo_plsda and go over the Arguments section thoroughly.

Hope it helps

Al

Hi @aljabadi,

Thanks for your reply. I converted the X object into a matrix but got the same error when assessing the PLSDA model using the perf() function:

En.GenNoC.keepMatrix <- as.matrix(En.GenNoC.keep)
is.matrix(En.GenNoC.keepMatrix)
[1] TRUE

En.GenNoC.plsda <- plsda(En.GenNoC.keepMatrix, SamplesNoC, logratio = 'CLR', ncomp = 8)
En.GenNoC.plsda.perf <- perf(En.GenNoC.plsda, validation = 'Mfold', folds = 2, progressBar = TRUE, nrepeat = 10)
Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent

The reason I had kept the X object as a list because the Koren example I was following for PLSDA also had the X object as a list:

> is.matrix(Koren.16S$data.raw)
[1] FALSE
> is.list(Koren.16S$data.raw)
[1] TRUE

Koren.plsda <- plsda(Koren.16S$data.raw, Koren.16S$bodysite, logratio = 'CLR', ncomp = 10)
Koren.perf.plsda <- perf(Koren.plsda, validation = 'Mfold', folds = 5, progressBar = TRUE, nrepeat = 10)

I’m not sure if I’ve misunderstood the original example or made a mistake in my code…

Thanks very much for your time!

Hi @dscheah,

Thanks for the followup.

I can certainly look into the issue if I can reproduce it on my side. You’re welcome to send us an email with the script and data.

Best wishes,

Al

Hi @aljabadi,

Yes, I can certainly send you my scripts and related data, as well as the scripts I had reproduced when working through the Koren.16S example dataset. I couldn’t find an email address on the website – where should I send my message to?

Hi @dscheah,

You can click on this blue text to send us an email.
Alternatively, you can right-click on the above text and choose ‘Copy Email Address’.

Best wishes,

Al

Hi @aljabadi, thanks for letting me know. I’ll compile the script and data and forward them to you asap.

Thanks!