Coder Social home page Coder Social logo

betatree's Introduction

################################################################################

betatree is a collection of python scripts to generate trees from the beta coalescent ensemble, calculate properties of those trees and gather statistics across many instances. 

Authors: Taylor Kessinger and Richard Neher

Contact: [email protected]

Example output of the betatree generator are given as pdf files in example_trees. Example site frequency spectra for different parameters of the beta-coalescent ensemble are provided in example_SFS.

If you use betatree in a publication, please refer to 

Neher, Kessinger, and Shraiman. "Coalescence and Genetic Diversity in Sexual Populations under Selection." PNAS 110: 15836-41. doi:10.1073/pnas.1309697110.


################################################################################
Tree generation

the script src/betatree.py provides a class that generates coalescent trees using pseudorandom numbers given an initial sample size n and a parameter alpha of the beta measure of the Lambda coalescent process. The following 3 lines will generate a tree of a sample size of 100 and draw it with the Biopython.Phylo package.

    myT = betatree(100, alpha = 2)
    myT.coalesce()
    Phylo.draw(myT.BioTree)

the tree is internally stored as a biopython.phylo tree with all the associated  functionality.

Sample code is appended to the definition of the class as will be exectuted if betatree.py is run as main.

################################################################################
Site frequency spectra

the script src/sfs.py uses the class betatree to generate many trees and calculate the SFS assuming that mutation are uniformly distributed on the tree. The following three lines will generate an SFS for a sample size 100 and alpha=1.5 by averaging 1000 trees.

    mySFS = SFS(100, alpha=1.5)
    mySFS.getSFS(ntrees=1000)

The sfs is accessible as mySFS.sfs and can be binned using different binning schemes or a user defined binning. 

    mySFS.binSFS(mode='logit', bins=20)
    plt.plot(mySFS.bin_center, mySFS.binned_sfs)

The sfs can be saved and loaded by member functions.

Sample code is appended to the definition of the class as will be exectuted if sfs.py is run as main.


################################################################################
Dependencies:

python 2.7
numpy
scipy
biopython
matplotlib for plotting examples

################################################################################

betatree's People

Contributors

rneher avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

iosonofabio

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.