Bio.Cluster.Tree 转为 newick 格式,示例:
输入文件cyano.txt github
基因 0 15 分钟 1 小时 6 小时 15 小时
sll0617 0.0 -0.141164092921 -0.564656371686 -0.219393769051 -0.582969948517
slr0452 0.0 -0.124988599702 -0.499954398807 0.195680498436 0.0781478593432
slr1513 0.0 0.788547158236 0.228594792282 0.255819396258 0.304823683415
sll1471 0.0 -0.770355431265 -1.10115338201 -1.00607440632 -0.834932250086
sll1694 0.0 -0.328239937586 -2.16037133914 -1.184544471 -1.36760041273
sll0430 0.0 2.57611845993 0.920296714116 0.331897478085 0.353984672049
sll0851 0.0 -0.260488607867 -1.04195443147 -0.870951657169 -0.563146663432
sll1260 0.0 0.488375211397 1.03336768086 1.05808458732 1.10257501897
sll1031 0.0 2.22636090218 1.2737708006 1.22441048661 1.13556192142
......
在python (view example source) 中使用treecluster
from Bio import Cluster
handle = open("cyano.txt")
record = Cluster.read(handle)
handle.close()
genetree = record.treecluster(method='s')
genetree.scale()
exptree = record.treecluster(dist='u', transpose=1)
record.save("cyano_result", genetree, exptree)
这将创建文件cyano_result.cdt、cyano_result.gtr 和cyano_result.atr
现在,我们可以使用R 和 Bioconductor 将 atr 转换为 newick
安装最新版本的R,然后通过启动R并输入命令获取最新版本的Bioconductor
#optional, for install bioconductor and ctc library
source("http://bioconductor.org/biocLite.R")
biocLite()
biocLite("ctc")
#code to convert atr to newick
library("ctc")
h <- xcluster2r("cyano_result.atr")
write(hc2Newick(h),file='cyano_result.newick')
在cyano_result,我们得到:
(1:0.356996468574314,
(2:0.0826361905178331,
(5:0.0469498559561281,
(3:0.513417484951725,4:0.513417484951725)
:0.0469498559561281)
:0.0826361905178331)
:0.356996468574314);
得到下面的情节