def test_hky_similarity(self): observationsHKY, metaHKY = spectraltree.simulate_sequences( seq_len=2_000, tree_model=self.reference_tree, seq_model=spectraltree.HKY(kappa=1.5), mutation_rate=0.1, rng=default_rng(543), alphabet="DNA") nj_hky = spectraltree.NeighborJoining(spectraltree.HKY_similarity_matrix(metaHKY)) self.assertTrue(spectraltree.topos_equal(self.reference_tree, nj_hky(observationsHKY, metaHKY)))
def setUp(self): # self.reference_tree = spectraltree.unrooted_birth_death_tree(self.num_taxa, birth_rate=1) # self.reference_tree = spectraltree.lopsided_tree(self.num_taxa) self.reference_tree = spectraltree.balanced_binary(128) # self.reference_tree = spectraltree.unrooted_pure_kingman_tree(self.num_taxa) self.observations_hky, self.meta_hky = spectraltree.simulate_sequences( seq_len=300, tree_model=self.reference_tree, seq_model=spectraltree.HKY(kappa=2), mutation_rate=0.05, rng=np.random.default_rng(234), alphabet='DNA')
def test_hky(self): observationsHKY, metaHKY = spectraltree.simulate_sequences( seq_len=500, tree_model=self.reference_tree, seq_model=spectraltree.HKY(kappa=2), mutation_rate=0.1, rng=default_rng(234), alphabet="DNA") forrest = spectraltree.Forrest() self.assertTrue( spectraltree.topos_equal(self.reference_tree, forrest(observationsHKY, metaHKY)))
from time import time as _t import numpy as np import spectraltree import metricNearness N = 100 num_taxa = 60 ################################# ## Tree generation ################################# print("Creating tree") jc = spectraltree.Jukes_Cantor() hky = spectraltree.HKY(kappa=2) mutation_rate = [jc.p2t(0.95)] # mutation_rate = [0.1] #reference_tree = spectraltree.unrooted_birth_death_tree(num_taxa, birth_rate=0.5) reference_tree = spectraltree.lopsided_tree(num_taxa) # reference_tree = spectraltree.balanced_binary(num_taxa) # for x in reference_tree.preorder_edge_iter(): # x.length = 0.5 print("Genration observations by JC and HKY") observationsJC, metaJC = spectraltree.simulate_sequences( N, tree_model=reference_tree, seq_model=jc, mutation_rate=mutation_rate,