Distance Matrix Calculation
0
0
Entering edit mode
3.7 years ago
anasjamshed ▴ 140

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
# Read in alignment
aln = AlignIO.read("C://Users//USER//Desktop/63_sequences.fasta","fasta")

# 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)
axes = fig.add_subplot(1, 1, 1)
Phylo.draw(tree, axes=axes, do_show=False)
plt.savefig('proj1phy.jpg')

and it is giving me the following output:

10819d4184b7fe808f57b65a0e9174d1    0
eaf307555b1ef040e7155ad169ba3637    0.1775  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 • 958 views
ADD COMMENT
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)

ADD REPLY

Login before adding your answer.

Traffic: 2888 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6