gpt4 book ai didi

python - BioPython 中系统发育树的子树

转载 作者:行者123 更新时间:2023-11-30 22:51:25 25 4
gpt4 key购买 nike

我有一个 newick 格式的系统发育树。我想根据终端节点的标签(因此基于物种列表)拉出一棵子树。我正在使用的树的副本可以在这里找到:http://hgdownload.soe.ucsc.edu/goldenPath/dm6/multiz27way/dm6.27way.nh

目前我已经使用 BioPython 阅读了树,如下所示:

from Bio import Phylo
#read in Phylogenetic Tree
tree = Phylo.read('dm6.27way.nh', 'newick')
#list of species of interest
species_list = ['dm6', 'droSim1', 'droSec1', 'droYak3', 'droEre2', 'droBia2', 'droSuz1', 'droAna3', 'droBip2', 'droEug2', 'droEle2', 'droKik2', 'droTak2', 'droRho2', 'droFic2']

如何仅提取species_list中物种的子树?

最佳答案

好吧,假设您想要包含物种列表中所有物种的最小树,您希望这棵树的根节点成为列表中所有物种的最近共同祖先(MRCA),值得庆幸的是,这已经是在 Phylo 中实现:

from Bio import Phylo

#read in Phylogenetic Tree
tree = Phylo.read('dm6.27way.nh', 'newick')
#list of species of interest
species_list = ['dm6',
'droSim1',
'droSec1',
'droYak3',
'droEre2',
'droBia2',
'droSuz1',
'droAna3',
'droBip2',
'droEug2',
'droEle2',
'droKik2',
'droTak2',
'droRho2',
'droFic2']

common_ancestor = tree.common_ancestor(species_list)
Phylo.draw_ascii(common_ancestor)

输出:

Clade
___ dm6
___|
| | , droSim1
| |_|
__________| | droSec1
| |
| | _____ droYak3
,| |_|
|| |____ droEre2
||
|| _______ droBia2
||_____|
| |_____ droSuz1
|
__| _______ droAna3
| |_________________________________|
| | |________ droBip2
| |
| |___________________ droEug2
|
|_____________ droEle2
,|
||______________________________ droKik2
__||
| ||______________ droTak2
___________________| |
| |____________ droRho2
|
|_______________ droFic2

关于python - BioPython 中系统发育树的子树,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39029517/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com