Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.


Code for forward population genetic simulation in asexual populations, with special focus on cancer progression. Fitness can be an arbitrary function of genetic interactions between multiple genes or modules of genes, including epistasis, order restrictions in mutation accumulation, and order effects. Mutation rates can differ between genes, and we can include mutator/antimutator genes (to model mutator phenotypes). Simulations so far use continuous-time models and can include driver and passenger genes and modules. Also included are functions for: simulating random DAGs of the type found in Oncogenetic Trees, Conjunctive Bayesian Networks, and other cancer progression models; plotting and sampling from single or multiple realizations of the simulations, including single-cell sampling; plotting the parent-child relationships of the clones; generating random fitness landscapes (Rough Mount Fuji, House of Cards, and additive models, and NK model) and plotting them.

The /OncoSimulR directory contains the code for the BioConductor package OncoSimulR. The /miscell-files directory contains additional files so far only related to the above.

A former version of this code has been used in the paper "Identifying restrictions in the order of accumulation of mutations during tumor progression: effects of passengers, evolutionary models, and sampling", BMC Bioinformatics, 2015, 16:41. OncoSimulR has also been used extensively in the simulations reported in the Bioinformatics paper "Cancer Progression Models And Fitness Landscapes: A Many-To-Many Relationship" and the PLoS Computational Biology paper "Every which way? On predicting tumor evolution using cancer progression models".

You can also find OncoSimulR on the Genetic Simulation Resources catalogue. Catalogued on GSR

New functionality to allow for frequency-dependent fitness has been added. See the freq-dep-fitness branch:


To use the most recent code in BioConductor, install the devel version.

if (!require("BiocManager"))
BiocManager::install("OncoSimulR", version = "devel")

To start using it:


You can directly install from github (and this might be newer than the BioC code)

install.packages("devtools") ## if you don't have it already

But sometimes the latest additions in this repo could be broken (see Software status). And you can of course clone this repo, and install from there.

BioConductor github repository

The github repository for this package is this one: . Since mid-2017 BioConductor is maintained using git, but since this directory contains other files and directories in addition to the OncoSimulR package itself, I have not used option "Sync an existing GitHub repository with Bioconductor". Instead, I continue using this github repo, but then locally update a Bioconductor-only repository of just the OncoSimulR code (as explained in Maintain a Bioconductor-only repository for an existing package).


As any R/BioConductor package, OncoSimulR comes with documentation for its user-visible functions and data sets (using the help is just standard R usage). From OncoSimulR's BioConductor page you have access to the standard documentation both the manual and overview ---the vignette. The best place to start is the vignette (created from the OncoSimulR/vignettes/OncoSimulR.Rnw file that includes both text and code).

You can view the vignette from R itself doing


and this gives you access to the HTML, the Rmd file (markdown + R), and the R code.

Documentation: HTML and PDF for this repo's version

From these two links you can also browse the HTML vignette and get a PDF version.

These files correspond to the most recent, github version, of the package (i.e., they might include changes not yet available from the BioConudctor package).

Further documentation

This paper published in Bioinformatics gives a quick overview of OncoSimulR (a former version is available as a bioRxiv preprint). You can also take a look at this poster presented at ECCB 2016. A chapter titled "Simulating evolution in asexual populations with epistasis" will appear in K.-C. Wong (ed.), Epistasis: Methods and Protocols. Methods in Molecular Biology, later during 2020; here is a preprint version.

If you use the package in publications please cite the Bioinformatics paper.

The frequency-dependent fitness functionality is based on Sergio Sanchez-Carrilo's Master's thesis (see also file 'miscell-files/Sergio_Sanchez-Carillo-improvements-post-TFM.pdf' for additional features that were not described in the original thesis). Additional functionality has been added by Juan Antonio Miguel González.

Licenses and copyright

The R/BioConductor OncoSimulR package is licensed under the GPLv3 license. The code for the OncoSimulR BioConductor package, except for functions and plot.stacked, is Copyright 2012-2020 by Ramon Diaz-Uriarte; the code for frequency dependent fitness is Copyright 2017-2019 Sergio Sanchez-Carrillo and 2019-2020 Juan Antonio Miguel Gonzalez. and plot.stacked are Copyright 2013-2016 by Marc Taylor (see also and

The code under src/FitnessLandascape is from MAGELLAN, Maps of Genetical Landscapes. The authors are S. Brouillet, G. Achaz, S. Matuszewski, H. Annoni, and L. Ferreti. I downloaded the sources on 2019-06-05 from The code is under the GPLv3. MAGELLAN is "an integrated tool to visualize and analyze fitness landscapes of small dimension (up to 7-8 loci)". In OncoSimulR we use only a very limited subset of the functionality of MAGELLAN (mostly to generate different types of random fitness landscapes and to compute statistics of epistasis); the Makevars file we use only compiles two of the executables (fl_statistics and fl_generate) ---the directory src/FitnessLandascape contains, however, the complete sources. Note also that the plots of fitness landscapes used in OncoSimulR are actually blatantly copied in looks from MAGELLAN's plots.

(For the freq-dep-fitness branch) The code under OncoSimulR/src/exprtk.h is from The C++ Mathematical Expression Toolkit Library (ExprTk). This code is copyright Arash Partow, and is licensed under "The MIT License (MIT)" ( and is compatible with GPL ( The file was originally downloaded from on 2017-05-15. The most recent version was downloaded again in 2019-05-14 (and corresponds to the exprTk repo at commit The file was originally named exprtk.hpp; to conform to R's requirements, it was renamed as exprt.h

The code in miscell-files/randutils.h is copyright Melissa E. O'Neill, and is licensed under "The MIT License (MIT)" in the terms explained in the file itself. This is a license that is compatible with the GPL. The file randutils.hpp was downloaded from on 2015-06-20 and is also referenced from the main article [Ease of Use without Loss of Power] ( I renamed it to randutils.h to conform to R's requirements (and changed the auto exit_func = hash(&_Exit); line to keep R from complaining about the Exit function). I had to disable usage of randutils for now, since I could not get it to compile with gcc-4.6 (since version 3.3 of R, the official Rtools for Windows now support C++-11, so I might change this in the near future).

The file under gitinfo-hooks is Copyright 2011 Brent Longborough, is part of the gitinfo package, and is under the LaTeX Project Public License 1.3, which is incompatible with the GPL. Note this file is not part of the OncoSimulR BioConductor package.

The files under miscell-files/AParramon_discrete_time are copyright Alberto Parramon, unless otherwise specified. This is an implementation of a discrete-time version of OncoSimulR.

Software status

Bioconductor (multiple platforms) Travis CI (Linux) Appveyor (Windows)
R CMD check Build status (release)
Build status (devel)
Build status Build status
Test coverage Coverage Status

(Note: Appveyor can fail for reasons that have nothing to do with the package, such as R not being downloaded correctly, etc. Look at the details of each failure. Similarly, some of the errors in BioConductor, specially in the development branch, can be caused, specially in Windows, by some required packages not being yet available, often "car" and "igraph".

Again, look at the details of each failure.)
You can’t perform that action at this time.