Warning in selectCompNum.pls(model, selcrit = ncomp.selcrit) : No validation results were found

For some reason, I could not submit this issue on github…

:lady_beetle: Describe the bug:

pca.result ← pca(data_auto)
plotIndiv(pca.result, group =meta$Clean.colon, title = ‘PCA’, ind.names = FALSE, legend = T)
Error in round(inf, 2) : non-numeric argument to mathematical function
MyResult.plsda <- plsda(X,Y, ncomp=5) Warning in selectCompNum.pls(model, selcrit = ncomp.selcrit) : No validation results were found. plotIndiv(MyResult.plsda) Error in UseMethod("plotIndiv") : no applicable method for 'plotIndiv' applied to an object of class "c('plsda', 'classmodel', 'pls', 'regmodel')"

:mag: reprex results from reproducible example including sessioninfo():

R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.0.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] mdatools_0.12.0 knitr_1.37 doSNOW_1.0.19 snow_0.4-4 iterators_1.0.13 foreach_1.5.1
[7] devtools_2.4.3 usethis_2.1.5 mixOmics_6.19.1 ggplot2_3.3.5 lattice_0.20-45 MASS_7.3-54
[13] sessioninfo_1.2.2

loaded via a namespace (and not attached):
[1] ggrepel_0.9.1 Rcpp_1.0.8.3 tidyr_1.2.0 corpcor_1.6.10 prettyunits_1.1.1
[6] ps_1.6.0 rprojroot_2.0.2 assertthat_0.2.1 digest_0.6.29 utf8_1.2.2
[11] RSpectra_0.16-0 R6_2.5.1 plyr_1.8.7 ellipse_0.4.2 pillar_1.7.0
[16] rlang_1.0.2 curl_4.3.2 callr_3.7.0 Matrix_1.3-4 desc_1.4.0
[21] rARPACK_0.11-0 BiocParallel_1.28.3 stringr_1.4.0 igraph_1.3.0 munsell_0.5.0
[26] compiler_4.1.2 xfun_0.29 pkgconfig_2.0.3 pkgbuild_1.3.1 htmltools_0.5.2
[31] tidyselect_1.1.2 tibble_3.1.6 gridExtra_2.3 codetools_0.2-18 matrixStats_0.61.0
[36] fansi_1.0.3 crayon_1.5.1 dplyr_1.0.8 withr_2.5.0 grid_4.1.2
[41] gtable_0.3.0 lifecycle_1.0.1 DBI_1.1.2 magrittr_2.0.3 scales_1.1.1
[46] cli_3.2.0 stringi_1.7.6 cachem_1.0.6 reshape2_1.4.4 remotes_2.4.2
[51] fs_1.5.2 testthat_3.1.1 ellipsis_0.3.2 generics_0.1.2 vctrs_0.4.0
[56] RColorBrewer_1.1-3 tools_4.1.2 glue_1.6.2 purrr_0.3.4 processx_3.5.2
[61] pkgload_1.2.4 parallel_4.1.2 fastmap_1.1.0 colorspace_2.0-3 memoise_2.0.1

:thinking: Expected behavior:

I ran the precise same code at the beginning of the week and it worked. The only thing I can think of being different is that I loaded the caret library. But even unloading that and re-installing mixomics with
install_github("mixOmicsTeam/mixOmics", ref = github_pull("176")) did not solve the issue

:bulb: Possible solution:

I have none.

Thank you very much for the heads up @stepra. I’ll look into this today. If I’m unable to reproduce it, I can look at your data specifically (if it is allowed to be distributed) and we can work through this together.

Thank you @MaxBladen . How did it go?

I am completely unable to reproduce your issue. Please run the following code and post a reprex of the results:

X <- srbct$gene
Y <- srbct$class
pca.result <- pca(X)
plotIndiv(pca.result, group = c(rep(1, 20), rep(2, 20), rep(3, 23)), title = "PCA", ind.names = FALSE, legend = T)
MyResult.plsda <- plsda(X,Y, ncomp=5)

If you don’t receive the same errors/warnings, then this is an issue with your data. When it states non-numeric argument to mathematical function, there may be large amounts of 0s in your data, low variance or highly irregular distributions.

I believe the function which is raising the error isselectCompNum.pls(). This is a function from one of our dependencies (mdatools). This may make resolving your issue a bit trickier.

Send back the output of that code above and we’ll go from there.


Thank you, Max!
Unfortunately, I get the same error with your data and I have the same issue whether I run on my local computer or our server. Here is the output from my labtop:

> data(srbct)
> X <- srbct$gene
> Y <- srbct$class
> pca.result <- pca(X)
> plotIndiv(pca.result, group = c(rep(1, 20), rep(2, 20), rep(3, 23)), title = "PCA", ind.names = FALSE, legend = T)
Error in round(inf, 2) : non-numeric argument to mathematical function
> session_info()
─ Session info ──────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.1.2 (2021-11-01)
 os       macOS Monterey 12.3.1
 system   x86_64, darwin17.0
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Stockholm
 date     2022-04-26
 rstudio  1.4.1717 Juliet Rose (desktop)
 pandoc   2.11.4 @ /Applications/RStudio.app/Contents/MacOS/pandoc/ (via rmarkdown)

I really hope we can solve this. I am presenting at a conference in May and was hoping to include the results.
All the best,

We will figure this out in time for your presentation. Here’s my thinking so far. Within the plotIndiv.pca() function, if we navigate to line 110-112, we are trying to round the proportion of variance explained (inf) to 2 decimal points. We are apparently passing a non-numerical value to this call of the round() function.

As a first step, please ensure that you have fully updated R and mixOmics. I can see that you are not running the latest version of the Mac OS R. This is the most likely cause of this issue and requires no further work to resolve it.

Assuming that this is not the cause, I have two hypotheses:

  1. Something is going wrong in the pca() function which results in non-numeric values being stored in pca.object$prop_expl_var$X. Hence, to confirm/deny this as the cause, please report the printed values from your machine when you run pca.object$prop_expl_var$X. Please do this for both the example code I provided as well as with your data. If we see non-numeric values reported, we know where the issue is arising.
  2. Seeing as on my machine (Windows 10), I receive no error but you do on Mac machines, I wonder if this is caused by a difference in the way that the two different OS’s encode floating point values. If you have access to a Windows machine, please try running the code I provided on this machine to see if it also fails (ensure it is running the latest versions of R and mixOmics). Alternatively, set up a free account in RStudio Cloud (via your browser) and run the same code there.

Let me know how you go with these. I’m sure we’ll get to the bottom of this soon.


Dear Max,
Thank you for getting back to me.
For point 1 I assume you mean pca.result$ ![Screenshot 2022-04-27 at 07.57.46|455x500](upload://nHg3WeB5eEofJewkVnVcqyJ3FAH.png) $X? That returns NULL in both cases. So the issue seems to lie there.
For point 2. I do not have access to a Windows machine. But this may not be necessary since it seems like sth is wrong with the pca function? I attach my pca.result as looking at it, I do see numbers but I do not see a prop_expl_var

Here you can see what it looks like under res

Dear @MaxBladen,
Do you have any idea what the issue is?
Best wishes,

I thought that this was an issue with one of our dependcies. Rather, you are using the mdatools package function rather than the mixOmics version of pca(). Ensure you use the call mixOmics::pca() rather than just pca(). Once you make this adjustment, your code will work as intended

For future issues like this, please make sure you check the mixOmics documentation as that would have instantly told you that you aren’t using the function from our package.