Browse code

review edits

Maddy Griswold authored on 11/01/2024 20:22:12
Showing 2 changed files

... ...
@@ -266,8 +266,28 @@ test_that("collapseCellTypes works", {
266 266
 #make seurat object:
267 267
 options(Seurat.object.assay.version = "v3")
268 268
 seur <- SeuratObject::CreateSeuratObject(counts = raw, assay="Spatial")
269
-test_that("runspatialdecon works on seurat objects", {
269
+test_that("runspatialdecon works on seurat objects - v3", {
270 270
   res <- runspatialdecon(seur)
271
+  res2 <- spatialdecon(norm = raw, raw = raw, bg = 0.1)
272
+  
273
+  expect_true(is.matrix(res$beta)) # test beta is a matrix
274
+  expect_true(is.matrix(res$yhat)) 
275
+  expect_true(is.matrix(res$resids))
276
+  expect_true(length(dim(res$sigmas)) == 3) # test sigmas is a 3d assar
277
+  expect_true(is.matrix(res$p))
278
+  expect_true(is.matrix(res$t))
279
+  expect_true(is.matrix(res$se))
280
+  expect_true(is.matrix(res$prop_of_all))
281
+  expect_true(is.matrix(res$prop_of_nontumor))
282
+  expect_true(is.matrix(res$X))
283
+  
284
+  expect_identical(res, res2)
285
+})
286
+
287
+options(Seurat.object.assay.version = "v5")
288
+seur <- suppressWarnings(SeuratObject::CreateSeuratObject(counts = raw, assay="Spatial"))
289
+test_that("runspatialdecon works on seurat objects - v5", {
290
+  res <- suppressWarnings(runspatialdecon(seur))
271 291
   
272 292
   res2 <- spatialdecon(norm = raw, raw = raw, bg = 0.1)
273 293
   
... ...
@@ -206,6 +206,7 @@ example of creating a matrix using a Seurat object.
206 206
 
207 207
 ```{r createSeuratmatrix}
208 208
 library(SeuratObject)
209
+library(Seurat)
209 210
 
210 211
 data("mini_singleCell_dataset")
211 212
 
... ...
@@ -220,9 +221,9 @@ rm(mini_singleCell_dataset)
220 221
 annots <- data.frame(cbind(cellType=as.character(Idents(seuratObject)), 
221 222
                            cellID=names(Idents(seuratObject))))
222 223
 
223
-custom_mtx_seurat <- create_profile_matrix(mtx = GetAssayData(object = seuratObject, 
224
-                                                              assay = "RNA", 
225
-                                                              slot = "counts"), 
224
+custom_mtx_seurat <- create_profile_matrix(mtx = Seurat::GetAssayData(object = seuratObject, 
225
+                                                                      assay = "RNA", 
226
+                                                                      slot = "counts"), 
226 227
                                            cellAnnots = annots, 
227 228
                                            cellTypeCol = "cellType", 
228 229
                                            cellNameCol = "cellID",