Seurat functions throwing error messages due to conflicting packages

I have ran these functions hundreds of times and have never seen this error before. They are related to the Seurat package for Single Cell RNA seq analysis. The errors occurred after i downloaded a different package related to the analysis (Scran). Since then I have removed the package, redownloaded Seurat, redownloaded its dependencies, updated and redownloaded R, and nothing has fixed it. I am 99% sure it isn't the function itself as I am using it in exactly the same fashion i have been. Its possible that i haven't tried every possible package to uninstall and reinstall, but what I'm looking for is how do I actually troubleshoot this. Please help I am lost.

A_Forced_Rice4_fil <- Seurat::CreateSeuratObject(counts = A_Forced_cellranger.data2, project = "Rice_SC_A4", min.cells = 3, min.features = 300)
Error in validObject(.Object) : 
  invalid class “LogMap” object: superclass "mMatrix" not defined in the environment of the object's class

For added context, this also happens when I load Seurat now. I have redownloaded SeuratObject 3 times now

library(Seurat)
Loading required package: SeuratObject
Loading required package: sp

Attaching package: ‘sp’

The following object is masked from ‘package:IRanges’:

    %over%

‘SeuratObject’ was built under R 4.3.0 but the current version is 4.3.1; it is recomended that you
reinstall ‘SeuratObject’ as the ABI for R may have changed
‘SeuratObject’ was built with package ‘Matrix’ 1.6.1.1 but the current version is 1.6.2; it is recomended
that you reinstall ‘SeuratObject’ as the ABI for ‘Matrix’ may have changed

Attaching package: ‘SeuratObject’

The following object is masked from ‘package:SummarizedExperiment’:

    Assays

The following object is masked from ‘package:GenomicRanges’:

    intersect

The following object is masked from ‘package:GenomeInfoDb’:

    intersect

The following object is masked from ‘package:IRanges’:

    intersect

The following object is masked from ‘package:S4Vectors’:

    intersect

The following object is masked from ‘package:BiocGenerics’:

    intersect

The following object is masked from ‘package:base’:

    intersect


Attaching package: ‘Seurat’

The following object is masked from ‘package:SummarizedExperiment’:

    Assays
1 Like

I can reproduce the problem on my computer, it has been reported here.

You can temporarily solve it by downgrading {Matrix}:

devtools::install_version("Matrix",version = "1.6.1.1")

ultimately I expect the Seurat maintainers to update SeuratObject to solve that.

One side-note:

One thing that is weird to me, the warning messages mention you are using R4.3.0, but the latest version is 4.3.2. That suggests something is wrong with your redownloads/reinstalls of R. Maybe you correctly reinstalled the latest version of R but RStudio missed it, that has happened to me in the past, you can use this to ensure you are indeed loading R 4.3.2.

So i had tried this and received this error. Sorry i think some of this error message is missing, as I am in the process of redownloading both R and rStudio to see if that solves it. I saw this fix as well and believe it will solve the problem but unfortunately because of this error message I couldn't try it.

devtools::install_version("Matrix",version = "1.6.1.1")

ld: warning: directory not found for option '-L/opt/gfortran/lib/gcc/x86_64-apple-darwin20.0/12.2.0'
ld: warning: directory not found for option '-L/opt/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Matrix.so] Error 1
ERROR: compilation failed for package ‘Matrix’
* removing ‘/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Matrix’
here is more context to the error

Warning message:
In i.p(...) :
  installation of package ‘/var/folders/8_/hq65blf10w50978zt96924340000gn/T//RtmpSXkT3t/remotes99f07fc9574f/Matrix’ had non-zero exit status

Right, that's because you need the fortran compiler. The instructions for Mac are here, you need Xcode and the GNU FORTRAN compiler. Feel free to open a new topic to get help from people who know Mac (I don't).

More details: packages are created as a "source" version, then need to be compiled to run (if they contain FORTRAN or C code). When you install the latest version of a package, usually CRAN has a pre-compiled version available. For older version of packages, CRAN might delete the precompiled version and only keep the source version, so you might need to recompile them yourself (depends on the package). The process is automated in devtools::install_version(), but it requires the C and FORTRAN compilers to be installed on the system.

Just to be clear, this is not directly related to the original problem, the Seurat problem will be solved with Matrix 1.6.1.1, but the FORTRAN compiler is necessary to install this older package.

Thank you so much for your help.

1 Like

I have this exact same issue, brand new and started appearing out of nowhere. Did you find a fix?

@ninkisa Have you tried running this?

1 Like

Hi,
Maybe try removing existing 'Matrix' package, with remove.packages('Matrix').
Then install it via this-
remotes::install_version("Matrix", version = "1.6.1.1")

This should solve it.

1 Like

Thank you both for these suggestions, I realized my installation of gcc/gfortran was the issue. I manually re-installed the package through the link that AlexisW provided earlier, and then reinstalled the Matrix package, and now the problem appears to be resolved.

Yes, likely it was related to compilers. Had a similar problem in R within a conda environment.
What seemed to help was

conda install -c conda-forge cxx-compiler

this was giving some warnings about downgrading compilers, including C++ and Fortran.
Finally Seurat works OK. Matrix version is 1.6-3

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.