Seurat: SpatialFeaturePlot returning error

Created on 10 Mar 2020  Â·  14Comments  Â·  Source: satijalab/seurat

Hello,
I'm taking a look at the spatial data vignette and I am getting an error when running _SpatialFeaturePlot_ at the very beginning.
I had previously been able to run it successfully in the past weeks and have not changed anything major. I've tried to reinstall the package from github but its still not working.

The code I'm running is the one showed in the vignette

devtools::install_github("satijalab/seurat",` ref = "spatial", force = TRUE)
library(Seurat)
library(SeuratData) # devtools::install_github('satijalab/seurat-data')
library(ggplot2)
library(cowplot)
library(dplyr)

InstallData("stxBrain")
brain <- LoadData("stxBrain", type = "anterior1")
SpatialFeaturePlot(brain, features = "nCount_Spatial") + theme(legend.position = "right")

The error I'm getting is the following:
_Error in data[[features[j]]] : subscript out of bounds_

I've checked and nCount_Spatial exists in the metadata of the Seurat object.

Could you please point towards what may be happening?

Thank you very much,
Marc

bug

All 14 comments

I am having the same problem. I also tried to directly download the files from the 10X website rather than using the SeuratData function.

I am having the same problem. I also tried to directly download the files from the 10X website rather than using the SeuratData function.

Have also tried this and get the same error as well.

The problem is data is a matrix, so subsetting by feature does not work. Converting data to a data.frame in SpatialPlot fixes the issue.

How do you convert data to a data.frame?

@rtower1, I'm not a Seurat developer. But looks like a bug in the SpatialPlot function. This change in that function fixed it for me:

   rownames(x = data) <- colnames(x = object)
+  data <- as.data.frame(data)
   facet.highlight <- facet.highlight && (!is.null(x = cells.highlight) && is.list(x = cells.highlight))

When I gave this a try I got the following error:
rownames(x = data) <- colnames(x = object)
Error in rownames<-(*tmp*, value = c("AAACAAGTATCTCCCA-1", "AAACACCAATAACTGC-1", :
attempt to set 'rownames' on an object with no dimensions

Thanks for reporting! I just pushed a fix for this. Please try reinstalling the spatial branch.

I am trying to reinstall the package, but the reinstall in unsuccessful. The problem seems to be the package "glue". It needs to be compiled to install the spatial package, but it cannot be updated because it is in use by devtools to install the spatial package in the first place:

installing source package 'glue' ...
** package 'glue' successfully unpacked and MD5 sums checked
ERROR: cannot remove earlier installation, is it in use?
Error in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE)
Execution halted
Error: Failed to install 'Seurat' from GitHub:
(converted from warning) installation of package ‘glue’ had non-zero exit status

If I try to not update glue, the following error message comes up:
Error: package 'glue' does not have a namespace
Execution halted
ERROR: lazy loading failed for package 'Seurat'

I have also tried to delete the 00LOCK-glue folder and retry with the same results

I have also tried to manually move 00LOCK-glue\glue\libs\x64\glue.dll into the glue\libs\x64\glue.dll location, but the devtools no longer works

Hi,

Try starting a fresh R session to update glue/any other packages. ( R --vanilla)

Alternatively, you don't need all of devtools to install, just remotes so you could try remotes::install_github instead of devtools::install_github

I have restarted R and deleted all packages and tried to reinstall but nothing changed. I tried again from scratch using the remotes function and got the following message:

* arch - i386
Error in system(cmd) : (converted from warning) 'make' not found

  • removing 'C:/Users/Clemens Lab/Documents/R/win-library/3.6/Seurat'
    Error: Failed to install 'Seurat' from GitHub:
    (converted from warning) installation of package ‘C:/Users/CLEMEN~1/AppData/Local/Temp/RtmpAZkmyp/file191c34f568a9/Seurat_3.1.4.9902.tar.gz’ had non-zero exit status
    In addition: Warning message:
    In missing_devel_warning(pkgdir) :
    Package Seurat has compiled code, but no suitable compiler(s) were found. Installation will likely fail.
    Install Rtools (https://cran.r-project.org/bin/windows/Rtools/).Then use the pkgbuild package, or make sure that Rtools in the PATH.

I have the newest Rtools installed but I seem to require devtools for the find_rtools() function to work. Installing devtools after trying the spatial Seurat restores the glue compiling issue above.

@MarcElosua, I'm assuming the new code fixed the original issue but if not feel free to reopen.

@rtower1 If you're still having installation issues, please start a new issue.

Was this page helpful?
0 / 5 - 0 ratings