# We can apply this tree style to a random tree as follows. t = ete3.Tree() t.populate(10) t.render("%%inline", tree_style=ts) # distance based methods to phylogenetic reconstruction # for the next approach, we will rely on computing the distances between the sequences. # We will use dissimilarity distance between two objects x and y. Literature on this can be found online, for now # we are going to show the code. from skbio import DistanceMatrix dm = DistanceMatrix([[0.0, 1.0, 2.0], [1.0, 0.0, 3.0], [2.0, 3.0, 0.0]], ids=['a', 'b', 'c']) _ = dm.plot(cmap='Greens') # We will use the scikit-bio to create a skbio.distancematrix object. These objects can be viewed as heatmaps. from BioinformaticsCode.algorithms import kmer_distance kmer_dm = DistanceMatrix.from_iterable(sequences, metric=kmer_distance, key='id') _ = kmer_dm.plot(cmap='Greens', title='3mer distances between sequences') kmer_dm.plot
List_Of_Name.append(array_of_frequencies[i, :]) for j in range(line): heatmap[i][j] = np.linalg.norm(array_of_frequencies[i, :] - array_of_frequencies[j, :]) f, ax = plt.subplots() ax = sns.heatmap(heatmap) plt.show() return heatmap #CreateProfiles("bact","/home/roselyne/Bureau/BIM-info/GENOM/Database",7) output = np.load("Frequency_vector_for_database.npy") df = Tuples2DF(output, [1, 2, 3]) heatmap = plot_Distance_Matrix_Between_Species(df) ids = list(df['Name']) dm = DistanceMatrix(heatmap, ids) tree_str = nj(dm, result_constructor=str) print(tree_str[:55], "...") fig = dm.plot(title='Distance Matrix - kmer from 1 to 3') fig.savefig('Distance_Matrix_kmer_1To3.png') file = open("tree_nw_format_kmer_1To3.txt", 'w') file.write(tree_str) file.close