def test_jc(self): jc = spectraltree.Jukes_Cantor() observations, meta = spectraltree.simulate_sequences( seq_len=500, tree_model=self.reference_tree, seq_model=jc, mutation_rate=0.05, rng=np.random.default_rng(12345), alphabet='DNA') spectral_method = spectraltree.STDR(spectraltree.RAxML, spectraltree.JC_similarity_matrix) #spectral_method = spectraltree.STDR(spectraltree.NeighborJoining,spectraltree.JC_similarity_matrix) tree_rec = spectral_method.deep_spectral_tree_reconstruction( observations, spectraltree.JC_similarity_matrix, taxa_metadata=meta, threshhold=self.threshold, min_split=5, merge_method="least_square", verbose=False) self.assertTrue(spectraltree.topos_equal(self.reference_tree, tree_rec))
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 test_jukes_cantor_similarity(self): observationsJC, metaJC = spectraltree.simulate_sequences( seq_len=400, tree_model=self.reference_tree, seq_model=spectraltree.Jukes_Cantor(), mutation_rate=0.1, rng=default_rng(345), alphabet="DNA") nj_jc = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) self.assertTrue(spectraltree.topos_equal(self.reference_tree, nj_jc(observationsJC, metaJC)))
def test_hky(self): spectral_method = spectraltree.STR(spectraltree.RAxML, spectraltree.HKY_similarity_matrix( self.meta_hky), threshold=32, merge_method="least_square", num_gaps=1, min_split=5, verbose=False) self.assertTrue( spectraltree.topos_equal( self.reference_tree, spectral_method(self.observations_hky, self.meta_hky)))
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)))
def test_jukes_cantor(self): observationsJC, metaJC = spectraltree.simulate_sequences( seq_len=500, tree_model=self.reference_tree, seq_model=spectraltree.Jukes_Cantor(), mutation_rate=0.1, rng=default_rng(234), alphabet="DNA") forrest = spectraltree.Forrest() self.assertTrue( spectraltree.topos_equal(self.reference_tree, forrest(observationsJC, metaJC)))
def test_jukes_cantor(self): # reference_tree = spectraltree.unrooted_birth_death_tree(num_taxa, birth_rate=1, rng=) # reference_tree = spectraltree.lopsided_tree(num_taxa) reference_tree = spectraltree.balanced_binary(8) jc = spectraltree.Jukes_Cantor(num_classes=2) observations, meta = spectraltree.simulate_sequences( seq_len=10_000, tree_model=reference_tree, seq_model=jc, mutation_rate=jc.p2t(0.98), rng=default_rng(678), alphabet="Binary") rg = spectraltree.RG(spectraltree.JC_distance_matrix) recoverd_tree = rg(observations, meta) print("(RF distance,F1 score):", spectraltree.compare_trees(reference_tree, recoverd_tree)) self.assertTrue(spectraltree.topos_equal( reference_tree, recoverd_tree)) # this doesn't work very well