Distance Matrix Calculation
0
0
Entering edit mode
3.1 years ago
anasjamshed ▴ 120

I have tried this script for the distance matrix calculator:

from Bio import Phylo, AlignIO
from Bio.Phylo.TreeConstruction import DistanceCalculator, DistanceTreeConstructor
import matplotlib
import matplotlib.pyplot as plt

# Calculate the distance matrix
calculator = DistanceCalculator('identity')
dm = calculator.get_distance(aln)
print(dm)
# Visualize neighbor joined tree
constructor = DistanceTreeConstructor()
tree = constructor.nj(dm)
matplotlib.rc('font', size=7)
fig = plt.figure(figsize=(14, 20), dpi=400)
Phylo.draw(tree, axes=axes, do_show=False)
plt.savefig('proj1phy.jpg')


and it is giving me the following output:

10819d4184b7fe808f57b65a0e9174d1    0
99a30d2e520c0bb462c9d36594b679ef    0.5900000000000001  0.5725  0
8bb6ba264b60216d22b221d5c6c0992e    0.17500000000000004 0.015000000000000013    0.5675  0


But I want a distance matrix in proper format like: **

            xcord   ycord
Boston      5         7
Phoenix     7        3
New York    8       1


** How can I do it after implementing the biopython library?

genome biopython • 829 views
0
Entering edit mode

Not sure if it is possible in biopython but I used this not that long ago. https://scikit-learn.org/stable/auto_examples/manifold/plot_mds.html#sphx-glr-auto-examples-manifold-plot-mds-py (assuming you want x and y coordinates based on distances)