前言:分析一組序列的tMRCA和進化速率,主要這幾類方法:①Regression of root-to-tip distances (軟體TempEst 或者軟體 Treetime),②least-squares dating(LSD,速度快,適合大數據), ③Scalable relaxed clock phylogeneticdating (Treedater),④Bayesian inference(貝葉斯分析,通過軟體beast完成)。
其中通過軟體Beast分析tMRCA和進化速率在本人之前的《Beast v1.8使用手冊》中已經提到,這裡重點介紹Regression of root-to-tip distances(RTT)裡的treetime軟體包分析tMRCA和進化速率。
參考文獻:《Estimating evolutionary rates using time-structured data: a general comparison of phylogenetic methods》,《TreeTime: Maximum-likelihood phylodynamic analysis》,《A comparison of methods for estimating substitution rates from ancient DNA sequence data 》
TempEst 和 Treetime以及LSD假設序列符合嚴格分子鐘,而BEAST默認是假設序列符合寬鬆分子鐘。
(2)適用範圍①RTT方法的適用於進化速率低的情況;估計分子鐘速率時,當物種多樣性低時TreeTime和LSD比BEAST表現好;當物種多樣性高時,BEAST表現好,TreeTime表現最差,物種多樣性對beast的影響不大。
②序列數量對Treetime、LSD、BEAST的影響
③LSD可以處理在不同譜系之間具有明顯水平速率變化的數據,LSD分析大數據集時速度快,而BEAST則非常慢。
2.Treetime的使用(1)在線版https://treetime.biozentrum.unibas.ch/ ①網站提供了示例數據,我們可以用示例數據看下效果:①我們選擇第一個「Time-tree inference」
這裡需要我們準備三個文件,newick格式的樹文件(通過其他軟體建好的ML樹)、fasta格式的對齊序列文件、時間文件,示例數據文件格式如下附件:
📎data.zip
需要注意的是,三個文件裡的序列名稱要一致。
默認是GTR模型,也可以進行其他模型設置:
我們先用網站提供的示例數據跑下看下效果:(通過點擊「Example datasets」預覽示例數據)
我們選擇流感H3N2的HA基因,測試下,Load後點擊下面的Run.
耐心等待幾分鐘:
②結果:(點擊放大更清晰)
③結果解讀
左下角的圖,μ 代表進化速率,如示例數據是3.921e-3(/site/year) ,R² 代表相關係數,示例數據為0.586。在上圖中,我們可以看到,隨著時間的增大,不同序列的Distance to root值也大致呈線性變化,表明這些序列具有時間結構;同時,不同譜系的序列之間良好的線性關係表示在不同譜系之間進化速率差別不大,說明這些序列可能適合嚴格分子鐘。
遺憾的是雖然圖很美,似乎還提供了結果打包的zip文件,但是,zip文件裡沒有提供圖片。沒有圖片倒問題不大,如果結果裡提供數據也可以自己做,比如zip裡的樹文件倒是可以用FigTree美化下,效果也還過得去。可是,zip文件裡沒有上圖左下角的圖片的數據(這張可以看進化速率和分子鐘類型的圖片非常重要),這是在線版的一個非常大的bug,所以,建議用本地版的Treetime。
(2)在Linux上運行TreetimeFAQ:我的電腦是windows系統,沒有linux怎麼辦?
如果你的電腦是win10系統,那就好辦了,可以免費安裝win10的分發版linux子系統,安裝教程見下:
https://www.windows10.pro/bash-on-ubuntu-on-windows/
這種方式,你可以簡單理解為在你的win10系統上多裝了一個軟體。
其實筆者也不想在liunx上運行這個程序,遺憾的是,windows版本的Treetime筆者沒有找到和結果輸出相關的參數,換句話說,windows版本的Treetime可以跑數據,但是不知道結果輸出在哪裡?實時界面雖然有一部分結果,但是不是想要的,於是先以linux版本的Treetime為例,以後找到了再補充windows版本的Treetime使用說明。
Treetime這個程序是python包。
①Linux上安裝Treetime安裝方法非常簡單,但是前提是你Linux系統上已經安裝了pip和biopython(pip和biopython的安裝方式見本人的「Linux學習筆記」知識庫)
先切換到管理員帳號,再在命令端輸入下面命令:
pip install phylo-treetime
系統提示安裝完成後,再在python裡輸入import treetime檢查下是否安裝成功,如下:
如果在python裡輸入import treetime沒有報錯則表示treetime包已經安裝成功。
②運行Treetime在linux系統命令終端輸入treetime -h 查看幫助文檔(注意不是在python裡)
部分截圖如下:
裡面有每個參數的介紹,其中指定輸出結果的位置的參數就是下面這個:
比如還有指定進化模型的參數是--gtr等等。
③功能(i)Timetrees
The to infer a timetree, i.e. a phylogenetic tree in which branch length reflect time rather than divergence, TreeTime offers implements the command:
$ treetime --aln <input.fasta> --tree <input.nwk> --dates <dates.csv>
```
This command will infer a time tree, ancestral sequences, a GTR model, and optionally confidence intervals and coalescent models.
A detailed explanation is of this command with its various options and examples are available at [treetime_examples/timetree.md](http://github.com/neherlab/treetime_examples/blob/master/timetree.md)
(ii)Rerooting and substitution rate estimation
To explore the temporal signal in the data and estimate the substitution rate (instead if full-blown timetree estimation), TreeTime implements a subcommand `clock` that is called as follows
$ treetime clock --tree <input.nwk> --aln <input.fasta> --dates <dates.csv> --reroot least-squares
```
The full list if options is available by typing `treetime clock -h`.
Instead of an input alignment, `--sequence-length <L>` can be provided.
Documentation of additional options and examples are available at [treetime_examples/clock.md](https://github.com/neherlab/treetime_examples/blob/master/clock.md)
(iii)Ancestral sequence reconstruction
The subcommand
$ treetime ancestral --aln input.fasta --tree input.nwk
```
will reconstruct ancestral sequences at internal nodes of the input tree.
The full list if options is available by typing `treetime ancestral -h`.
A detailed explanation of `treetime ancestral` with examples is available at [treetime_examples/ancestral.md](https://github.com/neherlab/treetime_examples/blob/master/ancestral.md)
(iv) Homoplasy analysis
Detecting and quantifying homoplasies or recurrent mutations is useful to check for recombination, putative adaptive sites, or contamination.
TreeTime provides a simple command to summarize homoplasies in data
$ treetime homoplasy --aln <input.fasta> --tree <input.nwk>
```
The full list if options is available by typing `treetime homoplasy -h`.
Please see [treetime_examples/homoplasy.md](https://github.com/neherlab/treetime_examples/blob/master/homoplasy.md) for examples and more documentation.
(v)Mugration analysis
Migration between discrete geographic regions, host switching, or other transition between discrete states are often parameterized by time-reversible models analogous to models describing evolution of genome sequences.
Such models are hence often called "mugration" models.
TreeTime GTR model machinery can be used to infer mugration models:
$ treetime mugration --tree <input.nwk> --states <states.csv> --attribute <field>
注意:以上黑體部分只是各功能最簡單的模板,具體參數請參考help文檔。
④示例數據以官網提供的示例數據包裡的ebola數據為例
打開linux終端,創建文件夾out為用來輸出結果的文件夾。再輸入treetime的運行命令:
treetime --aln ebola.fasta --tree ebola.nwk --dates ebola.metadata.csv --outdir out
正常運行效果如下:
耐心等待。運行完成後界面有結果提示:
使用上面簡單的參數實際輸出結果中含有下面這些:
📎root_to_tip_regression.pdf📎timetree.pdf
(a) root_to_tip_regression.pdf是下面這個:
可以看出這些數據具有時間結構,且不同譜系序列之間良好的線性關係表明其可能適合嚴格分子鐘。其中進化速率為7.98e-04+/- 1e-04(/site/year),tMRCA為:2013.9+/- 0.13(year)
(b)timetree.pdf是下面這個:
PDF文件是矢量圖,可用軟體AI進行修改微調。
(c) 覺得上面這棵時間樹不好看,可以用結果裡的timetree.nexus文件,使用FigTree打開,重新繪製下。
(d)ancestral_sequences.fasta裡有預測的每個節點的祖先序列。
3.注意點Treetime這個軟體預先利用每條序列的採樣時間進行分子鐘校準來計算這些數值,所以可以用來查看這些序列是否具有時間結構,如果具有時間結構,那麼它估算的tMRCA和進化速率是有意義的;如果這些序列不具備時間結構,那麼它估算的tMRCA和進化速率則沒有意義。詳情請參考文首第一篇參考文獻。
2019年1月15日初稿
轉載請註明出處。如有錯誤,歡迎及時與我反饋。
長按關注
微信公眾號生信雀