Browse code

Fix as(., "dgCMatrix") issue, note that SoupX is still failing

Yichen Wang authored on 30/09/2022 04:09:54
Showing 8 changed files

... ...
@@ -46,7 +46,7 @@
46 46
     }
47 47
 
48 48
     mat <- Matrix::readMM(path)
49
-    mat <- methods::as(mat, "dgCMatrix")
49
+    mat <- methods::as(mat, "CsparseMatrix")
50 50
 
51 51
     if (class == "matrix") {
52 52
         mat <- as.matrix(mat)
... ...
@@ -124,7 +124,6 @@ importFromFiles <- function(assayFile, annotFile = NULL, featureFile = NULL,
124 124
   if (is.null(colnames(countsin))){
125 125
     colnames(countsin) <- rownames(annotin)
126 126
   }
127
-  #assaylist[[assayName]] <- methods::as(countsin, "dgCMatrix")
128 127
   assaylist[[assayName]] <- .convertToMatrix(countsin)
129 128
 
130 129
   newassay <- SingleCellExperiment::SingleCellExperiment(assays = assaylist,
... ...
@@ -42,7 +42,7 @@
42 42
 
43 43
     ## Convert to "dgCMatrix"
44 44
     newM <- Matrix::Matrix(mat[,1], nrow=nrow(mat))
45
-    newM <- methods::as(newM, "dgCMatrix")
45
+    newM <- methods::as(newM, "CsparseMatrix")
46 46
     breaks <- seq(2, ncol(mat), by=1000)
47 47
     if(length(breaks) > 2) {
48 48
       for(i in seq(2, length(breaks))) {
... ...
@@ -25,7 +25,7 @@
25 25
     missMat <- Matrix::Matrix(0, nrow = length(missGene), ncol = ncol(matrix),
26 26
         dimnames = list(missGene, NULL))
27 27
 
28
-    matb <- methods::as(matrix, "dgCMatrix")
28
+    matb <- methods::as(matrix, "CsparseMatrix")
29 29
     rownames(matb) <- rownames(matrix)
30 30
 
31 31
     mat <- rbind(matb, missMat)
... ...
@@ -177,7 +177,7 @@ discreteColorPalette <- function(n, palette = c("random", "ggplot", "celda"),
177 177
   for (i in seq_len(chuN)) {
178 178
     start <- (i-1)*chuS + 1
179 179
     end <- min(i*chuS, dimN[2])
180
-    Mat[[i]] <- methods::as(x[, start:end], "dgCMatrix")
180
+    Mat[[i]] <- methods::as(x[, start:end], "CsparseMatrix")
181 181
   }
182 182
   x <- do.call(base::cbind, Mat)
183 183
   colnames(x) <- cn
... ...
@@ -82,7 +82,7 @@
82 82
 #' sce <- subsetSCECols(sce, colData = "type != 'EmptyDroplet'")
83 83
 #' \dontrun{
84 84
 #' # SoupX does not work for toy example,
85
-#' # can be tested with `sce <- importExampleData("pbmc3k")`
85
+#' sce <- importExampleData("pbmc3k")
86 86
 #' sce <- runSoupX(sce, sample = "sample")
87 87
 #' }
88 88
 runSoupX <- function(inSCE,
... ...
@@ -1344,7 +1344,7 @@ convertSCEToSeurat <-
1344 1344
     if (!is.null(normAssay) && normAssay %in% names(assays(inSCE))) {
1345 1345
       tempMatrix <- .convertToMatrix(assay(inSCE, normAssay))
1346 1346
       if (inherits(tempMatrix, "dgeMatrix")) {
1347
-        tempMatrix <- methods::as(tempMatrix, "dgCMatrix")
1347
+        tempMatrix <- methods::as(tempMatrix, "CsparseMatrix")
1348 1348
       }
1349 1349
       seuratObject@assays$RNA@data <- tempMatrix
1350 1350
       rownames(seuratObject@assays$RNA@data) <- seuratRowNames
... ...
@@ -135,7 +135,7 @@ data(scExample, package = "singleCellTK")
135 135
 sce <- subsetSCECols(sce, colData = "type != 'EmptyDroplet'")
136 136
 \dontrun{
137 137
 # SoupX does not work for toy example,
138
-# can be tested with `sce <- importExampleData("pbmc3k")`
138
+sce <- importExampleData("pbmc3k")
139 139
 sce <- runSoupX(sce, sample = "sample")
140 140
 }
141 141
 }