Browse code

some files had not been removed

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/OncoSimulR@121247 bc3139a8-67e5-0310-9ffc-ced21a209358

Ramon Diaz-Uriarte authored on 22/09/2016 17:43:20
Showing4 changed files

1 1
new file mode 100644
... ...
@@ -0,0 +1,16 @@
1
+The names of the files are as self explanatory as I could think of. Some
2
+files are names as "test.Z-somestring.R". Those are files where we set the
3
+seed of the random number generator to a specific value.
4
+
5
+In files with a name "test.Z*", at the very end we do a "set.seed(NULL)"
6
+to re-initialize the seed of the random number generator. This is done so
7
+that any files that are run after it do not have the same stream of random
8
+numbers. Since I want to avoid re-initilizing in every file, I move those
9
+specific test cases with fixed seeds to separate files.
10
+
11
+Why the Z? It is true that the documentation for testthat asks that we do
12
+not rely in a specific order for how files are tested. In this sense, any
13
+file that uses a fixed seed cleans up after itself, so the order in which
14
+files are tested should never mean we get a fixed stream. Nevertheless,
15
+using the "Z" will often mean we reinitialize the seed at the very end of
16
+all tests.
0 17
deleted file mode 100644
... ...
@@ -1,95 +0,0 @@
1
-## Like standard one, but with all 13 posets, which is an unneeded
2
-## overkill.
3
-
4
-data(examplePosets)
5
-RNGkind("Mersenne-Twister") 
6
-
7
-bozic <- function(poset) oncoSimulIndiv(poset)
8
-bozic9 <- function(poset) oncoSimulIndiv(poset, keepEvery = -9)
9
-    
10
-Exp <- function(poset) oncoSimulIndiv(poset, model = "Exp")
11
-Exp9 <- function(poset) oncoSimulIndiv(poset, model = "Exp", keepEvery = -9)
12
-
13
-mc <- function(poset) oncoSimulIndiv(poset, model = "McFL",
14
-                                     mu = 5e-7,
15
-                                     initSize = 4000,
16
-                                     sampleEvery = 0.025,
17
-                                     finalTime = 15000,
18
-                                     keepEvery = 5)
19
-mc9 <- function(poset) oncoSimulIndiv(poset, model = "McFL",
20
-                                     mu = 5e-7,
21
-                                     initSize = 4000,
22
-                                     sampleEvery = 0.025,
23
-                                     finalTime = 15000,
24
-                                      keepEvery = -9)
25
-
26
-
27
-## A list, where each element is a list
28
-## with two members, both expected to give same result
29
-FexpectedSame <- list(
30
-    Bozics = list(bozic = bozic, bozic9 = bozic9),
31
-    Exps = list(Exp = Exp, Exp9 = Exp9),
32
-    McFLs = list(mc = mc, mc9 = mc9)
33
-)
34
-
35
-
36
-popsNoZero <- function(x) {
37
-    keep <- which(x$pops.by.time[nrow(x$pops.by.time), ] > 0)
38
-    pops <- x$pops.by.time[nrow(x$pops.by.time), keep]
39
-    genots <- x$Genotypes[, keep[-1] - 1, drop = FALSE] ## keep contains time too in first col.
40
-    return(list(pops = pops, genots = genots))
41
-}
42
-
43
-runBothFuncts <- function(seed, Poset, functionPair) {
44
-    set.seed(seed); b1 <- functionPair[[1]](Poset)
45
-    set.seed(seed); b2 <- functionPair[[2]](Poset)
46
-    return(list(all = b1, last = b2))
47
-}
48
-
49
-
50
-for(i in 1:length(examplePosets)) {
51
-    s1 <- round(runif(1) * 10000) ## do better as: as.integer(runif(1, 1, 1e9))
52
-    Poset <- examplePosets[[i]]
53
-    attributes(Poset)$namePoset <- names(examplePosets)[[i]]
54
-    for(ffs in FexpectedSame) {
55
-        test_that(paste("Sampling only last same for ",
56
-                        paste(names(ffs), collapse = " ")), {
57
-                            ## comment next cat later
58
-                            cat(paste("\n ",
59
-                                      " Seed = ", s1, " ",
60
-                                      paste(names(ffs), collapse = " "),
61
-                                      ". Poset = ",
62
-                                      attributes(Poset)$namePoset,
63
-                                      "\n"))
64
-                            
65
-                            bb <- runBothFuncts(s1, Poset, ffs)
66
-                            b1 <- bb$all
67
-                            b2 <- bb$last
68
-                            popsGenots <- popsNoZero(b1)
69
-                            expect_equal(b1$TotalPopSize, b2$TotalPopSize)
70
-                            expect_equal(b1$FinalTime, b2$FinalTime)
71
-                            expect_equal(b1$NumIter, b2$NumIter)
72
-
73
-                            expect_equal(b1$NumDriversLargestPop,
74
-                                         b2$NumDriversLargestPop)
75
-                            expect_equal(b1$MaxDriversLast, b2$MaxDriversLast)
76
-                            expect_equal(b1$PropLargestPopLast,
77
-                                         b2$PropLargestPopLast)                            
78
-                            expect_equal(b1$LargestClone, b2$LargestClone)
79
-                            ## these need not be the same as those
80
-                            ## accumulate over all samples
81
-
82
-                            ## expect_equal(b1$MaxNumDrivers,
83
-                            ## b2$MaxNumDrivers)
84
-                            ## expect_equal(b1$TotalPresentDrivers,
85
-                            ## b2$TotalPresentDrivers)
86
-
87
-                            expect_equal(popsGenots$pops, b2$pops.by.time[1, ])
88
-                            expect_equal(popsGenots$genots, b2$Genotypes)
89
-                            expect_false(
90
-                                all(dim(b2$pops.by.time) ==
91
-                                        dim(b1$pops.by.time)))
92
-                            rm(bb, b1, b2)
93
-                        })   
94
-    }
95
-}
96 0
deleted file mode 100644
... ...
@@ -1,103 +0,0 @@
1
-cat(paste("\n Starting sample-only-last tests", date(), "\n"))
2
-
3
-data(examplePosets)
4
-RNGkind("Mersenne-Twister") 
5
-
6
-bozic <- function(poset) oncoSimulIndiv(poset, sampleEvery = 0.03,
7
-                                        keepEvery = 1)
8
-bozic9 <- function(poset) oncoSimulIndiv(poset, sampleEvery = 0.03,
9
-                                         keepEvery = -9)
10
-    
11
-Exp <- function(poset) oncoSimulIndiv(poset, sampleEvery = 0.03, keepEvery = 1,
12
-                                      model = "Exp")
13
-Exp9 <- function(poset) oncoSimulIndiv(poset, model = "Exp",
14
-                                       sampleEvery = 0.03,
15
-                                       keepEvery = -9)
16
-
17
-mc <- function(poset) oncoSimulIndiv(poset, model = "McFL",
18
-                                     mu = 5e-7,
19
-                                     initSize = 4000,
20
-                                     sampleEvery = 0.025,
21
-                                     finalTime = 15000,
22
-                                     keepEvery = 5)
23
-mc9 <- function(poset) oncoSimulIndiv(poset, model = "McFL",
24
-                                     mu = 5e-7,
25
-                                     initSize = 4000,
26
-                                     sampleEvery = 0.025,
27
-                                     finalTime = 15000,
28
-                                      keepEvery = -9)
29
-
30
-
31
-## A list, where each element is a list
32
-## with two members, both expected to give same result
33
-FexpectedSame <- list(
34
-    Bozics = list(bozic = bozic, bozic9 = bozic9),
35
-    Exps = list(Exp = Exp, Exp9 = Exp9),
36
-    McFLs = list(mc = mc, mc9 = mc9)
37
-)
38
-
39
-
40
-popsNoZero <- function(x) {
41
-    keep <- which(x$pops.by.time[nrow(x$pops.by.time), ] > 0)
42
-    pops <- x$pops.by.time[nrow(x$pops.by.time), keep]
43
-    genots <- x$Genotypes[, keep[-1] - 1, drop = FALSE] ## keep contains time too in first col.
44
-    return(list(pops = pops, genots = genots))
45
-}
46
-
47
-runBothFuncts <- function(seed, Poset, functionPair) {
48
-    set.seed(seed); b1 <- functionPair[[1]](Poset)
49
-    set.seed(seed); b2 <- functionPair[[2]](Poset)
50
-    return(list(all = b1, last = b2))
51
-}
52
-
53
-## We only use one from each of 11, 9, 7.
54
-## Whole collection tested in long tests
55
-examplePosets <- examplePosets[c(1, 5, 9)]
56
-for(i in 1:length(examplePosets)) {
57
-    s1 <- round(runif(1) * 10000) ## do better as: as.integer(runif(1, 1, 1e9))
58
-    Poset <- examplePosets[[i]]
59
-    attributes(Poset)$namePoset <- names(examplePosets)[[i]]
60
-    for(ffs in FexpectedSame) {
61
-        test_that(paste("Sampling only last same for ",
62
-                        paste(names(ffs), collapse = " ")), {
63
-                            ## comment next cat later
64
-                            cat(paste("\n ",
65
-                                      " Seed = ", s1, " ",
66
-                                      paste(names(ffs), collapse = " "),
67
-                                      ". Poset = ",
68
-                                      attributes(Poset)$namePoset,
69
-                                      "\n"))
70
-                            
71
-                            bb <- runBothFuncts(s1, Poset, ffs)
72
-                            b1 <- bb$all
73
-                            b2 <- bb$last
74
-                            popsGenots <- popsNoZero(b1)
75
-                            expect_equal(b1$TotalPopSize, b2$TotalPopSize)
76
-                            expect_equal(b1$FinalTime, b2$FinalTime)
77
-                            expect_equal(b1$NumIter, b2$NumIter)
78
-
79
-                            expect_equal(b1$NumDriversLargestPop,
80
-                                         b2$NumDriversLargestPop)
81
-                            expect_equal(b1$MaxDriversLast, b2$MaxDriversLast)
82
-                            expect_equal(b1$PropLargestPopLast,
83
-                                         b2$PropLargestPopLast)                            
84
-                            expect_equal(b1$LargestClone, b2$LargestClone)
85
-                            ## these need not be the same as those
86
-                            ## accumulate over all samples
87
-
88
-                            ## expect_equal(b1$MaxNumDrivers,
89
-                            ## b2$MaxNumDrivers)
90
-                            ## expect_equal(b1$TotalPresentDrivers,
91
-                            ## b2$TotalPresentDrivers)
92
-
93
-                            expect_equal(popsGenots$pops, b2$pops.by.time[1, ])
94
-                            expect_equal(popsGenots$genots, b2$Genotypes)
95
-                            expect_false(
96
-                                all(dim(b2$pops.by.time) ==
97
-                                        dim(b1$pops.by.time)))
98
-                            rm(bb, b1, b2)
99
-                        })   
100
-    }
101
-}
102
-
103
-cat(paste("\n Ending sample-only-last tests", date(), "\n"))
104 0
deleted file mode 100644
... ...
@@ -1,91 +0,0 @@
1
-cat(paste("\n Starting total-present-drivers tests", date(), "\n"))
2
-
3
-test_that("Count TotalPresentDrivers", {
4
-    ## There once was a bug here (in the driverCounts C++ function)
5
-    ## Testing we are OK
6
-    ## Below, I use specific seeds for a few cases where I got
7
-    ## errors. This actual cases might not be the same with other
8
-    ## compilers. But we are checking anyway against the number obtained
9
-    ## by other means.
10
-    RNGkind("Mersenne-Twister")
11
-    set.seed(1)
12
-    lni <- 5 ## no fitness effects genes
13
-    fni <- 50 ## fitness effects genes
14
-    no <- 1e2
15
-    ft <- 2
16
-    s3 <- 2.0
17
-    mu <- 1e-5 
18
-    ni <- rep(0, lni)
19
-    gn <- paste(paste0("a", 1:fni), collapse = ", ")
20
-    set.seed(2)
21
-    ## There are no drivers here
22
-    f3 <- allFitnessEffects(epistasis = c("A" = s3),
23
-                            geneToModule = c("A" = gn),
24
-                            noIntGenes = ni)
25
-    s3.ng <- oncoSimulIndiv(f3,
26
-                            mu = mu,
27
-                            mutationPropGrowth = FALSE,
28
-                            finalTime =ft,
29
-                            initSize = no,
30
-                            sampleEvery = 0.03,
31
-                            keepEvery = 1,
32
-                            onlyCancer = FALSE,
33
-                            seed = NULL)
34
-    s3.ng
35
-    ## so this should be zero
36
-    s3.ng$TotalPresentDrivers
37
-    expect_true(s3.ng$TotalPresentDrivers ==
38
-                length(strsplit(s3.ng$OccurringDrivers, ", ")[[1]]))
39
-    set.seed(1)
40
-    f4 <- allFitnessEffects(epistasis = c("A" = s3),
41
-                            geneToModule = c("A" = gn),
42
-                            noIntGenes = ni
43
-                          , drvNames = c("a2", "a5")
44
-                            )
45
-    s4.ng <- oncoSimulIndiv(f4,
46
-                            mu = mu,
47
-                            mutationPropGrowth = FALSE,
48
-                            finalTime =ft,
49
-                            initSize = no,
50
-                            sampleEvery = 0.03,
51
-                            keepEvery = 1,
52
-                            onlyCancer = FALSE,
53
-                            ## verbosity = 4,
54
-                            seed = NULL)
55
-    ## this should be zero
56
-    s4.ng$TotalPresentDrivers
57
-    s4.ng
58
-    expect_true(s4.ng$TotalPresentDrivers ==
59
-                length(strsplit(s4.ng$OccurringDrivers, ", ")[[1]]))
60
-    ## and something with drivers
61
-    set.seed(53)
62
-    s3.l <- oncoSimulIndiv(f3,
63
-                           mu = mu,
64
-                           mutationPropGrowth = FALSE,
65
-                           finalTime = 28,
66
-                           initSize = no,
67
-                           sampleEvery = 0.03,
68
-                           keepEvery = 1,
69
-                           onlyCancer = FALSE,
70
-                           ## verbosity = 4,
71
-                           seed = NULL)
72
-    s3.l
73
-    expect_true(s3.l$TotalPresentDrivers ==
74
-                length(strsplit(s3.l$OccurringDrivers, ", ")[[1]]))
75
-    set.seed(53)
76
-    s3.l <- oncoSimulIndiv(f3,
77
-                           mu = mu,
78
-                           mutationPropGrowth = FALSE,
79
-                           finalTime = 35,
80
-                           initSize = no,
81
-                           sampleEvery = 0.03,
82
-                           keepEvery = 1,
83
-                           onlyCancer = FALSE,
84
-                           ## verbosity = 4,
85
-                           seed = NULL)
86
-    s3.l
87
-    expect_true(s3.l$TotalPresentDrivers ==
88
-                length(strsplit(s3.l$OccurringDrivers, ", ")[[1]]))
89
-})
90
-
91
-cat(paste("\n Ending total-present-drivers tests", date(), "\n"))