Closed RyanSchubert closed 5 years ago
What version of Seurat are you using?
Seurat_2.3.4
I can't reproduce this. Can you try running the code line by line:
s = singler
s$seurat = SubsetData(s$seurat,colnames(s$seurat@data)[subsetdata])
subsetdata = unlist(lapply(s$seurat@cell.names,FUN=function(x)
which(singler$singler[[1]]$SingleR.single$cell.names==x)))
for (i in 1:length(s$singler)) {
s$singler[[i]]$SingleR.single$labels =
as.matrix(s$singler[[i]]$SingleR.single$labels[subsetdata,])
}
Hmm, same error Error in s$singler[[i]]$SingleR.single$labels[subsetdata, ] : incorrect number of dimensions
Could it be the number of cells we are analyzing? >100,000 cells?
Ok. I have a guess, though not sure where is the mistake in the code. Your object was created using SingleR.Combine, right? I'm guessing that for some reason singler$singler[[i]]$SingleR.single$labels is not a matrix [n.cells X 1]. Try this:
for (i in 1:length(singler$singler)) {
singler$singler[[i]]$SingleR.single$labels = as.matrix(singler$singler[[i]]$SingleR.single$labels)
}
and run the SingleR.Subset function again. Does this solve the issue? (might fail in another place)
You got it! I ended up iterating this over all the rest of the labels matrices:
for (i in 1:length(singler$singler)) { singler$singler[[i]]$SingleR.single$labels = as.matrix(singler$singler[[i]]$SingleR.single$labels) }
for (i in 1:length(singler$singler)) { singler$singler[[i]]$SingleR.single$labels1 = as.matrix(singler$singler[[i]]$SingleR.single$labels1) }
for (i in 1:length(singler$singler)) { singler$singler[[i]]$SingleR.single.main$labels = as.matrix(singler$singler[[i]]$SingleR.single.main$labels) }
for (i in 1:length(singler$singler)) { singler$singler[[i]]$SingleR.single.main$labels1 = as.matrix(singler$singler[[i]]$SingleR.single.main$labels1) }
Hi Dvir,
While running SingleR.Subset, I am getting below error. I am using Seurat_3.
Error in is.data.frame(x) : no slot of name "data" for this object of class "Seurat".
Initially was getting same error as Ryan but resolved that with your previous comments.
Thanks, Kinnari
Yes, sorry. I need to make some adjustments to that function to work with Seurat 3. The problem is that I didn't upgrade Seurat yet on my computer, so its a bit hard to test...
I will try to work around by using your SingleR.Subset function.
Until I make the change, don't send the function the seurat object (singler$seurat = NULL) and subset it independently.
Yup sure. Thanks for quick response. It's great tool
Hi Dvir,
I had this working previously, but now when I run SingleR.Subset it thinks for a minute then I get:
Error in s$singler[[i]]$SingleR.single$labels[subsetdata, ] : incorrect number of dimensions
I've checked and I have the same number of cells in the SingleR and Seurat objects. Could this have to do with the way singleR stores list information for the labels?
Thanks for your attention!
Best,
Ryan