Code Monkey home page Code Monkey logo

forward-equivalent-trees's Introduction

forward-equivalent-trees

Efficiently simulating multi-type birth-death processes via forward-equivalent parameter mapping

Jupyter Notebooks

The simulations and plots are produced by the jupyter notebooks in the notebooks directory. These should be run in the following order:

  • Run all cells in efficiency.ipynb in order to run all simulations. It will read output to a data sub-directory provided the save_to_file global varialbe and the "save_tree" key in the respective sim_spec are set to True.
  • After this, any of the three remaining notebooks can be run. These will create output images in a fig sub-directory.
    • distribution_tests.ipynb: This creates histograms comparing several tree statistics between the full and forward-equivalent simulations.
    • timing_plots.ipynb: This creates plots comparing the run-time of the ful and forward-equivalent simulations across three model specifications. By changing the sim_idx variable and then running all cells, one can create plots for each of the different model specificaitons.
    • draw_tree.ipynb: This draws a tree generated by the huge population simulation specification.

Python files

These modules are used by the jupyter notebooks.

  • modulators.py: Defines the FEModulator class. An FEModulator object is initialized by a specification of the full model and sampling rates, and computes and stores internal data to allow simulation-time access to forward-equivalent model parameters.
  • my_bdms.py: This module contains three classes:
    • DiscreteProcess: This sub-classes poisson.Process and can be used by bdms for simulation from a constant-rate (birth, death, or mutation) process taking on a finite phenotype space.
    • CustomProcess: This sub-classes poisson.Process and allows and user provided time- and state-dependent rates. In our code, we use this class to store birth, death, and mutation rates for the forward-equivalent model. the FEModulator class provides the CustomProcess initializer with the appropriate time- and state-dependent rate functions.
    • CustomMutator: This sub-classes mutators.Mutator. It is initialized with an FEModulator object, which is then used to carry out time- and state-dependent mutation transitions according the the forward-equivalent model.
  • utils.py: This exports some utility functions, as well functions to compute all the tree statistics used for the distribution tests (in distribution_tests.ipynb).

forward-equivalent-trees's People

Contributors

mcelentano avatar wsdewitt avatar

Watchers

 avatar  avatar Yun S. Song avatar Neil Thomas avatar Sebastián Prillo avatar

forward-equivalent-trees's Issues

compatibility with bdms >=v4.0

As of BDMS v4.0, the parameter

birth_mutations: bool

of the bdms.Tree.evolve() method has been replaced with

birth_mutation_prob: float | Callable[[Any, rng], float]

A new install will require a change in notebooks/efficiency.ipynb to replace birth_mutations=False with birth_mutation_prob=0.

Workflow / tidying

Here are some next steps:

  • Outline the workflow in the readme, e.g. "run notebook x to generate data y then run notebook z, ...".
  • Some code looks like non-functional stubs, e.g. draw_tree.ipynb. Consider what might be removed or migrated.
  • gcdyn is still imported in one notebook
  • There are several unused imports, which could be removed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.