An error occurred while running GSVA
Thank you for developing such a useful tool. I ran into an error (no method or default for coercing “matrix” to “dMatrix”) when running the GSVA function. I found that this error only occurs when the version of the GSVA package is greater than 1.44.2. The following code is a minimal example of repeating the error. Looking forward to your reply.
1.44.2 GSVA
> packageVersion(pkg = "GSVA")
[1] ‘1.44.2’
> library(GSVA)
> library(Seurat)
>
> # load data
> data(pbmc_small)
> pbmc_small <- SeuratObject::UpdateSeuratObject(pbmc_small)
Validating object structure
Updating object slots
Ensuring keys are in the proper strucutre
Ensuring feature names don't have underscores or pipes
Object representation is consistent with the most current Seurat version
> my.matrix <- SeuratObject::GetAssayData(pbmc_small, assay = "RNA", slot = "data")
>
> # custom geneset
> markers <- list()
> markers$Tcell_gd <- c("TRDC+", "TRGC1+", "TRGC2+", "TRDV1+","TRAC-","TRBC1-","TRBC2-")
> markers$Tcell_NK <- c("FGFBP2+", "SPON2+", "KLRF1+", "FCGR3A+", "CD3E-","CD3G-")
> markers$Tcell_CD4 <- c("CD4","CD40LG")
> markers$Tcell_CD8 <- c("CD8A","CD8B")
> markers$Tcell_Treg <- c("FOXP3","IL2RA")
>
> ssgsea.scores <- GSVA::gsva(my.matrix,
+ gset.idx.list = markers,
+ method = "ssgsea",
+ kcdf = "Gaussian",
+ ssgsea.norm = F,
+ parallel.sz = 1, verbose = F)
[1] "Calculating ranks..."
[1] "Calculating absolute values from ranks..."
Warning messages:
1: In .local(expr, gset.idx.list, ...) :
Using 'dgCMatrix' objects as input is still in an experimental stage.
2: In .gsva(expr, mapped.gset.idx.list, method, kcdf, rnaseq, abs.ranking, :
Some gene sets have size one. Consider setting 'min.sz > 1'.
1.44.3 GSVA
> detach("package:GSVA", unload = TRUE)
> BiocManager::install("GSVA", force = T)
> packageVersion(pkg = "GSVA")
[1] ‘1.44.3’
> library(GSVA)
> ssgsea.scores <- GSVA::gsva(my.matrix,
+ gset.idx.list = markers,
+ method = "ssgsea",
+ kcdf = "Gaussian",
+ ssgsea.norm = F,
+ parallel.sz = 1, verbose = F)
[1] "Calculating ranks..."
[1] "Calculating absolute values from ranks..."
Error in as(es, "dMatrix") :
no method or default for coercing “matrix” to “dMatrix”
In addition: Warning messages:
1: In .local(expr, gset.idx.list, ...) :
Using 'dgCMatrix' objects as input is still in an experimental stage.
2: In .gsva(expr, mapped.gset.idx.list, method, kcdf, rnaseq, abs.ranking, :
Some gene sets have size one. Consider setting 'min.sz > 1'.
1.45.3 GSVA
detach("package:GSVA", unload = TRUE)
devtools::install_github("rcastelo/GSVA", force = T)
> packageVersion(pkg = "GSVA")
[1] ‘1.45.3’
> library(GSVA)
> ssgsea.scores <- GSVA::gsva(my.matrix,
+ gset.idx.list = markers,
+ method = "ssgsea",
+ kcdf = "Gaussian",
+ ssgsea.norm = F,
+ parallel.sz = 1, verbose = F)
[1] "Calculating ranks..."
[1] "Calculating absolute values from ranks..."
Error in as(es, "dMatrix") :
no method or default for coercing “matrix” to “dMatrix”
In addition: Warning messages:
1: In .local(expr, gset.idx.list, ...) :
Using 'dgCMatrix' objects as input is still in an experimental stage.
2: In .gsva(expr, mapped.gset.idx.list, method, kcdf, rnaseq, abs.ranking, :
Some gene sets have size one. Consider setting 'min.sz > 1'.
Yes, I know, a week ago the upstream package Matrix was updated to version 1.5-0, introducing the simultaneous deprecation and defunct of many coercion functions, such as the one that coerces an R base matrix to the dspMatrix and had to change the code to adapt to that, but that change wasn't backward compatible and I forgot to enforce that minimum version of the 'Matrix' package. So until I fix that, a quick solution for you should be to upgrade your version of the Matrix package to 1.5-x.
I haven't been able to introduce a backward compatibility fix, so I've updated the package to enforce the minimum version of this upstream dependency Matrix to 1.5-0. It should work once you update the Matrix package. Let me know if you encounter any problem doing this.
Thank you! It's so good!
# restart your R
# upgrade your Matrix package to 1.5.1
install.packages(pkg = "Matrix", force = T)
# upgrade GSVA package
devtools::install_github("rcastelo/GSVA", force = T)
> packageVersion(pkg = "Matrix")
[1] ‘1.5.1’
> packageVersion(pkg = "GSVA")
[1] ‘1.45.4’
library(GSVA)
library(Seurat)
# load data
data(pbmc_small)
pbmc_small <- SeuratObject::UpdateSeuratObject(pbmc_small)
my.matrix <- SeuratObject::GetAssayData(pbmc_small, assay = "RNA", slot = "data")
# custom geneset
markers <- list()
markers$Tcell_gd <- c("TRDC+", "TRGC1+", "TRGC2+", "TRDV1+","TRAC-","TRBC1-","TRBC2-")
markers$Tcell_NK <- c("FGFBP2+", "SPON2+", "KLRF1+", "FCGR3A+", "CD3E-","CD3G-")
markers$Tcell_CD4 <- c("CD4","CD40LG")
markers$Tcell_CD8 <- c("CD8A","CD8B")
markers$Tcell_Treg <- c("FOXP3","IL2RA")
> ssgsea.scores <- GSVA::gsva(my.matrix,
+ gset.idx.list = markers,
+ method = "ssgsea",
+ kcdf = "Gaussian",
+ ssgsea.norm = F,
+ parallel.sz = 1, verbose = F)
[1] "Calculating ranks..."
[1] "Calculating absolute values from ranks..."
Warning messages:
1: In .local(expr, gset.idx.list, ...) :
Using 'dgCMatrix' objects as input is still in an experimental stage.
2: In .gsva(expr, mapped.gset.idx.list, method, kcdf, rnaseq, abs.ranking, :
Some gene sets have size one. Consider setting 'min.sz > 1'.