如何獲得BirdTree的一致樹(consensus tree)

以下只用到了R中的ape

1. 從BirdTree下載大量樹文件

https://data.vertlife.org/?basetree=birdtree&start_folder=Stage2/

有Hackett和Ericson兩種backbone。文獻中見到的更多的是Hackett。

一個文件是1000個樹(不同boostrap的topology),根據(jù)目標類群的大小和親緣關系決定具體下多少。以下假定下載了所有樹

2. 確定目標物種

假定目標物種都存在了向量sp

3. 對每一個樹做獨立的剪枝

#### trim tree
filenames = c('AllBirdsHackett1.tre','BirdzillaHackett2.tre','BirdzillaHackett4.tre','BirdzillaHackett6.tre',
                'BirdzillaHackett8.tre','BirdzillaHackett10.tre','BirdzillaHackett3.tre','BirdzillaHackett5.tre',
                'BirdzillaHackett7.tre','BirdzillaHackett9.tre')

new_trees = list()
tree_count = 0
n = 1000
file_count = 0

for (filename in filenames){
  file_count = file_count+1
  trees = read.tree(paste0(in_tree_parent_path,filename))
  
  for (tree in trees){
    tree = drop.tip(tree, tip=tree$tip.label[!tree$tip.label %in% sp])
    tree_count = tree_count + 1
    new_trees[[tree_count]] <- tree
    cat("\rFile", file_count, "Finished", tree_count, "of", n)
  }
}

write.tree(new_trees, out_name) ### 寫入10000棵樹剪枝后的結果

4. 獲得多數(shù)一致樹(majority consensus tree)

#### consnsus tree
consensus_tree = consensus(new_trees, p = 0.5, 
                           check.labels = TRUE, rooted = T)

consensus_rooted_tree = root(consensus_tree, 'Struthio_camelus') ### 重新root一下

write.tree(consensus_rooted_tree, out_name3) ### 輸出

也可以用Feng et al., 2020, Nature的文章中提供的一萬多種鳥的樹文件
Dense sampling of bird diversity increases power of comparative genomics

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容