Invalid class "Graph" object: superclass "mMatrix" not defined (Seurat/R)

1.6k views Asked by At

I am using Seurat for my RNAseq analysis and have been using the same code for over a month now (without issues). FindNeighbors gives an error now (out of the blue) and I can't seem to fix it. The data and code are the same as before.

all.integrated <- all.integrated %>%
  FindNeighbors(reduction = "harmony", dims = 1:30) %>%
  FindClusters(reduction = "harmony", resolution = 0.1) %>%
  RunUMAP(reduction = "harmony", dims=1:30)


> Computing nearest neighbor graph
> Computing SNN
> Error in validObject(.Object) : 
invalid class “Graph” object: superclass "mMatrix" not defined in 
the environment of the object's class

I've checked the class and it is a SeuratObject. The only thing that worked yesterday was deleting and re-installing R and R studio (restart R wouldn't help), but now it gives the same error. What to do?

Many thanks!!

2

There are 2 answers

5
csgroen On

I was having the same problem just now. According to this bug report in the Seurat Github page, it looks like the problem is coming from the new version of the Matrix package (1.6.2).

Downgrading to Matrix v1.6.1 resolved it for me:

remotes::install_version("Matrix", "1.6.1")
3
Mikael Jagan On

You must re-install SeuratObject <= 5.0.0 from sources after changing between Matrix < 1.6-2 and Matrix >= 1.6-2.

install.packages("SeuratObject", type = "source")

SeuratObject 5.0.1 has Imports: Matrix (>= 1.6-3) so another option is simply to update SeuratObject.