For some reason, I could not submit this issue on github…
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')"
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
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.
I am completely unable to reproduce your issue. Please run the following code and post a reprex of the results:
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)
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:
library(mixOmics)
> 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,
Stef
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:
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.
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
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.