以下只用到了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