Skip to content

rneher/betatree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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: richard.neher@tuebingen.mpg.de

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

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

About

Generate and analyze beta coalescent trees

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages