stuart-lab / signac

R toolkit for the analysis of single-cell chromatin data
https://stuartlab.org/signac/
Other
317 stars 85 forks source link

Solution for errors related to `as_cholmod_sparse ` or `CRsparse_rowSums` #1596

Open timoast opened 8 months ago

timoast commented 8 months ago

Following a recent update to the Matrix package, several users have reported errors related to functions that use methods from the Matrix package. These will typically result in error messages like: 'as_cholmod_sparse' not provided by package 'Matrix' or object 'CRsparse_colSums' not found.

Here is a list of relevant issues:

https://github.com/stuart-lab/signac/issues/1559 https://github.com/stuart-lab/signac/issues/1591 https://github.com/stuart-lab/signac/issues/1528 https://github.com/stuart-lab/signac/issues/1530 https://github.com/stuart-lab/signac/issues/1532 https://github.com/stuart-lab/signac/issues/1547

Cause

This is caused by a new version of Matrix removing certain S4 classes. Packages that used certain S4 methods from Matrix (such as irlba, TFBSTools, and Seurat) subsequently encounter errors. This is because the S4 methods are cached when the R package is built, rather than loaded in the R session. The solution is to re-build the impacted packages from source with the updated Matrix package installed. More information can be found here

Solutions

'as_cholmod_sparse' not provided by package 'Matrix'

To resolve this issue re-install the irlba package from source:

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

object 'CRsparse_colSums' not found

To resolve this issue re-install the TFBSTools package as described in this Seurat issue: https://github.com/satijalab/seurat/issues/8202

BiocManager::install("TFBSTools", type = "source", force = TRUE)
realmungmung commented 7 months ago

I installed irlba as suggested but still got the error: Error in irlba(A = t(x = object), nv = n, work = irlba.work, tol = tol) : function 'as_cholmod_sparse' not provided by package 'Matrix'

timoast commented 7 months ago

@realmungmung from your other issue you posted:

after installation in R, it also showed in the R console:
1: In install.packages("SeuratObject", type = "source") :
installation of package ‘Matrix’ had non-zero exit status
2: In install.packages("SeuratObject", type = "source") :
installation of package ‘SeuratObject’ had non-zero exit status
In install.packages("irlba", type = "source") :
installation of package ‘irlba’ had non-zero exit status

So these packages are not actually installed. You need to successfully install the packages from source.

bhanco commented 4 months ago

Any tips for how to fix this if you are loading R studio in an interactive session on quest. From a conda environment? I can't run the install.packages commands with a conda built environment.

JHCCoder commented 4 months ago

@bhanco Have you downloaded R-base in your conda environment? If so you should be able to use install.packages after you start your R environment by entering R in your command line.

bhanco commented 3 months ago

@JHCCoder Wow it wouldn't work when I ran in rstudio but when I ran it from command line it fixed and now I can run through in rstudio. Thanks so much!

JamesGallant commented 2 months ago

Hi,

I've been having issues with this as well, specifically runChromVar and have tried the solutions already presented. Everything else runs fine and the issue also persists when following the motif tutorial on Signac using the PBMCs.

I get the object 'Error in .local(x, na.rm, dims, ...): object 'CRsparse_colSums' not found error on runChromVar and I have tried the following

Checking colSums like this works, I dont recieve a error but once I runChromVar I see the error again. Found here: https://github.com/satijalab/seurat/issues/8202#issue-2047511055

library(Matrix)

colSums(m)
TFBSTools::colSums(m)
colSums(m)

R version is 4.3.3 Bioconductor version 3.18 Matrix version: 1.6.5 TFBSTools version 1.40.0 Signac: 1.13.0 Seurat: 5.1.0

Any help will be great, or a alternative methd to visualise motif accessibility would work as well.

Thanks

timoast commented 2 months ago

@JamesGallant Try updating Matrix, then re-installing TFBSTools from source using the command above, then restart R

JamesGallant commented 2 months ago

@timoast Thanks your suggestion helped me to get it working. I realised that TBFSTtools was not installing properly and needed to run Rstudio in administrator mode on windows.

P.S. for others: This worked for me for version 4.3.3 but not in the latest R version and matrix version. Installing TBFSTtools in version 4.4 of R with matrix at 1.7 will cause errors. R version 4.3.3 and matrix version 1.6.5 works.