美文网首页
如何获得BirdTree的一致树(consensus tree)

如何获得BirdTree的一致树(consensus tree)

作者: 杨康chin | 来源:发表于2023-07-06 14:49 被阅读0次

    以下只用到了R中的ape

    1. 从BirdTree下载大量树文件

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

    有Hackett和Ericson两种backbone。文献中见到的更多的是Hackett。

    一个文件是1000个树(不同boostrap的topology),根据目标类群的大小和亲缘关系决定具体下多少。以下假定下载了所有树

    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. 获得多数一致树(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

    相关文章

      网友评论

          本文标题:如何获得BirdTree的一致树(consensus tree)

          本文链接:https://www.haomeiwen.com/subject/dviludtx.html