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

FindNeighbors not work in Seurat 4.0.0 but work well in Seurat 3.2.3. #4263

Closed
RuzhangZhao opened this issue Mar 22, 2021 · 6 comments
Closed
Labels
bug Something isn't working

Comments

@RuzhangZhao
Copy link

I just updated Seurat to the newest version, but found FindNeighbors does not work for my current case. Therefore, I tested several datasets, including the example data from Seurat website. The FindNeighbors function still not work. I also tried to export the pca matrix out and directly fed into FindNeighbors function. It will not work in as.matrix version or as.data.frame version.

By the way, I use mac under macOS 10.15.4, R studio with R version 4.0.4, Seurat 4.0.0. The code example below use the provided data from Seurat website pbmc3k guided tutorial.

If I follow the below codes, the output will be

Computing nearest neighbor graph
Error: node stack overflow
Error during wrapup: node stack overflow
Error: no more error handlers available (recursive errors?); invoking 'abort' restart

If I directly feed matrix into FindNeighbors, (previously works well for me) the output is the same as above.
If I directly feed data.frame into FindNeighbors,(previously works well for me) it will report

Computing nearest neighbors
Error in a$addItem(ii - 1, data[ii, ]) : 
  Not compatible with requested type: [type=list; target=double].
# insert reproducible example here
library(dplyr)
library(Seurat)
library(patchwork)
expr<- Read10X(data.dir = "filtered_gene_bc_matrices/hg19/")
expr<-CreateSeuratObject(expr)
expr<- NormalizeData(expr)
expr<-FindVariableFeatures(expr)
expr<-ScaleData(expr)
expr<-RunPCA(expr, features = VariableFeatures(object = expr))
expr <- FindNeighbors(expr, dims = 1:10)
@RuzhangZhao RuzhangZhao added the bug Something isn't working label Mar 22, 2021
@RuzhangZhao
Copy link
Author

I think I found the reason. Once I load package Rfast, the error message will appear. There may be some conflict between newly updated Seurat and Rfast. Hope this can help you to reproduce the error message.

@NMikolajewicz
Copy link

I've started receiving this error message recently. Any progress in resolving it? In my case it doesn't seem to be related to Rfast.

@RuzhangZhao
Copy link
Author

Hi Nicholas. Previously, I had a list of packages. I excluded each one of them from the list by order and tried to use the Find Neighbor function. Finally, my case is that if I excluded Rfast, it will work. Would you mind sharing your case? I think that might help the team to resolve the problem.

@NMikolajewicz
Copy link

Here is my script:

`
packages2load <- c("Seurat", "scater", "scMiko", "reticulate", "destiny", "foreach", "doParallel", "clusterExperiment",
"plyr", "dplyr", "tidyr", "reshape2", "tidyverse", "RColorBrewer", "ggplot2", "gridExtra",
"DT", "flexdashboard", "ggpmisc", "ggpmisc", "ggExtra", "grid", "ggrepel", "scales", "ggformula",
"tidymodels", "viridis", "future", "diffusr", "markovchain", "Tempora", "s2a", "glue")

load packages

invisible({lapply(packages2load, library, character.only = TRUE)})

process expresion matrix

so.wgcna <- Seurat::CreateSeuratObject(counts = mat.data)
so.wgcna <- Seurat::ScaleData(so.wgcna)
so.wgcna <- Seurat::RunPCA(so.wgcna, features = rownames(so.wgcna), weight.by.var = F)
so.wgcna <- Seurat::FindNeighbors(so.wgcna, k.param = 5, features = rownames(so.wgcna), reduction = "pca")
so.wgcna <- Seurat::RunUMAP(so.wgcna, dim = 1:50, n.neighbors = 10, min.dist = 0.001, metric = "cosine")`

@NMikolajewicz
Copy link

Hi again. I managed to resolve the problem by changing nn.method from "annoy" to "rann". Seemed to be related to the "annoy" method in my case.

@RuzhangZhao
Copy link
Author

Hi Nicholas. Thanks so much! That also works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants