Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Found more than one class "dist" in cache #121

Closed
AndiMunteanu opened this issue Apr 5, 2024 · 4 comments
Closed

Found more than one class "dist" in cache #121

AndiMunteanu opened this issue Apr 5, 2024 · 4 comments

Comments

@AndiMunteanu
Copy link

Hello!

Thank you for creating and mantaining this very useful package!
I noticed this warning that pops up when creating the UMAP:
Found more than one class "dist" in cache; using the first, from namespace 'BiocGenerics' Also defined by 'spam'

This is an example that could help reproduce the problem:

library(BiocGenerics)
library(spam)
library(uwot)
uwot::umap(matrix(runif(300), ncol = 10))

The spam package is usually loaded together with Seurat and BiocGenerics with rhdf5, so at least in my use-case I can't avoid getting this warning.
I think that this warning is caused by an ambiguous definition of the dist class in the neghbors.R and uwot.R files, more precisely on these lines:

if (methods::is(X, "dist")) {

uwot/R/uwot.R

Line 3204 in 3bff01f

} else if (methods::is(X, "dist")) {

uwot/R/uwot.R

Line 4266 in 3bff01f

} else if (methods::is(X, "dist")) {

Replacing "dist" with "stats::dist" in these lines should fix this issue.

Thank you!

@jlmelville
Copy link
Owner

Thanks for letting me know about this. Unfortunately, the proposed fix doesn't quite work.

diris <- stats::dist(iris[1:10, -5])

methods::is(diris, "dist")
[1] TRUE

methods::is(diris, "stats::dist")
[1] FALSE

This may require some research.

@AndiMunteanu
Copy link
Author

Thank you for the very quick response!
You are right, sorry for suggesting a wrong solution!

Would replacing methods::is with inherits or something more custom (like attributes(diris)$class == "dist") keep the code consistent and remove the warning?

jlmelville added a commit that referenced this issue Apr 6, 2024
@jlmelville
Copy link
Owner

inherits seems to do the trick. Thank you for the suggestion. A fix has been pushed to master and this should be in the next CRAN release.

@AndiMunteanu
Copy link
Author

Thank you very much, your work is much appreciated!
I will close this issue, since the problem was fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants