Browse code

2.5.3. Vignette enhancements

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

Ramon Diaz-Uriarte authored on 12/12/2016 12:06:14
Showing 4 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.5.2
5
-Date: 2016-12-10
4
+Version: 2.5.3
5
+Date: 2016-12-12
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"))
... ...
@@ -30,7 +30,7 @@ URL: https://github.com/rdiaz02/OncoSimul, https://popmodels.cancercontrol.cance
30 30
 BugReports: https://github.com/rdiaz02/OncoSimul/issues
31 31
 Depends: R (>= 3.3.0)
32 32
 Imports: Rcpp (>= 0.12.4), parallel, data.table, graph, Rgraphviz, gtools, igraph, methods, RColorBrewer, grDevices, car, dplyr, smatr, ggplot2, ggrepel
33
-Suggests: BiocStyle, knitr, Oncotree, testthat (>= 1.0.0), rmarkdown, bookdown
33
+Suggests: BiocStyle, knitr, Oncotree, testthat (>= 1.0.0), rmarkdown, bookdown, pander
34 34
 LinkingTo: Rcpp
35 35
 VignetteBuilder: knitr
36 36
 
... ...
@@ -1,3 +1,7 @@
1
+Changes in version 2.5.2 (2016-12-12):
2
+	- Vignette uses pander in tables.
3
+	- Typos fixed and other enhancements in vignette.
4
+	
1 5
 Changes in version 2.5.2 (2016-12-10):
2 6
         - Lots and lots of addition to vignette including benchmarks.
3 7
         - Diversity of sampled genotypes.
... ...
@@ -10,7 +10,9 @@ author: "
10 10
 		 
11 11
 		 <rdiaz02@gmail.com>, <http://ligarto.org/rdiaz>
12 12
 		 "
13
-date: "`r paste0(Sys.Date(),'. OncoSimulR version ', packageVersion('OncoSimulR'), '. Revision: ', system('git rev-parse --short HEAD', intern = TRUE))`"
13
+date: "`r paste0(Sys.Date(),'. OncoSimulR version ', packageVersion('OncoSimulR'), suppressWarnings(ifelse(length(try(system('git rev-parse --short HEAD', ignore.stderr = TRUE, intern = TRUE))), paste0('. Revision: ', system('git rev-parse --short HEAD', intern = TRUE)), '')))`"
14
+header-includes:
15
+    - \input{preamble.tex}
14 16
 output: 
15 17
   bookdown::html_document2:
16 18
     css: custom4.css
... ...
@@ -21,6 +23,7 @@ classoption: a4paper
21 23
 geometry: margin=3cm
22 24
 fontsize: 12pt
23 25
 bibliography: OncoSimulR.bib
26
+biblio-style: "apalike"
24 27
 link-citations: true
25 28
 vignette: >
26 29
   %\VignetteIndexEntry{OncoSimulR: forward genetic simulation in asexual populations with arbitrary epistatic interactions and a focus on modeling tumor progression.}
... ...
@@ -129,6 +132,7 @@ MathJax.Hub.Config({
129 132
 knitr::opts_chunk$set(echo = TRUE, collapse = TRUE)
130 133
 options(width = 70)
131 134
 require(BiocStyle)
135
+require(pander)
132 136
 ```
133 137
 
134 138
 <!-- bookdown::pdf_document2 seems to produce the tex even if failures -->
... ...
@@ -144,8 +148,9 @@ require(BiocStyle)
144 148
 <!-- sed -i 's/\\Rfunction{\([^}]\+\)}/*`\1`*/g' p22.md -->
145 149
 
146 150
 
151
+\clearpage
147 152
 
148
-# Introduction {#intro}
153
+# Introduction {#introdd}
149 154
  
150 155
 OncoSimulR is an individual-based forward-time genetic simulator for
151 156
 biallelic markers (wildtype vs. mutated) in asexually reproducing
... ...
@@ -286,6 +291,7 @@ is a summary of some of the key features:
286 291
   from the simulations.
287 292
   
288 293
 
294
+
289 295
 The table below, modified from the table at the
290 296
 [Genetics Simulation Resources (GSR) page](https://popmodels.cancercontrol.cancer.gov/gsr/packages/oncosimulr/#detailed)
291 297
 provides a summary of the key features of OncoSimulR. (An
... ...
@@ -295,7 +301,7 @@ https://popmodels.cancercontrol.cancer.gov/gsr/search/ or from the
295 301
 [Genetics Simulation Resources table itself](https://popmodels.cancercontrol.cancer.gov/gsr/packages/oncosimulr/#detailed),
296 302
 by moving the mouse over each term).
297 303
 
298
-
304
+\clearpage
299 305
 
300 306
 |Attribute Category     | Attribute                                     |
301 307
 |-----------------------|-----------------------------------------------|
... ...
@@ -322,7 +328,7 @@ by moving the mouse over each term).
322 328
 |&nbsp; Mutation Models|	Two-allele Mutation Model (wildtype, mutant), without back mutation|
323 329
 |&nbsp; Events Allowed|	Varying Genetic Features: change of individual mutation rates (mutator/antimutator genes)|
324 330
 |&nbsp; Spatial Structure| No Spatial Structure (perfectly mixed and no migration)|
325
-Table: (\#tab:osrfeatures) Key features of OncoSimulR. Modified from
331
+Table:(\#tab:osrfeatures) Key features of OncoSimulR. Modified from
326 332
 the original table from
327 333
 https://popmodels.cancercontrol.cancer.gov/gsr/packages/oncosimulr/#detailed
328 334
 .
... ...
@@ -485,17 +491,19 @@ g1 <- simOGraph(4, out = "rT")
485 491
 ## 2. Simulate two evolutionary trajectories
486 492
 s1 <- oncoSimulPop(10, allFitnessEffects(g1, drvNames = 1:4),
487 493
                    mc.cores = 2, ## adapt to your hardware
488
-                   seed = NULL) ## for reproducibility in this vignette
494
+                   seed = NULL) ## for reproducibility of vignette
489 495
 
490 496
 ## 3. Sample those data uniformly, and add noise
491 497
 d1 <- samplePop(s1, timeSample = "unif", propError = 0.1)
492 498
 
493
-## 4. You would now run the appropriate inferential method and compare
494
-## observed and true
499
+## 4. You would now run the appropriate inferential method and
500
+## compare observed and true
501
+
495 502
 require(Oncotree)
496 503
 fit1 <- oncotree.fit(d1)
497
-## Now, compare fitted and original. This is well beyond the scope of this
498
-## document (and OncoSimulR itself).
504
+
505
+## Now, compare fitted and original. This is well beyond the
506
+## scope of this document (and OncoSimulR itself).
499 507
 
500 508
 ```
501 509
 
... ...
@@ -532,8 +540,8 @@ RNGkind("L'Ecuyer-CMRG")
532 540
 ```{r exochs}
533 541
 ## Specify fitness effects. 
534 542
 
535
-## Numeric values arbitrary, but set the intermediate genotype 
536
-## en route to ui as mildly deleterious so there is a valley. 
543
+## Numeric values arbitrary, but set the intermediate genotype en
544
+## route to ui as mildly deleterious so there is a valley.
537 545
 
538 546
 ## As in Ochs and Desai, the ui and uv genotypes
539 547
 ## can never appear. 
... ...
@@ -545,7 +553,9 @@ od <- allFitnessEffects(
545 553
                   "u:v" = uv, "i" = i,
546 554
                   "v:-i" = -Inf, "v:i" = vi))
547 555
 
548
-## For the sake of extending this example, also turn i into a mutator gene
556
+## For the sake of extending this example, also turn i into a
557
+## mutator gene
558
+
549 559
 odm <- allMutatorEffects(noIntGenes = c("i" = 50))
550 560
 
551 561
 ## How do mutation and fitness look like for each genotype?
... ...
@@ -600,19 +610,23 @@ RNGkind("L'Ecuyer-CMRG")
600 610
 ## reference genotype or evolutionary model, or stopping criterion, 
601 611
 ## sampling procedure, or ...
602 612
 
603
-## 1. Generate a random fitness landscape, from the Rough
604
-##    Mount Fuji model, with g genes, and c ("slope" constant) and
605
-##    reference chosen randomly. Ask for a minimal number of accessible
606
-##    genotypes
613
+## 1. Generate a random fitness landscape, from the Rough Mount
614
+##    Fuji model, with g genes, and c ("slope" constant) and
615
+##    reference chosen randomly. Ask for a minimal number of
616
+##    accessible genotypes
617
+
607 618
 g <- 6
608 619
 c <- runif(1, 1/5, 5)
609 620
 rl <- rfitness(g, c = c, min_accessible_genotypes = g)
610 621
 
611
-## Plot it if you want; commented here as it takes long for a vignette
622
+## Plot it if you want; commented here as it takes long for a
623
+## vignette
624
+
612 625
 ## plot(rl)
613 626
 
614 627
 ## Obtain landscape measures from Magellan. Export to Magellan
615 628
 to_Magellan(rl, file = "rl1.txt")
629
+
616 630
 ## (Getting the statistics requires you to install Magellan,
617 631
 ## and that requires either calling the web app 
618 632
 ## (http://wwwabi.snv.jussieu.fr/public/Magellan/) or
... ...
@@ -1165,7 +1179,7 @@ version 2. Please note that **the functionality of version 1 will soon be remove
1165 1179
 
1166 1180
 
1167 1181
 
1168
-
1182
+\clearpage
1169 1183
 
1170 1184
 # Running time and space consumption of OncoSimulR {#timings}
1171 1185
 
... ...
@@ -1230,6 +1244,91 @@ some of the benchmarks is available from the
1230 1244
 repository at https://github.com/rdiaz02/OncoSimul).
1231 1245
 
1232 1246
 
1247
+```{r colnames_benchmarks, echo = FALSE, eval = TRUE}
1248
+
1249
+data(benchmark_1)
1250
+data(benchmark_1_0.05)
1251
+data(benchmark_2)
1252
+data(benchmark_3)
1253
+
1254
+colnames(benchmark_1)[
1255
+    match(c(
1256
+	"time_per_simul",
1257
+    "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1258
+	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean",
1259
+	"TotalPopSize.Max.", "keepEvery",  "Attempts.Median",
1260
+	"Attempts.Mean", "Attempts.Max.",
1261
+	"PDBaseline", "n2", "onlyCancer"),
1262
+	 colnames(benchmark_1)
1263
+	)] <- c("Elapsed Time, average per simulation (s)",
1264
+	              "Object Size, average per simulation (MB)",
1265
+				  "Number of Clones, median",
1266
+				  "Number of Iterations, median",
1267
+				  "Final Time, median",
1268
+				  "Total Population Size, median",
1269
+				   "Total Population Size, mean",
1270
+				  "Total Population Size, max.",
1271
+				  "keepEvery",
1272
+				  "Attempts until Cancer, median",
1273
+				  "Attempts until Cancer, mean",
1274
+				  "Attempts until Cancer, max.",
1275
+				  "PDBaseline", "n2", "onlyCancer"
1276
+				  )
1277
+				  
1278
+	
1279
+colnames(benchmark_1_0.05)[
1280
+    match(c("time_per_simul",
1281
+    "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1282
+	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean", 
1283
+	"TotalPopSize.Max.",
1284
+	"keepEvery",
1285
+	"PDBaseline", "n2", "onlyCancer", "Attempts.Median"),
1286
+	colnames(benchmark_1_0.05))] <- c("Elapsed Time, average per simulation (s)",
1287
+	              "Object Size, average per simulation (MB)",
1288
+				  "Number of Clones, median",
1289
+				  "Number of Iterations, median",
1290
+				  "Final Time, median",
1291
+				  "Total Population Size, median",
1292
+				  "Total Population Size, mean",
1293
+				  "Total Population Size, max.",
1294
+				  "keepEvery",
1295
+				  "PDBaseline", "n2", "onlyCancer",
1296
+				  "Attempts until Cancer, median"
1297
+				  )
1298
+
1299
+
1300
+colnames(benchmark_2)[match(c("Model", "fitness", "time_per_simul",
1301
+    "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1302
+	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean", 
1303
+	"TotalPopSize.Max."), colnames(benchmark_2))] <-  c("Model",
1304
+				  "Fitness",
1305
+	"Elapsed Time, average per simulation (s)",
1306
+	              "Object Size, average per simulation (MB)",
1307
+				  "Number of Clones, median",
1308
+				  "Number of Iterations, median",
1309
+				  "Final Time, median",
1310
+				  "Total Population Size, median",
1311
+				  "Total Population Size, mean",
1312
+				  "Total Population Size, max."
1313
+				  )	
1314
+				  
1315
+colnames(benchmark_3)[match(c("Model", "fitness", "time_per_simul",
1316
+    "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1317
+	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean", 
1318
+	"TotalPopSize.Max."), colnames(benchmark_3))] <-  c("Model",
1319
+				  "Fitness",
1320
+	"Elapsed Time, average per simulation (s)",
1321
+	              "Object Size, average per simulation (MB)",
1322
+				  "Number of Clones, median",
1323
+				  "Number of Iterations, median",
1324
+				  "Final Time, median",
1325
+				  "Total Population Size, median",
1326
+				  "Total Population Size, mean",
1327
+				  "Total Population Size, max."
1328
+				  )					  
1329
+```
1330
+
1331
+
1233 1332
 ## Exp and McFL with "detectionProb" and pancreas example {#bench1}
1234 1333
 
1235 1334
 To get familiar with some of they factors that affect time and size,
... ...
@@ -1246,9 +1345,6 @@ period are pruned and only the existing clones at the end of the
1246 1345
 simulation are returned (see details in \@ref(prune)).
1247 1346
 
1248 1347
 
1249
-```{r loadbench1, echo = FALSE, eval = TRUE} 
1250
-data(benchmark_1) 
1251
-``` 
1252 1348
 
1253 1349
 Will run `r unique(benchmark_1$Numindiv)` simulations.  The results
1254 1350
 I show are for a laptop with an 8-core Intel Xeon E3-1505M CPU,
... ...
@@ -1340,36 +1436,50 @@ summary(unlist(lapply(exp1, "[[", "TotalPopSize")))
1340 1436
 The above runs yield the following:
1341 1437
 
1342 1438
 
1439
+\blandscape
1440
+
1441
+Table: (\#tab:bench1) Benchmarks of Exp and McFL models using the default `detectionProb` with two settings of `keepEvery`. 
1343 1442
 ```{r bench1, eval=TRUE, echo = FALSE}
1344
-data(benchmark_1)
1345
-knitr::kable(benchmark_1[1:4, c("time_per_simul",
1346
-    "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1347
-	"FinalTime.Median", "TotalPopSize.Median",
1348
-	"TotalPopSize.Max.", "keepEvery")], 
1349
-    booktabs = TRUE,
1350
-	col.names = c("Elapsed Time, average per simulation (s)",
1351
-	              "Object Size, average per simulation (MB)",
1352
-				  "Number of Clones, median",
1353
-				  "Number of Iterations, median",
1354
-				  "Final Time, median",
1355
-				  "Total Population Size, median",
1356
-				  "Total Population Size, max.",
1357
-				  "keepEvery"
1358
-				  ),
1359
-    caption = "Benchmarks of Exp and McFL models using the default
1360
-	`detectionProb` with two settings of `keepEvery`.", 
1361
-	align = "c")
1443
+
1444
+panderOptions("table.split.table", 99999999)
1445
+panderOptions("table.split.cells", 900)  ## For HTML
1446
+## panderOptions("table.split.cells", 8) ## For PDF
1447
+
1448
+set.alignment('right')
1449
+panderOptions('round', 3)
1450
+				          
1451
+pander(benchmark_1[1:4, c("Elapsed Time, average per simulation (s)", 
1452
+ 	              "Object Size, average per simulation (MB)",
1453
+ 				  "Number of Clones, median",
1454
+ 				  "Number of Iterations, median",
1455
+ 				  "Final Time, median",
1456
+ 				  "Total Population Size, median",
1457
+ 				  "Total Population Size, max.",
1458
+ 				  "keepEvery")],
1459
+				  ## caption = "\\label{tab:bench1}Benchmarks of Exp and McFL  models using the default `detectionProb` with two settings of `keepEvery`."
1460
+				  )
1362 1461
 ```
1363 1462
 
1364
-The above table shows that a naive comparison (looking simply at
1365
-execution time) might conclude that the McFL model is much, much
1366
-slower than the Exp model. But that is not the complete story: using
1367
-the `detectionProb` stopping mechanism (see \@ref(detectprob)) will
1368
-lead to stopping the simulations very quickly in the exponential
1369
-model because as soon as a clone with fitness $>1$ appears it starts
1370
-growing exponentially. In fact, we can see that the number of
1371
-iterations and the final time are much smaller in the Exp than in
1372
-the McFL model. 
1463
+\elandscape
1464
+
1465
+\clearpage
1466
+
1467
+
1468
+
1469
+The above table shows that a naive comparison (looking simply at execution
1470
+time) might conclude that the McFL model is much, much slower than the Exp
1471
+model. But that is not the complete story: using the `detectionProb`
1472
+stopping mechanism (see \@ref(detectprob)) will lead to stopping the
1473
+simulations very quickly in the exponential model because as soon as a
1474
+clone with fitness $>1$ appears it starts growing exponentially. In fact,
1475
+we can see that the number of iterations and the final time are much
1476
+smaller in the Exp than in the McFL model.  We will elaborate on this
1477
+point below (section \@ref(common1)), when we discuss the setting for
1478
+`checkSizePEvery` (here left at its default value of 20): checking the
1479
+exiting condition more often (smaller `checkSizePEvery`) would probably be
1480
+justified here (notice also the very large final times) and would lead to
1481
+a sharp decrease in number of iterations and, thus, running time.
1482
+
1373 1483
 
1374 1484
 
1375 1485
 This table also shows that the `keepEvery = NA` setting, which was in effect
... ...
@@ -1451,30 +1561,38 @@ t_exp6 <- system.time(
1451 1561
 
1452 1562
 ```
1453 1563
 
1564
+\blandscape
1454 1565
 
1566
+Table: (\#tab:bench1b) Benchmarks of Exp models modifying the default `detectionProb` with two settings of `keepEvery`.
1455 1567
 ```{r bench1b, eval=TRUE, echo = FALSE}
1456
-data(benchmark_1)
1457
-knitr::kable(benchmark_1[5:8, c("time_per_simul",
1458
-    "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1459
-	"FinalTime.Median", "TotalPopSize.Median",
1460
-	"TotalPopSize.Max.", "keepEvery",
1461
-	"PDBaseline", "n2")], 
1462
-    booktabs = TRUE,
1463
-	col.names = c("Elapsed Time, average per simulation (s)",
1464
-	              "Object Size, average per simulation (MB)",
1465
-				  "Number of Clones, median",
1466
-				  "Number of Iterations, median",
1467
-				  "Final Time, median",
1468
-				  "Total Population Size, median",
1469
-				  "Total Population Size, max.",				  
1470
-				  "keepEvery",
1471
-				  "PDBaseline", "n2"
1472
-				  ),	
1473
-    caption = "Benchmarks of Exp models modifying the default
1474
-	`detectionProb` with two settings of `keepEvery`.", 
1475
-	align = "c")
1568
+panderOptions("table.split.table", 99999999)
1569
+panderOptions("table.split.cells", 900)  ## For HTML
1570
+## panderOptions("table.split.cells", 8) ## For PDF
1571
+set.alignment('right')
1572
+panderOptions('round', 2)
1573
+panderOptions('big.mark', ',')
1574
+panderOptions('digits', 2)
1575
+
1576
+pander(benchmark_1[5:8, c("Elapsed Time, average per simulation (s)",
1577
+ 	              "Object Size, average per simulation (MB)",
1578
+ 				  "Number of Clones, median",
1579
+ 				  "Number of Iterations, median",
1580
+ 				  "Final Time, median",
1581
+ 				  "Total Population Size, median",
1582
+ 				  "Total Population Size, max.",
1583
+ 				  "keepEvery",
1584
+				  "PDBaseline",
1585
+				  "n2")], 
1586
+## 				  round = c(rep(2, 3), rep(0, 7)),
1587
+## 				  digits = c(rep(2, 3), rep(1, 7)),
1588
+	  ## caption = "\\label{tab:bench1b}Benchmarks of Exp and McFL models modifying the default `detectionProb` with two settings of `keepEvery`."
1589
+    )
1590
+
1476 1591
 ```
1477 1592
 
1593
+\elandscape
1594
+
1595
+\clearpage
1478 1596
 
1479 1597
 As above,  `keepEvery = NA` (in `exp4` and `exp6`) leads to much
1480 1598
 smaller object sizes and slightly smaller numbers of clones and
... ...
@@ -1509,62 +1627,95 @@ initial population sizes) because of the dependency of death rate on total
1509 1627
 population size (see section \@ref(mcfl)).
1510 1628
 
1511 1629
 
1512
-The number of attempts until cancer was reached in the above models is
1513
-shown in the following table (the values can be obtained from any of the
1514
-above runs doing, for instance, `median(unlist(lapply(exp1, function(x)
1515
-x$other$attemptsUsed)))` ).:
1516
-
1517
-
1630
+The number of attempts until cancer was reached in the above
1631
+models is shown in the Table \@ref(tab:bench1c) (the values can be obtained from
1632
+any of the above runs doing, for instance, `median(unlist(lapply(exp1,
1633
+function(x) x$other$attemptsUsed)))` ):
1518 1634
 
1635
+Table: (\#tab:bench1c) Number of attempts until cancer.
1519 1636
 ```{r bench1c, eval=TRUE, echo = FALSE}
1520
-data(benchmark_1)
1521
-knitr::kable(benchmark_1[1:8, c("Attempts.Median"), drop = FALSE], 
1522
-    booktabs = TRUE,
1523
-	row.names = TRUE,
1524
-	col.names = "Attempts until cancer",
1525
-    caption = "Median Number of attempts until cancer.", 
1526
-	align = "r")
1637
+panderOptions("table.split.table", 99999999)
1638
+panderOptions("table.split.cells", 900)  ## For HTML
1639
+## panderOptions("table.split.cells", 8) ## For PDF
1640
+set.alignment('right')
1641
+panderOptions('round', 2)
1642
+panderOptions('big.mark', ',')
1643
+panderOptions('digits', 2)
1644
+
1645
+pander(benchmark_1[1:8, c(
1646
+"Attempts until Cancer, median", 
1647
+"Attempts until Cancer, mean", 
1648
+"Attempts until Cancer, max.", 
1649
+				  "PDBaseline",
1650
+				  "n2")], 
1651
+## 				  round = c(rep(2, 3), rep(0, 7)),
1652
+## 				  digits = c(rep(2, 3), rep(1, 7)),
1653
+	  ## caption = "\\label{tab:bench1c}Median number of attempts until cancer."
1654
+    )
1655
+## ## data(benchmark_1)
1656
+## knitr::kable(benchmark_1[1:8, c("Attempts.Median",
1657
+##                                 "PDBaseline", "n2"), drop = FALSE], 
1658
+##     booktabs = TRUE,
1659
+## 	row.names = TRUE,
1660
+## 	col.names = c("Attempts until cancer", "PDBaseline", "n2"),
1661
+##     caption = "Median number of attempts until cancer.", 
1662
+## 	align = "r")
1527 1663
 	
1528 1664
 ```
1529 1665
 
1530 1666
 
1531
-
1532
-
1667
+The McFL models finish in a single attempt. The exponential model
1668
+simulations where we can exit with small population sizes (`exp1`, `exp2`)
1669
+need many fewer attempts to reach cancer than those where large population
1670
+sizes are required (`exp3` to `exp6`). There is no relevant different
1671
+among those four, which is what we would expect: a population that has
1672
+already reached a size of 50,000 cells from an initial population size of
1673
+500 is obviously a growing population where there is at least one mutant
1674
+with positive fitness; thus, it unlikely to go extinct and therefore
1675
+having to grow up to at least 500,000 will not significantly increase the
1676
+risk of extinction.
1533 1677
 
1534 1678
 
1535 1679
 We will now rerun all of the above models with argument `onlyCancer =
1536
-FALSE`.  The results are shown below (note that the differences between
1537
-this table and table \@ref(tab:bench1) for the McFL models are due only to
1538
-sampling variation).
1680
+FALSE`.  The results are shown in Table \@ref(tab:timing3) (note that the
1681
+differences between this table and table \@ref(tab:bench1) for the McFL
1682
+models are due only to sampling variation).
1683
+
1684
+\bslandscape
1539 1685
 
1540 1686
 
1541
-Table: (\#tab:timing3) Benchmarks of models in Table \@ref(tab:bench1) and
1542
-\@ref(tab:bench1b) when run with `onlyCancer = FALSE`
1687
+Table: (\#tab:timing3) Benchmarks of models in Table \@ref(tab:bench1) and \@ref(tab:bench1b) when run with `onlyCancer = FALSE`
1543 1688
 ```{r bench1d, eval=TRUE, echo = FALSE}
1544
-data(benchmark_1)
1545
-knitr::kable(benchmark_1[9:16, c("time_per_simul",
1546
-    "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1547
-	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean", 
1548
-	"TotalPopSize.Max.",
1549
-	"keepEvery",
1550
-	"PDBaseline", "n2")], 
1551
-    booktabs = TRUE,
1552
-	col.names = c("Elapsed Time, average per simulation (s)",
1553
-	              "Object Size, average per simulation (MB)",
1554
-				  "Number of Clones, median",
1555
-				  "Number of Iterations, median",
1556
-				  "Final Time, median",
1557
-				  "Total Population Size, median",
1689
+panderOptions("table.split.table", 99999999)
1690
+panderOptions("table.split.cells", 900)  ## For HTML
1691
+## panderOptions("table.split.cells", 8) ## For PDF
1692
+panderOptions("table.split.cells", 15) ## does not fit otherwise
1693
+set.alignment('right')
1694
+panderOptions('round', 3)
1695
+
1696
+pander(benchmark_1[9:16, 
1697
+    c("Elapsed Time, average per simulation (s)",
1698
+ 	              "Object Size, average per simulation (MB)",
1699
+ 				  "Number of Clones, median",
1700
+ 				  "Number of Iterations, median",
1701
+ 				  "Final Time, median",
1702
+ 				  "Total Population Size, median",
1558 1703
 				  "Total Population Size, mean",
1559
-				  "Total Population Size, max.",
1560
-				  "keepEvery",
1561
-				  "PDBaseline", "n2"
1562
-				  ),
1563
-##    caption = "Benchmarks of models in Table \@ref(tab:bench1) and
1564
-##   \@ref(tab:bench1b) when run with `onlyCancer = FALSE`", 
1565
-	align = "c")
1704
+ 				  "Total Population Size, max.",
1705
+ 				  "keepEvery",
1706
+				  "PDBaseline",
1707
+				  "n2")],
1708
+## caption = "\\label{tab:timing3} Benchmarks of models in Table \\@ref(tab:bench1) and \\@ref(tab:bench1b) when run with `onlyCancer = FALSE`."
1709
+				  )	
1710
+	
1566 1711
 ```
1567 1712
 
1713
+\eslandscape
1714
+
1715
+\clearpage
1716
+
1717
+
1718
+
1568 1719
 
1569 1720
 Now most simulations under the exponential model end up in extinction, as
1570 1721
 seen by the median population size of 0 (but not all, as the mean and
... ...
@@ -1576,47 +1727,101 @@ on the question being asked (see, for example, section \@ref(exbauer) for
1576 1727
 a question where we will naturally want to use `onlyCancer = FALSE`).
1577 1728
 
1578 1729
 
1730
+To make it easier to compare results with those of the next section, Table
1731
+\@ref(tab:allr1bck) shows all the runs so far.
1732
+
1733
+
1734
+\bslandscape
1735
+
1736
+Table: (\#tab:allr1bck) Benchmarks of all models in Tables \@ref(tab:bench1), \@ref(tab:bench1b) and \@ref(tab:timing3).  
1737
+```{r bench1dx0, eval=TRUE, echo = FALSE}
1738
+panderOptions("table.split.table", 99999999)
1739
+## panderOptions("table.split.cells", 900)  ## For HTML
1740
+panderOptions("table.split.cells", 19)
1741
+
1742
+set.alignment('right') 
1743
+panderOptions('round', 3)
1744
+	
1745
+pander(benchmark_1[ , c("Elapsed Time, average per simulation (s)",
1746
+ 	              "Object Size, average per simulation (MB)", 
1747
+				  "Number of Clones, median", 
1748
+				  "Number of Iterations, median", 
1749
+				  "Final Time, median", "Total Population Size, median", 
1750
+				  "Total Population Size, mean", "Total Population Size, max.",
1751
+ 	              "keepEvery", "PDBaseline", "n2", "onlyCancer")], 
1752
+				  ## caption = "\\label{tab:allr1bck}Benchmarks of all models in Tables \\@ref(tab:bench1), \\@ref(tab:bench1b)  and \\@ref(tab:timing3)."  
1753
+				  )  
1754
+```
1755
+
1756
+\eslandscape
1757
+
1758
+\clearpage
1759
+
1760
+
1761
+
1579 1762
 ### Changing fitness: $s=0.1$ and $s=0.05$ {#bench1xf}
1580 1763
 
1581 1764
 In the above fitness specification the fitness effect of each gene (when
1582 1765
 its restrictions are satisfied) is $s = 0.1$ (see section \@ref(numfit)
1583 1766
 for details). Here we rerun all the above benchmarks using $s= 0.05$ and
1584
-results are shown below in Table \@(tab:timing3xf); the results from these
1767
+results are shown below in Table \@ref(tab:timing3xf); the results from these
1585 1768
 benchmarks are available as `data(benchmark_1_0.05)`:
1586 1769
 
1770
+\bslandscape
1587 1771
 
1588
-Table: (\#tab:timing3xf) Benchmarks of all models in Tables \@ref(tab:bench1),
1589
-\@ref(tab:bench1b) and \@ref(tab:timing3) using $s=0.05$ (instead of
1590
-$s=0.1$).
1772
+Table: (\#tab:timing3xf) Benchmarks of all models in Table \@ref(tab:allr1bck) using $s=0.05$ (instead of $s=0.1$).
1591 1773
 ```{r bench1dx, eval=TRUE, echo = FALSE}
1592
-data(benchmark_1_0.05)
1593
-knitr::kable(benchmark_1_0.05[, c("time_per_simul",
1594
-    "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1595
-	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean", 
1596
-	"TotalPopSize.Max.",
1597
-	"keepEvery",
1598
-	"PDBaseline", "n2", "onlyCancer")], 
1599
-    booktabs = TRUE,
1600
-	col.names = c("Elapsed Time, average per simulation (s)",
1601
-	              "Object Size, average per simulation (MB)",
1602
-				  "Number of Clones, median",
1603
-				  "Number of Iterations, median",
1604
-				  "Final Time, median",
1605
-				  "Total Population Size, median",
1606
-				  "Total Population Size, mean",
1607
-				  "Total Population Size, max.",				  
1608
-				  "keepEvery",
1609
-				  "PDBaseline", "n2", "onlyCancer"
1610
-				  ),
1611
-##    caption = "Benchmarks of models in Table \@ref(tab:bench1) and
1612
-##   \@ref(tab:bench1b) when run with `onlyCancer = FALSE`", 
1613
-	align = "c")
1774
+## data(benchmark_1_0.05)
1775
+## knitr::kable(benchmark_1_0.05[, c("time_per_simul",
1776
+##     "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1777
+## 	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean", 
1778
+## 	"TotalPopSize.Max.",
1779
+## 	"keepEvery",
1780
+## 	"PDBaseline", "n2", "onlyCancer")], 
1781
+##     booktabs = TRUE,
1782
+## 	col.names = c("Elapsed Time, average per simulation (s)",
1783
+## 	              "Object Size, average per simulation (MB)",
1784
+## 				  "Number of Clones, median",
1785
+## 				  "Number of Iterations, median",
1786
+## 				  "Final Time, median",
1787
+## 				  "Total Population Size, median",
1788
+## 				  "Total Population Size, mean",
1789
+## 				  "Total Population Size, max.",				  
1790
+## 				  "keepEvery",
1791
+## 				  "PDBaseline", "n2", "onlyCancer"
1792
+## 				  ),
1793
+## ##    caption = "Benchmarks of models in Table \@ref(tab:bench1) and
1794
+## ##   \@ref(tab:bench1b) when run with `onlyCancer = FALSE`", 
1795
+## 	align = "c")
1796
+	
1797
+panderOptions("table.split.table", 99999999)
1798
+## panderOptions("table.split.cells", 900)  ## For HTML
1799
+panderOptions("table.split.cells", 19)
1800
+
1801
+set.alignment('right') 
1802
+panderOptions('round', 3)
1803
+	
1804
+pander(benchmark_1_0.05[ , c("Elapsed Time, average per simulation (s)",
1805
+ 	              "Object Size, average per simulation (MB)", 
1806
+				  "Number of Clones, median", 
1807
+				  "Number of Iterations, median", 
1808
+				  "Final Time, median", 
1809
+				  "Total Population Size, median", 
1810
+				  "Total Population Size, mean", "Total Population Size, max.",
1811
+ 	              "keepEvery", "PDBaseline", "n2", "onlyCancer")], 
1812
+ 	              ## caption = "\\label{tab:timing3xf}Benchmarks of all models in Table \\@ref(tab:allr1bck) using $s=0.05$ (instead of $s=0.1$)."  
1813
+)  
1814
+				  
1614 1815
 ```
1615 1816
 
1817
+\eslandscape
1818
+
1819
+\clearpage
1820
+
1616 1821
 As expected, having a smaller $s$ leads to slower processes in most cases,
1617 1822
 since it takes longer to reach the exiting conditions sooner. Particularly
1618 1823
 noticeable are the runs for the McFL models (notice the increases in
1619
-population size and number of iterations). 
1824
+population size and number of iterations ---see also below). 
1620 1825
 
1621 1826
 
1622 1827
 That is not the case, however, for `exp5` and `exp6` (and `exp5_noc` and
... ...
@@ -1651,6 +1856,15 @@ additional iterations. They exit sooner in terms of time periods,
1651 1856
 but they do much more work before arriving there.
1652 1857
 
1653 1858
 
1859
+The setting of `checkSizePEvery` is also having a huge effect on the McFL
1860
+model simulations (the number of iterations is $>10^6$). Even more than in
1861
+the previous section, checking the exiting condition more often (smaller
1862
+`checkSizePEvery`) would probably be justified here (notice also the very
1863
+large final times) and would lead to a sharp decrease in number of
1864
+iterations and, thus, running time.
1865
+
1866
+
1867
+
1654 1868
 The moral here is that in complex simulations like this, the effects
1655 1869
 of some parameters ($s$ in this case) might look counter-intuitive
1656 1870
 at first. Thus the need to "experiment before launching a large
... ...
@@ -1680,34 +1894,41 @@ pancr <- allFitnessEffects(
1680 1894
 	             "MLL3", "TGFBR2", "PXDN"))
1681 1895
 
1682 1896
 
1683
-## Random fitness landscape with 6 genes 
1897
+## Random fitness landscape with 6 genes
1898
+## At least 50 accessible genotypes
1684 1899
 rfl6 <- rfitness(6, min_accessible_genotypes = 50)
1685
-attributes(rfl6)$accessible_genotypes ## How many actually accessible
1900
+attributes(rfl6)$accessible_genotypes ## How many accessible
1686 1901
 rf6 <- allFitnessEffects(genotFitness = rfl6)
1687 1902
 
1688 1903
 
1689 1904
 ## Random fitness landscape with 12 genes
1905
+## At least 200 accessible genotypes
1690 1906
 rfl12 <- rfitness(12, min_accessible_genotypes = 200)
1691
-attributes(rfl12)$accessible_genotypes ## How many actually accessible
1907
+attributes(rfl12)$accessible_genotypes ## How many accessible
1692 1908
 rf12 <- allFitnessEffects(genotFitness = rfl12)
1693 1909
 
1694 1910
 
1695 1911
 
1696 1912
 
1697 1913
 ## Independent genes; positive fitness from exponential distribution
1698
-## mean around 0.1, and negative from exponential with mean around 0.02.
1699
-## Half positive, half negative
1914
+## mean around 0.1, and negative from exponential with mean around 
1915
+## 0.02. Half of genes positive fitness effects, half negative.
1916
+
1700 1917
 ng <- 200
1701
-re_200 <- allFitnessEffects(noIntGenes = c(rexp(ng/2, 10), -rexp(ng/2, 50)))
1918
+re_200 <- allFitnessEffects(noIntGenes = c(rexp(ng/2, 10), 
1919
+                                           -rexp(ng/2, 50)))
1702 1920
 
1703 1921
 ng <- 500
1704
-re_500 <- allFitnessEffects(noIntGenes = c(rexp(ng/2, 10), -rexp(ng/2, 50)))
1922
+re_500 <- allFitnessEffects(noIntGenes = c(rexp(ng/2, 10), 
1923
+                                           -rexp(ng/2, 50)))
1705 1924
 
1706 1925
 ng <- 2000
1707
-re_2000 <- allFitnessEffects(noIntGenes = c(rexp(ng/2, 10), -rexp(ng/2, 50)))
1926
+re_2000 <- allFitnessEffects(noIntGenes = c(rexp(ng/2, 10), 
1927
+                                            -rexp(ng/2, 50)))
1708 1928
 
1709 1929
 ng <- 4000
1710
-re_4000 <- allFitnessEffects(noIntGenes = c(rexp(ng/2, 10), -rexp(ng/2, 50)))
1930
+re_4000 <- allFitnessEffects(noIntGenes = c(rexp(ng/2, 10), 
1931
+                                            -rexp(ng/2, 50)))
1711 1932
 
1712 1933
 ```
1713 1934
 
... ...
@@ -1769,12 +1990,12 @@ oncoSimulPop(Nindiv,
1769 1990
 
1770 1991
 
1771 1992
 For the exponential model we will stop simulations when the populations
1772
-gets $>10^6$ cells (simulations start from 500 cells). For the McFarland
1993
+have $>10^6$ cells (simulations start from 500 cells). For the McFarland
1773 1994
 model we will use the `detectionProb` mechanism (see section
1774 1995
 \@ref(detectprob) for details); we could have used as stopping mechanism
1775 1996
 `detectionSize = 2 * initSize` (which would be basically equivalent to
1776 1997
 reaching cancer, as argued in [@McFarland2013]) but we want to provide
1777
-further runs under the `detectionProb` mechanism. We will start from 1000
1998
+further examples under the `detectionProb` mechanism. We will start from 1000
1778 1999
 cells, not 500 (starting from 1000 we almost always reach cancer in a
1779 2000
 single execution).
1780 2001
 
... ...
@@ -1818,42 +2039,69 @@ met.
1818 2039
 
1819 2040
 
1820 2041
 
1821
-```{r loadbench2usual, echo = FALSE, eval = TRUE} 
1822
-data(benchmark_2) 
1823
-``` 
2042
+<!-- ```{r loadbench2usual, echo = FALSE, eval = TRUE}  -->
2043
+<!-- data(benchmark_2)  -->
2044
+<!-- ```  -->
1824 2045
 
1825 2046
 The results of the benchmarks, using `r unique(benchmark_2$Numindiv)`
1826 2047
 individual simulations, are shown in Table \@ref(tab:timingusual).
1827 2048
 
1828 2049
 
2050
+\blandscape
1829 2051
 
1830
-Table: (\#tab:timingusual) Benchmarks under some common use cases,
1831
-set 1.
2052
+Table: (\#tab:timingusual) Benchmarks under some common use cases, set 1.
1832 2053
 ```{r benchustable, eval=TRUE, echo = FALSE}
1833
-data(benchmark_2)
1834
-
1835
-knitr::kable(benchmark_2[, c("Model", "fitness", "time_per_simul",
1836
-    "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1837
-	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean", 
1838
-	"TotalPopSize.Max.")], 
1839
-    booktabs = TRUE,
1840
-	col.names = c("Model",
1841
-				  "Fitness",
1842
-	"Elapsed Time, average per simulation (s)",
1843
-	              "Object Size, average per simulation (MB)",
1844
-				  "Number of Clones, median",
1845
-				  "Number of Iterations, median",
1846
-				  "Final Time, median",
1847
-				  "Total Population Size, median",
1848
-				  "Total Population Size, mean",
1849
-				  "Total Population Size, max."
1850
-				  ),
1851
-	align = "c")
2054
+## data(benchmark_2)
2055
+
2056
+## knitr::kable(benchmark_2[, c("Model", "fitness", "time_per_simul",
2057
+##     "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
2058
+## 	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean", 
2059
+## 	"TotalPopSize.Max.")], 
2060
+##     booktabs = TRUE,
2061
+## 	col.names = c("Model",
2062
+## 				  "Fitness",
2063
+## 	"Elapsed Time, average per simulation (s)",
2064
+## 	              "Object Size, average per simulation (MB)",
2065
+## 				  "Number of Clones, median",
2066
+## 				  "Number of Iterations, median",
2067
+## 				  "Final Time, median",
2068
+## 				  "Total Population Size, median",
2069
+## 				  "Total Population Size, mean",
2070
+## 				  "Total Population Size, max."
2071
+## 				  ),
2072
+## 	align = "c")
2073
+
2074
+panderOptions("table.split.table", 99999999)
2075
+panderOptions("table.split.cells", 900)  ## For HTML
2076
+## panderOptions("table.split.cells", 8) ## For PDF
2077
+
2078
+## set.alignment('right', row.names = 'center')
2079
+panderOptions('table.alignment.default', 'right')
2080
+
2081
+panderOptions('round', 3)
2082
+
2083
+pander(benchmark_2[ , c(
2084
+    "Model", "Fitness",
2085
+    "Elapsed Time, average per simulation (s)",
2086
+ 	              "Object Size, average per simulation (MB)",
2087
+ 				  "Number of Clones, median",
2088
+ 				  "Number of Iterations, median",
2089
+ 				  "Final Time, median",
2090
+ 				  "Total Population Size, median",
2091
+ 				  "Total Population Size, mean",				  
2092
+ 				  "Total Population Size, max.")], 
2093
+				  justify = c('left', 'left', rep('right', 8)),
2094
+				  ## caption = "\\label{tab:timingusual}Benchmarks under some common use cases, set 1." 
2095
+				  )	
2096
+	
1852 2097
 ```
1853 2098
 
2099
+\elandscape
2100
+
2101
+\clearpage
1854 2102
 
1855 2103
 In most cases, simulations run reasonably fast (under 0.1 seconds per
1856
-individual simulation) and the return objects are small. In will only
2104
+individual simulation) and the return objects are small. I will only
1857 2105
 focus on a few cases.
1858 2106
 
1859 2107
 The McFL model with random fitness landscape `rf12` and with `pancr` does
... ...
@@ -1927,29 +2175,56 @@ output in the 'miscell-files/vignette_bench_Rout' directory of the
1927 2175
 main OncoSimul repository at https://github.com/rdiaz02/OncoSimul.
1928 2176
 The data are available as `data(benchmark_3)`.
1929 2177
 	
1930
-Table: (\#tab:timingusual2) Benchmarks under some common use cases,
1931
-set 2.	
2178
+\blandscape
2179
+
2180
+Table: (\#tab:timingusual2) Benchmarks under some common use cases, set 2.	
1932 2181
 ```{r benchustable2, eval=TRUE, echo = FALSE}
1933
-data(benchmark_3)
2182
+## data(benchmark_3)
2183
+
2184
+## knitr::kable(benchmark_3[, c("Model", "fitness", "time_per_simul",
2185
+##     "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
2186
+## 	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean", 
2187
+## 	"TotalPopSize.Max.")], 
2188
+##     booktabs = TRUE,
2189
+## 	col.names = c("Model",
2190
+## 				  "Fitness", "Elapsed Time, average per simulation (s)",
2191
+## 	              "Object Size, average per simulation (MB)",
2192
+## 				  "Number of Clones, median",
2193
+## 				  "Number of Iterations, median",
2194
+## 				  "Final Time, median",
2195
+## 				  "Total Population Size, median",
2196
+## 				  "Total Population Size, mean",
2197
+## 				  "Total Population Size, max."
2198
+## 				  ),
2199
+## 	align = "c")
2200
+
2201
+panderOptions("table.split.table", 99999999)
2202
+panderOptions("table.split.cells", 900)  ## For HTML
2203
+## panderOptions("table.split.cells", 8) ## For PDF
2204
+
2205
+
2206
+panderOptions('round', 3)
2207
+panderOptions('table.alignment.default', 'right')
2208
+
2209
+pander(benchmark_3[ , c(
2210
+    "Model", "Fitness",
2211
+    "Elapsed Time, average per simulation (s)",
2212
+ 	              "Object Size, average per simulation (MB)",
2213
+ 				  "Number of Clones, median",
2214
+ 				  "Number of Iterations, median",
2215
+ 				  "Final Time, median",
2216
+ 				  "Total Population Size, median",
2217
+ 				  "Total Population Size, mean",				  
2218
+ 				  "Total Population Size, max.")],
2219
+				  justify = c('left', 'left', rep('right', 8)),
2220
+				  ## caption = "\\label{tab:timingusual2}Benchmarks under some common use cases, set 2."
2221
+				  )	
2222
+```
1934 2223
 
1935
-knitr::kable(benchmark_3[, c("Model", "fitness", "time_per_simul",
1936
-    "size_mb_per_simul", "NumClones.Median", "NumIter.Median",
1937
-	"FinalTime.Median", "TotalPopSize.Median", "TotalPopSize.Mean", 
1938
-	"TotalPopSize.Max.")], 
1939
-    booktabs = TRUE,
1940
-	col.names = c("Model",
1941
-				  "Fitness", "Elapsed Time, average per simulation (s)",
1942
-	              "Object Size, average per simulation (MB)",
1943
-				  "Number of Clones, median",
1944
-				  "Number of Iterations, median",
1945
-				  "Final Time, median",
1946
-				  "Total Population Size, median",
1947
-				  "Total Population Size, mean",
1948
-				  "Total Population Size, max."
1949
-				  ),
1950
-	align = "c")
2224
+\elandscape
2225
+
2226
+\clearpage
1951 2227
 
1952
-```
1953 2228
 
1954 2229
 Since we increased the maximum final time and forced runs to "reach
1955 2230
 cancer" the McFL run with the pancreas fitness specification takes a bit
... ...
@@ -1969,7 +2244,6 @@ take longer than their McFL counterparts) and the number of clones created
1969 2244
 is much smaller.
1970 2245
 
1971 2246
 
1972
-
1973 2247
 ## Can we use a large number of genes? {#lnum}
1974 2248
 
1975 2249
 Yes. In fact, in OncoSimulR there is no pre-set limit on genome
... ...
@@ -1996,18 +2270,16 @@ stop when the population grows over $1e6$ individuals:
1996 2270
 ```{r exp10000, echo = TRUE, eval = FALSE}
1997 2271
 ng <- 10000
1998 2272
 u <- allFitnessEffects(noIntGenes = c(rep(0.1, ng/2), rep(-0.1, ng/2)))
1999
-t_e_10000 <- system.time(e_10000 <- oncoSimulPop(5,
2000
-                                                 u,
2001
-                                                 model = "Exp",
2002
-                                                 mu = 1e-7,
2003
-                                                 detectionSize = 1e6,
2004
-                                                 detectionDrivers = NA,
2005
-                                                 detectionProb = NA,
2006
-                                                 keepPhylog = TRUE,
2007
-                                                 onlyCancer = FALSE,
2008
-                                                 mutationPropGrowth = TRUE,
2009
-                                                 mc.cores = 1
2010
-                                ))
2273
+
2274
+t_e_10000 <- system.time(
2275
+    e_10000 <- oncoSimulPop(5, u, model = "Exp", mu = 1e-7,
2276
+                            detectionSize = 1e6,
2277
+                            detectionDrivers = NA,
2278
+                            detectionProb = NA,
2279
+                            keepPhylog = TRUE,
2280
+                            onlyCancer = FALSE,
2281
+                            mutationPropGrowth = TRUE,
2282
+                            mc.cores = 1))
2011 2283
 ```
2012 2284
 
2013 2285
 
... ...
@@ -2044,19 +2316,20 @@ NA` argument (this setting was explained in detail in section
2044 2316
 
2045 2317
 
2046 2318
 ```{r exp10000b, eval = FALSE, echo = TRUE}
2047
-t_e_10000b <- system.time(e_10000b <- oncoSimulPop(5,
2048
-                                                   u,
2049
-                                                   model = "Exp",
2050
-                                                   mu = 1e-7,
2051
-                                                   detectionSize = 1e6,
2052
-                                                   detectionDrivers = NA,
2053
-                                                   detectionProb = NA,
2054
-                                                   keepPhylog = TRUE,
2055
-                                                   onlyCancer = FALSE,
2056
-                                                   keepEvery = NA,
2057
-                                                   mutationPropGrowth = TRUE,
2058
-                                                   mc.cores = 1
2059
-                                ))
2319
+t_e_10000b <- system.time(
2320
+    e_10000b <- oncoSimulPop(5,
2321
+                             u,
2322
+                             model = "Exp",
2323
+                             mu = 1e-7,
2324
+                             detectionSize = 1e6,
2325
+                             detectionDrivers = NA,
2326
+                             detectionProb = NA,
2327
+                             keepPhylog = TRUE,
2328
+                             onlyCancer = FALSE,
2329
+                             keepEvery = NA,
2330
+                             mutationPropGrowth = TRUE,
2331
+                             mc.cores = 1
2332
+                             ))
2060 2333
 
2061 2334
 ```
2062 2335
 
... ...
@@ -2089,19 +2362,20 @@ reasonable decision depends on the problem; see also below.
2089 2362
 ```{r exp50000, echo = TRUE, eval = FALSE}
2090 2363
 ng <- 50000
2091 2364
 u <- allFitnessEffects(noIntGenes = c(rep(0.1, ng/2), rep(-0.1, ng/2)))
2092
-t_e_50000 <- system.time(e_50000 <- oncoSimulPop(5,
2093
-                                                 u,
2094
-                                                 model = "Exp",
2095
-                                                 mu = 1e-7,
2096
-                                                 detectionSize = 1e6,
2097
-                                                 detectionDrivers = NA,
2098
-                                                 detectionProb = NA,
2099
-                                                 keepPhylog = TRUE,
2100
-                                                 onlyCancer = FALSE,
2101
-                                                 keepEvery = NA,
2102
-                                                 mutationPropGrowth = FALSE,
2103
-                                                 mc.cores = 1
2104
-                                                 ))
2365
+t_e_50000 <- system.time(
2366
+    e_50000 <- oncoSimulPop(5,
2367
+                            u,
2368
+                            model = "Exp",
2369
+                            mu = 1e-7,
2370
+                            detectionSize = 1e6,
2371
+                            detectionDrivers = NA,
2372
+                            detectionProb = NA,
2373
+                            keepPhylog = TRUE,
2374
+                            onlyCancer = FALSE,
2375
+                            keepEvery = NA,
2376
+                            mutationPropGrowth = FALSE,
2377
+                            mc.cores = 1
2378
+                            ))
2105 2379
 
2106 2380
 
2107 2381
 t_e_50000
... ...
@@ -2131,19 +2405,20 @@ What if we had not pruned?
2131 2405
 ```{r exp50000np, echo = TRUE, eval = FALSE}
2132 2406
 ng <- 50000
2133 2407
 u <- allFitnessEffects(noIntGenes = c(rep(0.1, ng/2), rep(-0.1, ng/2)))
2134
-t_e_50000np <- system.time(e_50000np <- oncoSimulPop(5,
2135
-                                                 u,
2136
-                                                 model = "Exp",
2137
-                                                 mu = 1e-7,
2138
-                                                 detectionSize = 1e6,
2139
-                                                 detectionDrivers = NA,
2140
-                                                 detectionProb = NA,
2141
-                                                 keepPhylog = TRUE,
2142
-                                                 onlyCancer = FALSE,
2143
-                                                 keepEvery = 1,
2144
-                                                 mutationPropGrowth = FALSE,
2145
-                                                 mc.cores = 1
2146
-                                                 ))
2408
+t_e_50000np <- system.time(
2409
+    e_50000np <- oncoSimulPop(5,
2410
+                              u,
2411
+                              model = "Exp",
2412
+                              mu = 1e-7,
2413
+                              detectionSize = 1e6,
2414
+                              detectionDrivers = NA,
2415
+                              detectionProb = NA,
2416
+                              keepPhylog = TRUE,
2417
+                              onlyCancer = FALSE,
2418
+                              keepEvery = 1,
2419
+                              mutationPropGrowth = FALSE,
2420
+                              mc.cores = 1
2421
+                              ))
2147 2422
 
2148 2423
 t_e_50000np
2149 2424
 ##   user  system elapsed
... ...
@@ -2176,19 +2451,20 @@ What about the `mutationPropGrowth` setting? We will rerun the example in
2176 2451
 ng <- 50000
2177 2452
 u <- allFitnessEffects(noIntGenes = c(rep(0.1, ng/2), rep(-0.1, ng/2)))
2178 2453
 
2179
-t_e_50000c <- system.time(e_50000c <- oncoSimulPop(5,
2180
-                                                 u,
2181
-                                                 model = "Exp",
2182
-                                                 mu = 1e-7,
2183
-                                                 detectionSize = 1e6,
2184
-                                                 detectionDrivers = NA,
2185
-                                                 detectionProb = NA,
2186
-                                                 keepPhylog = TRUE,
2187
-                                                 onlyCancer = FALSE,
2188
-                                                 keepEvery = NA,
2189
-                                                 mutationPropGrowth = TRUE,
2190
-                                                 mc.cores = 1
2191
-                                                 ))
2454
+t_e_50000c <- system.time(
2455
+    e_50000c <- oncoSimulPop(5,
2456
+                             u,
2457
+                             model = "Exp",
2458
+                             mu = 1e-7,
2459
+                             detectionSize = 1e6,
2460
+                             detectionDrivers = NA,
2461
+                             detectionProb = NA,
2462
+                             keepPhylog = TRUE,
2463
+                             onlyCancer = FALSE,
2464
+                             keepEvery = NA,
2465
+                             mutationPropGrowth = TRUE,
2466
+                             mc.cores = 1
2467
+                             ))
2192 2468
 
2193 2469
 t_e_50000c
2194 2470
 ##    user  system elapsed 
... ...
@@ -2238,19 +2514,20 @@ Let's start with  `mutationPropGrowth = FALSE` and `keepEvery = NA`:
2238 2514
 ng <- 50000
2239 2515
 u <- allFitnessEffects(noIntGenes = c(rep(0.1, ng/2), rep(-0.1, ng/2)))
2240 2516
 
2241
-t_mc_50000_nmpg <- system.time(mc_50000_nmpg <- oncoSimulPop(5,
2242
-                                                   u,
2243
-                                                   model = "McFL",
2244
-                                                   mu = 1e-7,
2245
-                                                   detectionSize = 1e6,
2246
-                                                   detectionDrivers = NA,
2247
-                                                   detectionProb = NA,
2248
-                                                   keepPhylog = TRUE,
2249
-                                                   onlyCancer = FALSE,
2250
-                                                   keepEvery = NA,
2251
-                                                   mutationPropGrowth = FALSE,
2252
-                                                   mc.cores = 1
2253
-                                                   ))
2517
+t_mc_50000_nmpg <- system.time(
2518
+    mc_50000_nmpg <- oncoSimulPop(5,
2519
+                                  u,
2520
+                                  model = "McFL",
2521
+                                  mu = 1e-7,
2522
+                                  detectionSize = 1e6,
2523
+                                  detectionDrivers = NA,
2524
+                                  detectionProb = NA,
2525
+                                  keepPhylog = TRUE,
2526
+                                  onlyCancer = FALSE,
2527
+                                  keepEvery = NA,
2528
+                                  mutationPropGrowth = FALSE,
2529
+                                  mc.cores = 1
2530
+                                  ))
2254 2531
 t_mc_50000_nmpg
2255 2532
 ##   user  system elapsed 
2256 2533
 ##  30.46    0.54   31.01 
... ...
@@ -2277,19 +2554,20 @@ Setting `keepEvery = 1` (i.e., keeping track of clones with an
2277 2554
 interval of 1):
2278 2555
 
2279 2556
 ```{r mc50000_kp, echo = TRUE, eval = FALSE}
2280
-t_mc_50000_nmpg_k <- system.time(mc_50000_nmpg_k <- oncoSimulPop(5,
2281
-                                                   u,
2282
-                                                   model = "McFL",
2283
-                                                   mu = 1e-7,
2284
-                                                   detectionSize = 1e6,
2285
-                                                   detectionDrivers = NA,
2286
-                                                   detectionProb = NA,
2287
-                                                   keepPhylog = TRUE,
2288
-                                                   onlyCancer = FALSE,
2289
-                                                   keepEvery = 1,
2290
-                                                   mutationPropGrowth = FALSE,
2291
-                                                   mc.cores = 1
2292
-                                                   ))
2557
+t_mc_50000_nmpg_k <- system.time(
2558
+    mc_50000_nmpg_k <- oncoSimulPop(5,
2559
+                                    u,
2560
+                                    model = "McFL",
2561
+                                    mu = 1e-7,
2562
+                                    detectionSize = 1e6,
2563
+                                    detectionDrivers = NA,
2564
+                                    detectionProb = NA,
2565
+                                    keepPhylog = TRUE,
2566
+                                    onlyCancer = FALSE,
2567
+                                    keepEvery = 1,
2568
+                                    mutationPropGrowth = FALSE,
2569
+                                    mc.cores = 1
2570
+                                    ))
2293 2571
 
2294 2572
 t_mc_50000_nmpg_k
2295 2573
 ##    user  system elapsed 
... ...
@@ -2323,19 +2601,20 @@ detection size by a factor of 3:
2323 2601
 ng <- 50000
2324 2602
 u <- allFitnessEffects(noIntGenes = c(rep(0.1, ng/2), rep(-0.1, ng/2)))
2325 2603
 
2326
-t_mc_50000_nmpg_3e6 <- system.time(mc_50000_nmpg_3e6 <- oncoSimulPop(5,
2327
-                                                   u,
2328
-                                                   model = "McFL",
2329
-                                                   mu = 1e-7,
2330
-                                                   detectionSize = 3e6,
2331
-                                                   detectionDrivers = NA,
2332
-                                                   detectionProb = NA,
2333
-                                                   keepPhylog = TRUE,
2334
-                                                   onlyCancer = FALSE,
2335
-                                                   keepEvery = NA,
2336
-                                                   mutationPropGrowth = FALSE,
2337
-                                                   mc.cores = 1
2338
-                                                   ))
2604
+t_mc_50000_nmpg_3e6 <- system.time(
2605
+    mc_50000_nmpg_3e6 <- oncoSimulPop(5,
2606
+                                      u,
2607
+                                      model = "McFL",
2608
+                                      mu = 1e-7,
2609
+                                      detectionSize = 3e6,
2610
+                                      detectionDrivers = NA,
2611
+                                      detectionProb = NA,
2612
+                                      keepPhylog = TRUE,
2613
+                                      onlyCancer = FALSE,
2614
+                                      keepEvery = NA,
2615
+                                      mutationPropGrowth = FALSE,
2616
+                                      mc.cores = 1
2617
+                                      ))
2339 2618
 t_mc_50000_nmpg_3e6
2340 2619
 ##    user  system elapsed 
2341 2620
 ##  77.240   1.064  78.308 
... ...
@@ -2367,19 +2646,20 @@ Let us use the same `detectionSize = 1e6` as in the first example
2367 2646
 ng <- 50000
2368 2647
 u <- allFitnessEffects(noIntGenes = c(rep(0.1, ng/2), rep(-0.1, ng/2)))
2369 2648
 
2370
-t_mc_50000_nmpg_5mu <- system.time(mc_50000_nmpg_5mu <- oncoSimulPop(5,
2371
-                                                   u,
2372
-                                                   model = "McFL",
2373
-                                                   mu = 5e-7,
2374
-                                                   detectionSize = 1e6,
2375
-                                                   detectionDrivers = NA,
2376
-                                                   detectionProb = NA,
2377
-                                                   keepPhylog = TRUE,
2378
-                                                   onlyCancer = FALSE,
2379
-                                                   keepEvery = NA,
2380
-                                                   mutationPropGrowth = FALSE,
2381
-                                                   mc.cores = 1
2382
-                                                   ))
2649
+t_mc_50000_nmpg_5mu <- system.time(
2650
+    mc_50000_nmpg_5mu <- oncoSimulPop(5,
2651
+                                      u,
2652
+                                      model = "McFL",
2653
+                                      mu = 5e-7,
2654
+                                      detectionSize = 1e6,
2655
+                                      detectionDrivers = NA,
2656
+                                      detectionProb = NA,
2657
+                                      keepPhylog = TRUE,
2658
+                                      onlyCancer = FALSE,
2659
+                                      keepEvery = NA,
2660
+                                      mutationPropGrowth = FALSE,
2661
+                                      mc.cores = 1
2662
+                                      ))
2383 2663
 
2384 2664
 t_mc_50000_nmpg_5mu
2385 2665
 ##    user  system elapsed 
... ...
@@ -2415,19 +2695,20 @@ with further details in \@ref(prune)).
2415 2695
 Finally, let's run the above example but with `keepEvery = 1`:
2416 2696
 
2417 2697
 ```{r mcf5muk, echo = TRUE, eval = FALSE}
2418
-t_mc_50000_nmpg_5mu_k <- system.time(mc_50000_nmpg_5mu_k <- oncoSimulPop(5,
2419
-                                                   u,
2420
-                                                   model = "McFL",
2421
-                                                   mu = 5e-7,
2422
-                                                   detectionSize = 1e6,
2423
-                                                   detectionDrivers = NA,
2424
-                                                   detectionProb = NA,
2425
-                                                   keepPhylog = TRUE,
2426
-                                                   onlyCancer = FALSE,
2427
-                                                   keepEvery = 1,
2428
-                                                   mutationPropGrowth = FALSE,
2429
-                                                   mc.cores = 1
2430
-                                                   ))
2698
+t_mc_50000_nmpg_5mu_k <- system.time(
2699
+    mc_50000_nmpg_5mu_k <- oncoSimulPop(5,
2700
+                                        u,
2701
+                                        model = "McFL",
2702
+                                        mu = 5e-7,
2703
+                                        detectionSize = 1e6,
2704
+                                        detectionDrivers = NA,
2705
+                                        detectionProb = NA,
2706
+                                        keepPhylog = TRUE,
2707
+                                        onlyCancer = FALSE,
2708
+                                        keepEvery = 1,
2709
+                                        mutationPropGrowth = FALSE,
2710
+                                        mc.cores = 1
2711
+                                        ))
2431 2712
 												   
2432 2713
 t_mc_50000_nmpg_5mu_k
2433 2714
 ##    user  system elapsed 
... ...
@@ -2470,19 +2751,20 @@ default of `mutationPropGrowth = TRUE`:
2470 2751
 ng <- 50000
2471 2752
 u <- allFitnessEffects(noIntGenes = c(rep(0.1, ng/2), rep(-0.1, ng/2)))
2472 2753
 
2473
-t_mc_50000 <- system.time(mc_50000 <- oncoSimulPop(5,
2474
-                                                   u,
2475
-                                                   model = "McFL",
2476
-                                                   mu = 1e-7,
2477
-                                                   detectionSize = 1e6,
2478
-                                                   detectionDrivers = NA,
2479
-                                                   detectionProb = NA,
2480
-                                                   keepPhylog = TRUE,
2481
-                                                   onlyCancer = FALSE,
2482
-                                                   keepEvery = NA,
2483
-                                                   mutationPropGrowth = TRUE,
2484
-                                                   mc.cores = 1
2485
-                                                   ))
2754
+t_mc_50000 <- system.time(
2755
+    mc_50000 <- oncoSimulPop(5,
2756
+                             u,
2757
+                             model = "McFL",
2758
+                             mu = 1e-7,
2759
+                             detectionSize = 1e6,
2760
+                             detectionDrivers = NA,
2761
+                             detectionProb = NA,
2762
+                             keepPhylog = TRUE,
2763
+                             onlyCancer = FALSE,
2764
+                             keepEvery = NA,
2765
+                             mutationPropGrowth = TRUE,
2766
+                             mc.cores = 1
2767
+                             ))
2486 2768
 
2487 2769
 t_mc_50000
2488 2770
 ##    user  system elapsed 
... ...
@@ -2518,19 +2800,20 @@ single out a couple of cases here.
2518 2800
 First, we repeat the run shown in section \@ref(mc50000ex5):
2519 2801
 
2520 2802
 ```{r mcf5muk005, echo = TRUE, eval = FALSE}
2521
-t_mc_50000_nmpg_5mu_k <- system.time(mc_50000_nmpg_5mu_k <- oncoSimulPop(2,
2522
-                                                   u,
2523
-                                                   model = "McFL",
2524
-                                                   mu = 5e-7,
2525
-                                                   detectionSize = 1e6,
2526
-                                                   detectionDrivers = NA,
2527
-                                                   detectionProb = NA,
2528
-                                                   keepPhylog = TRUE,
2529
-                                                   onlyCancer = FALSE,
2530
-                                                   keepEvery = 1,
2531
-                                                   mutationPropGrowth = FALSE,
2532
-                                                   mc.cores = 1
2533
-                                                   ))
2803
+t_mc_50000_nmpg_5mu_k <- system.time(
2804
+    mc_50000_nmpg_5mu_k <- oncoSimulPop(2,
2805
+                                        u,
2806
+                                        model = "McFL",
2807
+                                        mu = 5e-7,
2808
+                                        detectionSize = 1e6,
2809
+                                        detectionDrivers = NA,
2810
+                                        detectionProb = NA,
2811
+                                        keepPhylog = TRUE,
2812
+                                        onlyCancer = FALSE,
2813
+                                        keepEvery = 1,
2814
+                                        mutationPropGrowth = FALSE,
2815
+                                        mc.cores = 1
2816
+                                        ))
2534 2817
 t_mc_50000_nmpg_5mu_k
2535 2818
 ##    user  system elapsed 
2536 2819
 ## 305.512   5.164 310.711 
... ...
@@ -2566,19 +2849,20 @@ $10^6$ starting from an equilibrium population of 500 we need about
2566 2849
 Next, let us rerun \@ref(mc50000ex1):
2567 2850
 
2568 2851
 ```{r mc50000_1_005, echo = TRUE, eval = FALSE}
2569
-t_mc_50000_nmpg <- system.time(mc_50000_nmpg <- oncoSimulPop(5,
2570
-                                                   u,
2571
-                                                   model = "McFL",
2572
-                                                   mu = 1e-7,
2573
-                                                   detectionSize = 1e6,
2574
-                                                   detectionDrivers = NA,
2575
-                                                   detectionProb = NA,
2576
-                                                   keepPhylog = TRUE,
2577
-                                                   onlyCancer = FALSE,
2578
-                                                   keepEvery = NA,
2579
-                                                   mutationPropGrowth = FALSE,
2580
-                                                   mc.cores = 1
2581
-                                                   ))
2852
+t_mc_50000_nmpg <- system.time(
2853
+    mc_50000_nmpg <- oncoSimulPop(5,
2854
+                                  u,
2855
+                                  model = "McFL",
2856
+                                  mu = 1e-7,
2857
+                                  detectionSize = 1e6,
2858
+                                  detectionDrivers = NA,
2859
+                                  detectionProb = NA,
2860
+                                  keepPhylog = TRUE,
2861
+                                  onlyCancer = FALSE,
2862
+                                  keepEvery = NA,
2863
+                                  mutationPropGrowth = FALSE,
2864
+                                  mc.cores = 1
2865
+                                  ))
2582 2866
 t_mc_50000_nmpg
2583 2867
 ##    user  system elapsed 
2584 2868
 ## 111.236   0.596 111.834 
... ...
@@ -2790,22 +3074,23 @@ u <- allFitnessEffects(noIntGenes = c(rep(0.1, ng)))
2790 3074
 
2791 3075
 
2792 3076
 ```{r ex-large-mf, eval = FALSE, echo = TRUE}
2793
-t_mc_k_50_1e11 <- system.time(mc_k_50_1e11 <- oncoSimulPop(5,
2794
-                                                     u,
2795
-                                                     model = "McFL",
2796
-                                                     mu = 1e-7,
2797