Created
June 29, 2016 13:17
-
-
Save clarle/ae158f005380576b92ad9ee3847589d9 to your computer and use it in GitHub Desktop.
Generate simulated phylogenetic data using DendroPy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dendropy | |
from dendropy.simulate import treesim | |
from dendropy.model.discrete import Hky85, simulate_discrete_char_dataset | |
# Generate a simulated tree | |
taxa = dendropy.TaxonNamespace(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']) | |
tree_model = treesim.birth_death_tree(birth_rate=1.0, death_rate=0.5, taxon_namespace=taxa) | |
# Use the HKY85 model for character mutation | |
seq_model = Hky85() | |
# Simulate a data set with the given tree and model, with 50 character sequences | |
data = simulate_discrete_char_dataset(50, tree_model, seq_model) | |
# Print tree and sequences in FASTA format | |
tree_model.print_plot() | |
print(data.as_string('fasta')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment