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

unable to find an inherited method for function ‘imgRaster’ for signature ‘"VisiumV1"’ #5128

Closed
Prakrithi-P opened this issue Sep 24, 2021 · 13 comments

Comments

@Prakrithi-P
Copy link

Hi,
I am working with ST data from https://www.10xgenomics.com/resources/datasets/human-cerebellum-targeted-neuroscience-panel-1-standard-1-2-0 .

When I run SpatialFeaturePlot() , I get the following error:
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘imgRaster’ for signature ‘"VisiumV1"’

Also when I try out the data given in the vignette,

InstallData("stxBrain")
trying URL 'http://seurat.nygenome.org/src/contrib/stxBrain.SeuratData_0.1.1.tar.gz'
Content type 'application/octet-stream' length 110346050 bytes (105.2 MB)

downloaded 1.5 MB

Error in download.file(url, destfile, method, mode = "wb", ...) :
download from 'http://seurat.nygenome.org/src/contrib/stxBrain.SeuratData_0.1.1.tar.gz' failed
In addition: There were 38 warnings (use warnings() to see them)
Warning in download.packages(pkgs, destdir = tmpd, available = available, :
download of package ‘stxBrain.SeuratData’ failed
Error in loadNamespace(name) :
there is no package called ‘stxBrain.SeuratData’

Help with any of the above issues would be great for me to start with ST data analysis.

Thanks,
Prakrithi

@Dimitri-Sid
Copy link

I also have this issue - any luck with solving it?

SpatialFeaturePlot(S3A, features = c("TOP2A"))
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘imgRaster’ for signature ‘"VisiumV1"’

@suhaibMo
Copy link

I came across a similar error when running SpatialFeaturePlot. As I understand the imgRaster function is inherited from SpatialExperiment package. You may need to uninstall this package to avoid any inheritance . This works

remove.packages('SpatialExperiment')

@lmweber
Copy link

lmweber commented Oct 27, 2021

Hi all, I am one of the developers of SpatialExperiment.

I tried to reproduce this just now on one of the Seurat examples, and did not get the error.

Maybe it is related to an older version of SpatialExperiment. Could you please let me know the version of SpatialExperiment you are using with sessionInfo()? Or alternatively try installing the latest version with remotes::install_github("drighelli/SpatialExperiment") (or from Bioconductor devel) and let me know if it works.

Thanks!

@Dimitri-Sid
Copy link

I came across a similar error when running SpatialFeaturePlot. As I understand the imgRaster function is inherited from SpatialExperiment package. You may need to uninstall this package to avoid any inheritance . This works

remove.packages('SpatialExperiment')

unistalling SpatialExperiment and reinstalling Seurat worked for me!

@allyhawkins
Copy link

I too am having this error. Uninstalling SpatialExperiment does the trick, but even when using the latest version on github, I still get this error when trying to create a spatialFeaturePlot() @lmweber.

I have attached my session info for reference.

Screen Shot 2021-11-22 at 3 36 46 PM

@lmweber
Copy link

lmweber commented Feb 3, 2022

Hi all, just following up since this issue came up again in discussions today.

I have tried to reproduce the error using the Seurat spatial vignettes, but those examples all seem to work fine for me.

Does anyone have an example / some code where this error occurs? This would be very helpful for tracking it down, and I would definitely like to help figure it out if this is still causing problems for people. (I had previously assumed it was related to older versions of Seurat / SpatialExperiment only, but it seems this may not be the case.)

@jaredslosberg
Copy link

This is still an issue for me, on R 4.1.2, Seurat 4.1.0, and SpatialExperiment 1.4.0.

If SpatialExperiment is loaded, I get the same error as everyone above.

Following the vignette at https://satijalab.org/seurat/articles/spatial_vignette.html, I get this error:

> SpatialFeaturePlot(brain, features = "nCount_Spatial") + theme(legend.position = "right")
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘imgRaster’ for signature ‘"VisiumV1"’
In addition: Warning message:
`guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead. 

And here is my session info (with SpatialExperiment loaded)
image

And here is the traceback:

31: stop(gettextf(“unable to find an inherited method for function %s for signature %s”, 
    sQuote(fdef@generic), sQuote(cnames)), domain = NA)
30: (function (classes, fdef, mtable) 
  {
    methods <- .findInheritedMethods(classes, fdef, mtable)
    if (length(methods) == 1L) 
      return(methods[[1L]])
   ...
29: imgRaster(x)
28: dim(x)
27: dim(x)
26: ncol(x = image)
25: data.frame(x = c(0, ncol(x = image)), y = c(0, nrow(x = image)))
24: transform_position(data, panel_params$x$rescale, panel_params$y$rescale)
23: f(...)
22: coord$transform(data.frame(x = c(0, ncol(x = image)), y = c(0, 
    nrow(x = image))), panel_scales)
21: f(...)
20: (structure(function (...) 
  f(...), class = “ggproto_method”))(data, panel_params, coord, 
    image = new(“VisiumV1”, image = structure(c(0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0.43921568627451, 0.901960784313726, 0.894117647058824, 
    0.905882352941176, 0.905882352941176, 0.909803921568627, 
   ...
19: do.call(self$draw_panel, args)
18: FUN(X[[i]], ...)
17: lapply(split(data, data$PANEL), function(data) {
    if (empty(data)) 
      return(zeroGrob())
    panel_params <- layout$panel_params[[data$PANEL[1]]]
    do.call(self$draw_panel, args)
   ...
16: f(..., self = self)
15: self$geom$draw_layer(data, self$computed_geom_params, layout, 
    layout$coord)
14: f(..., self = self)
13: l$draw_geom(d, layout)
12: (function (l, d) 
  l$draw_geom(d, layout))(dots[[1L]][[1L]], dots[[2L]][[1L]])
11: mapply(FUN = f, ..., SIMPLIFY = FALSE)
10: Map(function(l, d) l$draw_geom(d, layout), plot$layers, data)
9: ggplot_gtable.ggplot_built(ggplot_build(x))
8: ggplot_gtable(ggplot_build(x))
7: ggplotGrob(x)
6: plot_table.ggplot(X[[i]], ...)
5: FUN(X[[i]], ...)
4: lapply(x$plots, plot_table, guides = guides)
3: build_patchwork(plot, plot$layout$guides %||% “auto”)
2: print.patchwork(x)
1: (function (x, ...) 
  UseMethod(“print”))(x)

@lmweber
Copy link

lmweber commented Feb 3, 2022

Ok thanks. After looking through the Seurat and SpatialExperiment code some more now, I think this is related to the fact that both Seurat and SpatialExperiment have a class called SpatialImage. So if both packages are installed, Seurat is trying to use the wrong SpatialImage.

Not sure what the best solution is yet, but will think about it some more. Thanks for raising it.

@lmweber
Copy link

lmweber commented Feb 3, 2022

Yes, I think this is due to both packages having a class called SpatialImage, which is an unfortunate coincidence.

So R is probably choosing which class to use depending on which order the two packages are loaded with library(), which is also why this error is only happening sometimes and not other times.

We will discuss this some more to try to find a solution. Thanks all for your comments.

@HelenaLC
Copy link

HelenaLC commented Feb 24, 2022

For completeness @lmweber, I could reproduce the error as follows:

suppressPackageStartupMessages({
    library(Seurat)
    library(SeuratData)
    library(SeuratObject)
    library(SpatialExperiment)
})

if (!"stxBrain" %in% InstalledData()$Dataset)
    InstallData("stxBrain")
data("anterior1")

SpatialFeaturePlot(
    object = anterior1, 
    features = rownames(anterior1)[1])

> Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘imgRaster’ for signature ‘"VisiumV1"’

We will push a fix on the SpatialExperiment-end shortly.

@lmweber
Copy link

lmweber commented Mar 1, 2022

This has now been addressed in the latest update to the SpatialExperiment package. We renamed our SpatialImage class to VirtualSpatialImage, so now there is no longer a clash with the SpatialImage class name in Seurat.

The update is available in SpatialExperiment version 1.5.3, which can be installed from GitHub. This version is now going through the Bioconductor build system, so should also be available via Bioc-devel from later this week onwards (Wed or Thu).

Additional details in the SpatialExperiment repo here and here.

Thanks all for your feedback! Glad we were able to figure this out.

@lmweber
Copy link

lmweber commented Mar 3, 2022

Quick follow-up to say that SpatialExperiment version 1.5.3 is now available via Bioc-devel (Bioconductor version 3.15), as well as GitHub, so this issue should now be resolved.

@dcollins15
Copy link
Contributor

Thanks for using Seurat!

It appears that this issue has gone stale. In an effort to keep our Issues board from getting more unruly than it already is, we’re going to begin closing out issues that haven’t had any activity since the release of v4.4.0.

If this issue is still relevant we strongly encourage you to reopen or repost it, especially if you didn’t initially receive a response from us.

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

8 participants