Phylo BioPython 构建树
我尝试使用 BioPython、Phylo 模块构建一棵树。
到目前为止我所做的是这张图片:
每个名称都有一个四位数字,后跟 - 和一个数字:这个数字指的是序列被表示的次数。这意味着 1578 - 22,该节点应该代表 22 个序列。
所以现在我知道如何更改节点的每个大小。每个节点都有不同的大小,这很容易制作不同值的数组:
fh = open(MEDIA_ROOT + "groupsnp.txt")
list_size = {}
for line in fh:
if '>' in line:
labels = line.split('>')
label = labels[-1]
label = label.split()
num = line.split('-')
size = num[-1]
size = size.split()
for lab in label:
for number in size:
list_size[lab] = int(number)
a = array(list_size.values())
但是该数组是任意的,我想将正确的节点大小放入正确的节点中,我尝试了这个:
for elem in list_size.keys():
if labels == elem:
Phylo.draw_graphviz(tree_xml, prog="neato", node_size=a)
但是当我使用 if 时什么也没有出现陈述。
无论如何要这样做吗?
我真的很感激!
谢谢大家
I trying to build a tree with BioPython, Phylo module.
What I've done so far is this image:
each name has a four digit number followed by - and a number: this number refer to the number of times that sequence is represented. That means 1578 - 22, that node should represent 22sequences.
the file with the sequences aligned: file
the file with the distance to build a tree: file
So now I known how to change each size of the node. Each node has a different size, this is easy doing an array of the different values:
fh = open(MEDIA_ROOT + "groupsnp.txt")
list_size = {}
for line in fh:
if '>' in line:
labels = line.split('>')
label = labels[-1]
label = label.split()
num = line.split('-')
size = num[-1]
size = size.split()
for lab in label:
for number in size:
list_size[lab] = int(number)
a = array(list_size.values())
But the array is arbitrary, I would like to put the correct node size into the right node, I tried this:
for elem in list_size.keys():
if labels == elem:
Phylo.draw_graphviz(tree_xml, prog="neato", node_size=a)
but nothing appears when I use the if statement.
Anyway of doing this?
I would really appreciate!
Thanks everybody
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于成功了。基本前提是您将使用
labels/nodelist
来构建node_sizes
。这样它们就可以正确关联。我确信我缺少一些重要的选项来使树看起来 100%,但节点大小似乎正确显示。结果树
I finally got this working. The basic premise is that you're going to use the
labels/nodelist
to build yournode_sizes
. This way they correlate properly. I'm sure I'm missing some important options to make the tree look 100% but it appears the node sizes are showing up properly.Resulting Tree