Phylogenetic trees in Plotly
2
0
Entering edit mode
2.9 years ago

Hi, Does anyone have any experience generating phylogenetic trees using Plotly with python? I already have the newick files for the trees and can process and plot them (e.g. with ete3 or Bio.Phylo), but I would love to get the x-y coordinates of those tree nodes and edges to generate interactive plots in Plotly. Or maybe there are other more elegant ways to generate trees from newick files in Plotly. Thanks in advance for any help!

Jon

Dash python Plotly • 2.0k views
ADD COMMENT
2
Entering edit mode
2.9 years ago

There is no y coordinate for the tree nodes but you can get the x (branch length) like this:

from Bio import Phylo

tree = Phylo.read("example.nwk", "newick")

#all nodes:
print(tree.depths())

# only terminals nodes:
print(tree.get_terminals())
ADD COMMENT
0
Entering edit mode
2.9 years ago

Thanks Simon. I don't think I asked my question in the quite right way. Although a newick tree is a just a mathematical object with no representation in 2D space, some drawing algorithm must have been used to render that object onto two (x,y) dimensions on a graph. So I am wondering 1) what algorithm(s) can render a newick tree object into a 2D graph like in the image below, and 2) how can I grab the coordinates of the nodes and edges?

Thanks! enter image description here

ADD COMMENT

Login before adding your answer.

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