Browse code

add test for RDS param files; make changes to get test passing

Tom Sherman authored on 18/02/2019 19:53:40
Showing 3 changed files

... ...
@@ -81,7 +81,7 @@ isRdsFile <- function(file)
81 81
         return(FALSE)
82 82
     if (!is(file, "character"))
83 83
         return(FALSE)
84
-    return(tools::file_ext(file) == ".rds")
84
+    return(tools::file_ext(file) == "rds")
85 85
 }
86 86
 
87 87
 #' get input that might be an RDS file
88 88
new file mode 100755
89 89
Binary files /dev/null and b/tests/testthat/temp_params.rds differ
... ...
@@ -200,5 +200,22 @@ test_that("Valid Top-Level CoGAPS Calls",
200 200
     res <- CoGAPS(gistCsvPath, nIterations=100, outputFrequency=100, seed=42,
201 201
         messages=FALSE, nPatterns=3, subsetIndices=1:100, subsetDim=1)
202 202
     expect_true(nrow(res@featureLoadings) == 100)
203
+
204
+    # test using RDS file for parameters
205
+    matP <- getSampleFactors(GIST.result)
206
+    params <- CogapsParams(nPatterns=ncol(matP), nIterations=175, seed=42,
207
+        singleCell=TRUE, sparseOptimization=TRUE, distributed="genome-wide",
208
+        explicitSets=list(1:200, 201:400, 401:600, 601:800, 801:1000))
209
+    params <- setDistributedParams(params, nSets=5, cut=ncol(matP) + 1)
210
+    params <- setFixedPatterns(params, matP, "P")
211
+    saveRDS(params, file="temp_params.rds")
212
+
213
+    res1 <- CoGAPS(GIST.matrix, params)
214
+    res2 <- CoGAPS(GIST.matrix, "temp_params.rds")
215
+    
216
+    expect_true(all(res1@featureLoadings == res2@featureLoadings))
217
+    expect_true(all(res1@featureStdDev == res2@featureStdDev))
218
+    expect_true(all(res1@sampleFactors == res2@sampleFactors))
219
+    expect_true(all(res1@sampleStdDev== res2@sampleStdDev))
203 220
 })
204 221