Browse code

2.9.10: test.Z-fixation: some tests only on Linux because rng is done in C++.

ramon diaz-uriarte (at Phelsuma) authored on 19/04/2018 19:17:38
Showing5 changed files

... ...
@@ -1,8 +1,8 @@
1 1
 Package: OncoSimulR
2 2
 Type: Package
3 3
 Title: Forward Genetic Simulation of Cancer Progression with Epistasis 
4
-Version: 2.9.9
5
-Date: 2018-04-10
4
+Version: 2.9.10
5
+Date: 2018-04-19
6 6
 Authors@R: c(person("Ramon", "Diaz-Uriarte", role = c("aut", "cre"),
7 7
 		     email = "rdiaz02@gmail.com"),
8 8
 	      person("Mark", "Taylor", role = "ctb", email = "ningkiling@gmail.com"))
... ...
@@ -1,3 +1,19 @@
1
+Changes in version 2.10.0 (for BioC 3.7):
2
+	- probDetect mechanism changed. This could be a BREAKING CHANGE.
3
+	  The expression divides by the baseline. For fixed initSize, this
4
+	  is simply a matter of changing the cPDetect.
5
+	- fixation allows exact genotypes, includes tolerance,
6
+ 	  and checks for a successive number of specified periods
7
+	- LOD: using only the strict Szendro et al. meaning.
8
+	- POM: computed in C++.
9
+	- Using fitness landscape directly when given as input (no
10
+          conversion to epistasis) and several improvements in speed when
11
+	  using fitness landscapes as input.
12
+
13
+Changes in version 2.9.10 (2018-04-19):
14
+	- test.Z-fixation: some tests only on Linux because rng is done in
15
+	C++.
16
+	
1 17
 Changes in version 2.9.9 (2018-04-10):
2 18
 	- probDetect mechanism changed. This could be a BREAKING CHANGE.
3 19
 	  The expression divides by the baseline. For fixed initSize, this
... ...
@@ -32,8 +32,7 @@ test_that("exercising plotClonePhylog", {
32 32
               plotClonePhylog(tmp, N = 10, keepEvents = TRUE)
33 33
               ## Reaching the fixOverlap code
34 34
               plotClonePhylog(tmp, N = 0, timeEvents = TRUE)
35
-              expect_true(TRUE) ## dummy, to prevent the
36
-              ## attempt to apply non-function
35
+              expect_true(TRUE) 
37 36
               ## If plotting failed, this would fail
38 37
               expect_error(plotClonePhylog(c(1, 2)))
39 38
           })
... ...
@@ -68,10 +67,8 @@ test_that("exercising the fitnessEffects plotting code", {
68 67
               plot(fp4m, "igraph", layout = igraph::layout.reingold.tilford, 
69 68
                    expandModules = TRUE, autofit = TRUE)
70 69
               plot(fp4m, expandModules = TRUE, autofit = TRUE)
71
-              expect_true(TRUE) ## dummy, to prevent the
72
-              ## attempt to apply non-function
73
-              ## If plotting failed, this would fail
74
-          })
70
+              expect_true(TRUE)
71
+})
75 72
 date()
76 73
 
77 74
 test_that("xlab, ylab, ylim, xlim can be passed", {
... ...
@@ -181,9 +178,7 @@ test_that("xlab, ylab, ylim, xlim can be passed", {
181 178
          ylab = "ylab", ylim = c(-100, 1000),
182 179
          xlim = c(20, 70),
183 180
          plotDrivers = TRUE)
184
-    expect_true(TRUE) ## dummy, to prevent the
185
-    ## attempt to apply non-function
186
-    ## If plotting failed, this would fail
181
+    expect_true(TRUE) 
187 182
     expect_error(plot(e1, type = "stremaitoooihoh"))
188 183
     
189 184
 })
... ...
@@ -224,9 +219,7 @@ test_that("oncosimul v.1 objects and genotype plotting", {
224 219
     plot(p1, type = "stacked", show = "genotypes", thinData = TRUE)
225 220
     plot(p1, type = "stream", show = "genotypes", thinData = TRUE)
226 221
     plot(p1, type = "line", show = "genotypes", thinData = TRUE)
227
-    expect_true(TRUE) ## dummy, to prevent the
228
-    ## attempt to apply non-function
229
-    ## If plotting failed, this would fail
222
+    expect_true(TRUE) 
230 223
     expect_error(plot(tmp, type = "linito"))
231 224
 })
232 225
 date()
... ...
@@ -238,94 +231,90 @@ date()
238 231
 
239 232
 
240 233
 
241
-## test_that("passing colors", {
242
-##     data(examplePosets)
243
-##     ## An object of class oncosimul
244
-##     p705 <- examplePosets[["p705"]]
245
-##     max.tries <- 4
246
-##     for(i in 1:max.tries) {
247
-##     p1 <- oncoSimulIndiv(p705)
248
-##     if(nrow(p1$pops.by.time) >= 11) {
249
-##             break
250
-##     } else {
251
-##         cat("\n hummm.. had to run again in the plot")
252
-##         if(i >= max.tries) {
253
-##             print(p1)
254
-##             stop("stream will break")
255
-##         }
256
-##     }
257
-##     }
258
-##     ## class(p1)
259
-##     plot(p1, type = "stacked", show = "genotypes", thinData = TRUE)
260
-##     ## with newest testthat, the next make if fail with test_dir, but
261
-##     ## not if run from REPL. Go figure
262
-##     plot(p1, type = "stacked", show = "genotypes", col = rainbow(8))
263
-##     plot(p1, type = "stream", show = "genotypes", col = rainbow(18))
264
-##     plot(p1, type = "line", show = "genotypes", col = rainbow(3))
265
-##     expect_true(TRUE) ## dummy, to prevent the
266
-##     ## attempt to apply non-function
267
-##     ## If plotting failed, this would fail
268
-##     expect_error(plot(p1, type = "linito"))
269
-## })
234
+test_that("passing colors", {
235
+    data(examplePosets)
236
+    ## An object of class oncosimul
237
+    p705 <- examplePosets[["p705"]]
238
+    max.tries <- 4
239
+    for(i in 1:max.tries) {
240
+    p1 <- oncoSimulIndiv(p705)
241
+    if(nrow(p1$pops.by.time) >= 11) {
242
+            break
243
+    } else {
244
+        cat("\n hummm.. had to run again in the plot")
245
+        if(i >= max.tries) {
246
+            print(p1)
247
+            stop("stream will break")
248
+        }
249
+    }
250
+    }
251
+    ## class(p1)
252
+    plot(p1, type = "stacked", show = "genotypes", thinData = TRUE)
253
+    ## with newest testthat, the next make if fail with test_dir, but
254
+    ## not if run from REPL. Go figure
255
+    plot(p1, type = "stacked", show = "genotypes", col = rainbow(8))
256
+    plot(p1, type = "stream", show = "genotypes", col = rainbow(18))
257
+    plot(p1, type = "line", show = "genotypes", col = rainbow(3))
258
+    expect_true(TRUE) 
259
+    expect_error(plot(p1, type = "linito"))
260
+})
270 261
 
271 262
 
272 263
 
273 264
 
274 265
 
275
-## date()
276
-## test_that("stacked, stream, genotypes and some colors", {
277
-##     data(examplesFitnessEffects)
278
-##     max.tries <- 4
279
-##     for(i in 1:max.tries) {
280
-##         tmp <-  oncoSimulIndiv(examplesFitnessEffects[["o3"]],
281
-##                                model = "McFL", 
282
-##                                mu = 5e-5,
283
-##                                detectionSize = 1e8, 
284
-##                                detectionDrivers = 3,
285
-##                                sampleEvery = 0.025,
286
-##                                max.num.tries = 10,
287
-##                                keepEvery = 5,
288
-##                                initSize = 2000,
289
-##                                finalTime = 3000,
290
-##                                onlyCancer = FALSE, detectionProb = NA,
291
-##                                keepPhylog = TRUE)
292
-##         if(nrow(tmp$pops.by.time) >= 5) {
293
-##             break
294
-##         } else {
295
-##             cat("\n hummm.. had to run again in the plot")
296
-##             if(i >= max.tries) {
297
-##                 print(tmp)
298
-##                 stop("stream will break")
299
-##             }
300
-##         }
301
-##     }
302
-##     plot(tmp, type = "stacked", show = "genotypes")
303
-##     plot(tmp, type = "stream", show = "genotypes")
304
-##     plot(tmp, type = "line", show = "genotypes")
305
-##     plot(tmp, type = "stacked", show = "drivers")
306
-##     plot(tmp, type = "stream", show = "drivers")
307
-##     plot(tmp, type = "line", show = "drivers")
308
-##     plot(tmp, type = "stacked", order.method = "max")
309
-##     plot(tmp, type = "stacked", order.method = "first")
310
-##     plot(tmp, type = "stream", order.method = "max")
311
-##     plot(tmp, type = "stream", order.method = "first")
312
-##     plot(tmp, type = "stream", stream.center = TRUE)
313
-##     plot(tmp, type = "stream", stream.center = FALSE)
314
-##     plot(tmp, type = "stream", stream.center = TRUE, log = "x")
315
-##     plot(tmp, type = "stacked", stream.center = TRUE, log = "x")
316
-##     plot(tmp, type = "stacked", show = "genotypes",
317
-##          breakSortColors = "random")
318
-##     plot(tmp, type = "stream", show = "genotypes",
319
-##          breakSortColors = "distave")
320
-##     plot(tmp, type = "stacked", show = "genotypes", col = rainbow(9))
321
-##     plot(tmp, type = "stream", show = "genotypes", col = rainbow(3))
322
-##     plot(tmp, type = "line", show = "genotypes", col = rainbow(20))
323
-##     expect_true(TRUE) ## dummy, to prevent the
324
-##     ## attempt to apply non-function
325
-##     ## If plotting failed, this would fail
326
-##     expect_error(plot(tmp, type = "linito"))
327
-## })
328
-## date()
266
+date()
267
+test_that("stacked, stream, genotypes and some colors", {
268
+    data(examplesFitnessEffects)
269
+    max.tries <- 4
270
+    for(i in 1:max.tries) {
271
+        tmp <-  oncoSimulIndiv(examplesFitnessEffects[["o3"]],
272
+                               model = "McFL", 
273
+                               mu = 5e-5,
274
+                               detectionSize = 1e8, 
275
+                               detectionDrivers = 3,
276
+                               sampleEvery = 0.025,
277
+                               max.num.tries = 10,
278
+                               keepEvery = 5,
279
+                               initSize = 2000,
280
+                               finalTime = 3000,
281
+                               onlyCancer = FALSE, detectionProb = NA,
282
+                               keepPhylog = TRUE)
283
+        if(nrow(tmp$pops.by.time) >= 5) {
284
+            break
285
+        } else {
286
+            cat("\n hummm.. had to run again in the plot")
287
+            if(i >= max.tries) {
288
+                print(tmp)
289
+                stop("stream will break")
290
+            }
291
+        }
292
+    }
293
+    plot(tmp, type = "stacked", show = "genotypes")
294
+    plot(tmp, type = "stream", show = "genotypes")
295
+    plot(tmp, type = "line", show = "genotypes")
296
+    plot(tmp, type = "stacked", show = "drivers")
297
+    plot(tmp, type = "stream", show = "drivers")
298
+    plot(tmp, type = "line", show = "drivers")
299
+    plot(tmp, type = "stacked", order.method = "max")
300
+    plot(tmp, type = "stacked", order.method = "first")
301
+    plot(tmp, type = "stream", order.method = "max")
302
+    plot(tmp, type = "stream", order.method = "first")
303
+    plot(tmp, type = "stream", stream.center = TRUE)
304
+    plot(tmp, type = "stream", stream.center = FALSE)
305
+    plot(tmp, type = "stream", stream.center = TRUE, log = "x")
306
+    plot(tmp, type = "stacked", stream.center = TRUE, log = "x")
307
+    plot(tmp, type = "stacked", show = "genotypes",
308
+         breakSortColors = "random")
309
+    plot(tmp, type = "stream", show = "genotypes",
310
+         breakSortColors = "distave")
311
+    plot(tmp, type = "stacked", show = "genotypes", col = rainbow(9))
312
+    plot(tmp, type = "stream", show = "genotypes", col = rainbow(3))
313
+    plot(tmp, type = "line", show = "genotypes", col = rainbow(20))
314
+    expect_true(TRUE) 
315
+    expect_error(plot(tmp, type = "linito"))
316
+})
317
+date()
329 318
 
330 319
 
331 320
 cat(paste("\n Ending exercise-plotting-code long at", date()))
... ...
@@ -1,6 +1,11 @@
1 1
 inittime <- Sys.time()
2 2
 cat(paste("\n Starting test.Z-fixation at", date(), "\n"))
3 3
 
4
+## Some tests below might only work on Linux because of compiler
5
+## differences, because the rng is done in C++, etc.
6
+## Note that the difference is in whether a certain code
7
+## is exercised. The runs should work in all platforms, though.
8
+## This is the same as in test.Z-oncoSimulIndiv.R
4 9
 
5 10
 
6 11
 test_that("Three cases with fixation of genotypes" ,{
... ...
@@ -28,12 +33,13 @@ test_that("Three cases with fixation of genotypes" ,{
28 33
                          keepPhylog = FALSE)
29 34
     
30 35
     summary(r3)
36
+    if(Sys.info()["sysname"] == "Linux") {
31 37
     ## stopping at ABCG, which is not a maximum, not a labelled peak
32
-    expect_equal(
33
-        c(A = 1, B = 1, C = 1, D = 0, E = 0, F = 0, G = 1),
34
-        samplePop(r3, "last", "singleCell")[1, ])
38
+        expect_equal(
39
+            c(A = 1, B = 1, C = 1, D = 0, E = 0, F = 0, G = 1),
40
+            samplePop(r3, "last", "singleCell")[1, ])
41
+    }
35 42
     feex$labelled_peaks
36
-
37 43
     ## And not a single genotype unique
38 44
     expect_true(r3$TotalPopSize > r3$LargestClone)
39 45
     
... ...
@@ -57,9 +63,11 @@ test_that("Three cases with fixation of genotypes" ,{
57 63
                      keepPhylog = FALSE)
58 64
     summary(r4)
59 65
     ## now a local max is the single clone
60
-    expect_equal(
61
-        c(A = 1, B = 1, C = 1, D = 0, E = 0, F = 1, G = 1),
62
-        samplePop(r4, "last", "singleCell")[1, ])
66
+    if(Sys.info()["sysname"] == "Linux") {
67
+        expect_equal(
68
+            c(A = 1, B = 1, C = 1, D = 0, E = 0, F = 1, G = 1),
69
+            samplePop(r4, "last", "singleCell")[1, ])
70
+    }
63 71
     expect_true(r4$TotalPopSize == r4$LargestClone)
64 72
 
65 73
 
... ...
@@ -83,9 +91,11 @@ test_that("Three cases with fixation of genotypes" ,{
83 91
                          errorHitMaxTries = TRUE,
84 92
                          keepPhylog = FALSE)
85 93
     summary(r5)
94
+    if(Sys.info()["sysname"] == "Linux") {
86 95
     expect_equal(
87 96
         c(A = 1, B = 1, C = 1, D = 0, E = 0, F = 1, G = 1),
88 97
         samplePop(r5, "last", "singleCell")[1, ])
98
+    }
89 99
     ## but other clones present too
90 100
     expect_true(r5$TotalPopSize > r5$LargestClone)
91 101
 })
... ...
@@ -1,15 +1,15 @@
1 1
 \usepackage[%
2
-		shash={1bb7743},
3
-		lhash={1bb7743d2798aafc935d6e3fcdd9c78392564e9a},
4
-		authname={Ramon Diaz-Uriarte (at Coleonyx)},
2
+		shash={c58241c},
3
+		lhash={c58241c578e1e58ea975ab0283f4f9a9898be60a},
4
+		authname={ramon diaz-uriarte (at Phelsuma)},
5 5
 		authemail={rdiaz02@gmail.com},
6
-		authsdate={2018-04-17},
7
-		authidate={2018-04-17 17:55:23 +0200},
8
-		authudate={1523980523},
9
-		commname={Ramon Diaz-Uriarte (at Coleonyx)},
6
+		authsdate={2018-04-18},
7
+		authidate={2018-04-18 02:15:18 +0200},
8
+		authudate={1524010518},
9
+		commname={ramon diaz-uriarte (at Phelsuma)},
10 10
 		commemail={rdiaz02@gmail.com},
11
-		commsdate={2018-04-17},
12
-		commidate={2018-04-17 17:55:23 +0200},
13
-		commudate={1523980523},
11
+		commsdate={2018-04-18},
12
+		commidate={2018-04-18 02:15:18 +0200},
13
+		commudate={1524010518},
14 14
 		refnames={ (HEAD -> master, origin/master, origin/HEAD)}
15 15
 	]{gitsetinfo}
16 16
\ No newline at end of file