How to construct a phylogenetic tree accroding to sequence similarity matrix
0
0
Entering edit mode
16 months ago
Jason • 0

Hi everyone,

I would like to know how to construct a phylogenetic tree accroding to pre-calculated sequence similarity matrix. An example of input file is like:

  Seq1 Seq2  Seq3 Seq4

Seq1 1 0.9 0.6 0.4

Seq2 0.9 1 0.5 0.1

Seq3 0.6 0.5 1 0.6

Seq4 0.4 0.1 0.6 1

——————————

How can I use above data to build a tree?

Many thanks :)

similarity tree sequence phylogenetic • 814 views
ADD COMMENT
1
Entering edit mode

using https://ai.tinybio.cloud/chat

To construct a phylogenetic tree using Biopython, you can use the DistanceTreeConstructor class from the Bio.Phylo.TreeConstruction module. This class provides methods to construct a phylogenetic tree using distance matrix. Here is a simple example:

from Bio.Phylo.TreeConstruction import DistanceTreeConstructor
from Bio.Phylo.TreeConstruction import DistanceMatrix

# Your sequence similarity matrix
matrix = [
    [1, 0.9, 0.6, 0.4],
    [0.9, 1, 0.5, 0.1],
    [0.6, 0.5, 1, 0.6],
    [0.4, 0.1, 0.6, 1]
]

# Names of your sequences
names = ['Seq1', 'Seq2', 'Seq3', 'Seq4']

# Create a distance matrix
dm = DistanceMatrix(names, matrix)

# Create a DistanceTreeConstructor object
constructor = DistanceTreeConstructor()

# Construct a tree using UPGMA algorithm
tree = constructor.upgma(dm)

# Print the tree
print(tree)

In this example, the upgma method is used to construct the tree using UPGMA (Unweighted Pair Group Method with Arithmetic Mean) algorithm. You can also use the nj method to construct the tree using NJ (Neighbor Joining) algorithm.

Please note that the distance matrix should represent the evolutionary distance between the sequences, not the sequence similarity. You might need to convert your sequence similarity matrix to a distance matrix before constructing the tree.

ADD REPLY

Login before adding your answer.

Traffic: 2789 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