def part12_cat(num_taxa_s_cat, Ns_cat): ##### Part 1: NJ vs SNJ print("Starting Part 12") snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) methods = [snj, nj] ## Part 1.2: different Taxa cat_trees = [spectraltree.lopsided_tree(num_taxa) for num_taxa in num_taxa_s_cat] res_cat12 = compare_methods.experiment(tree_list = cat_trees, sequence_model = sequence_model, Ns = Ns_cat, methods = methods, mutation_rates=mutation_rates, reps_per_tree=5, verbose=True) return res_cat12
def part11(num_taxa, Ns_bin): ##### Part 1: NJ vs SNJ print("Starting Part 11") snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) methods = [snj, nj] ## Part 1.1: different N bin_tree = spectraltree.balanced_binary(num_taxa) res_bin11 = compare_methods.experiment(tree_list = [bin_tree], sequence_model = sequence_model, Ns = Ns_bin, methods = methods, mutation_rates=mutation_rates, reps_per_tree=5, verbose=True) return res_bin11
def part21_king(num_taxa_king, Ns_king): ##### Part 2: NJ vs SNJ vs RG vs CLRG print("Starting Part 21 for kingman tree") snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) rg = spectraltree.RG(spectraltree.JC_distance_matrix) #clrg = spectraltree.CLRG() methods = [snj, nj,rg] alphabet = "DNA" ## Part 2.1: different N king_tree = spectraltree.unrooted_pure_kingman_tree(num_taxa_king) res_king21 = compare_methods.experiment(tree_list = [king_tree], sequence_model = sequence_model, Ns = Ns_king, methods = methods, mutation_rates=mutation_rates, reps_per_tree=5, alphabet=alphabet, verbose=True) return res_king21
def part21_bin(num_taxa_bin, Ns_bin): ##### Part 2: NJ vs SNJ vs RG vs CLRG print("Starting Part 21 for binary tree") snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) rg = spectraltree.RG(spectraltree.JC_distance_matrix) #clrg = spectraltree.CLRG() methods = [snj, nj,rg] alphabet = "DNA" ## Part 2.1: different N bin_tree = spectraltree.balanced_binary(num_taxa_bin) res_bin21 = compare_methods.experiment(tree_list = [bin_tree], sequence_model = sequence_model, Ns = Ns_bin, methods = methods, mutation_rates=mutation_rates, reps_per_tree=5, alphabet=alphabet, verbose=True) return res_bin21
def part11_cat(num_taxa, Ns_cat): ##### Part 1: NJ vs SNJ print("Starting Part 11") snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) methods = [snj, nj] ## Part 1.1: different N #alphabet = "Binary" cat_tree = spectraltree.lopsided_tree(num_taxa) res_cat11 = compare_methods.experiment(tree_list = [cat_tree], sequence_model =sequence_model, Ns = Ns_cat, methods = methods, mutation_rates=mutation_rates, reps_per_tree=5, verbose=True, savepath = '20200821_res12_cat_SNJPAPER',folder = './experiments/snj_paper_experiments/results/') return res_cat11
def part22_cat(num_taxa_s_cat, Ns_cat): ## Part 2.2: different Taxa print("Starting Part 22 for caterpillar trees") snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) rg = spectraltree.RG(spectraltree.JC_distance_matrix) clrg = spectraltree.CLRG() methods = [snj, nj,rg] alphabet = "Binary" cat_trees = [spectraltree.lopsided_tree(num_taxa) for num_taxa in num_taxa_s_cat] res_cat22 = compare_methods.experiment(tree_list = cat_trees, sequence_model = sequence_model, Ns = Ns_cat, methods = methods, mutation_rates=mutation_rates, reps_per_tree=5, alphabet=alphabet , verbose=True) return res_cat22
def part21_cat(num_taxa_cat, Ns_cat): ##### Part 2: NJ vs SNJ vs RG vs CLRG print("Starting Part 21 for caterpillar tree") snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) rg = spectraltree.RG(spectraltree.JC_distance_matrix) #clrg = spectraltree.CLRG() methods = [snj, nj,rg] alphabet = "DNA" ## Part 2.1: different N cat_tree = spectraltree.lopsided_tree(num_taxa_cat) res_cat21 = compare_methods.experiment(tree_list = [cat_tree], sequence_model = sequence_model, Ns = Ns_cat, methods = methods, mutation_rates=mutation_rates, reps_per_tree=5, alphabet=alphabet, verbose=True) return res_cat21
def part22_king(num_taxa_s_king, Ns_king): ## Part 2.2: different Taxa print("Starting Part 22 for kingman trees") snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) rg = spectraltree.RG(spectraltree.JC_distance_matrix) clrg = spectraltree.CLRG() methods = [snj, nj,rg] alphabet = "DNA" king_trees = [spectraltree.unrooted_pure_kingman_tree(num_taxa) for num_taxa in num_taxa_s_king] res_king22 = compare_methods.experiment(tree_list = king_trees, sequence_model = sequence_model, Ns = Ns_king, methods = methods, mutation_rates=mutation_rates, reps_per_tree=5, alphabet=alphabet , verbose=True) return res_king22
def part22_bin(num_taxa_s_bin, Ns_bin): ## Part 2.2: different Taxa print("Starting Part 22 for binary trees") snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) rg = spectraltree.RG(spectraltree.JC_distance_matrix) clrg = spectraltree.CLRG() methods = [snj, nj,rg] alphabet = "DNA" bin_trees = [spectraltree.balanced_binary(num_taxa) for num_taxa in num_taxa_s_bin] res_bin22 = compare_methods.experiment(tree_list = bin_trees, sequence_model = sequence_model, Ns = Ns_bin, methods = methods, mutation_rates=mutation_rates, reps_per_tree=5, alphabet=alphabet , verbose=True) return res_bin22
def part31_king(num_taxa_king, Ns_king): ##### Part 3: NJ vs SNJ vs RG vs CLRG vs Forrest vs Tree_SVD print("Starting Part 31") snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) #rg = spectraltree.RG(spectraltree.JC_distance_matrix) #clrg = spectraltree.CLRG() forrest = spectraltree.Forrest() tree_svd = spectraltree.TreeSVD() #methods = [snj, nj,rg,clrg, forrest,tree_svd] methods = [snj, nj, forrest,tree_svd] alphabet = "Binary" ## Part 3.1: different N kingman_tree = spectraltree.unrooted_birth_death_tree(num_taxa_king, birth_rate=1) res_king31 = compare_methods.experiment(tree_list = [kingman_tree], sequence_model = sequence_model2, Ns = Ns_king, methods = methods, mutation_rates=mutation_rates2, reps_per_tree=5, alphabet=alphabet, verbose=True) return res_king31
import spectraltree import spectraltree.compare_methods as compare_methods tree_list = [spectraltree.balanced_binary(32)] jc = spectraltree.Jukes_Cantor(num_classes=2) Ns = [100,200,300] mutation_rates = [jc.p2t(0.9)] snj = spectraltree.SpectralNeighborJoining(spectraltree.JC_similarity_matrix) nj = spectraltree.NeighborJoining(spectraltree.JC_similarity_matrix) RG = spectraltree.RG(spectraltree.JC_distance_matrix) CLRG = spectraltree.CLRG() methods = [nj,snj,RG,CLRG] num_reps = 1 results = compare_methods.experiment(tree_list = tree_list, sequence_model = jc, Ns = Ns, methods=methods, mutation_rates = mutation_rates, reps_per_tree=num_reps,savepath='balanced_binary_m_512.pkl',folder = './data/',overwrite=True) df = compare_methods.results2frame(results) print(df) a =1