YuLab-SMU / treeio

:seedling: Base Classes and Functions for Phylogenetic Tree Input and Output
https://yulab-smu.top/treedata-book/
94 stars 24 forks source link

rename tip label by a mapping table for multiphylo tree #79

Closed neptuneyt closed 2 years ago

neptuneyt commented 2 years ago

Dear Dr Yu, Thanks for your such amazing work. My issue is that, Suppose I have a newick file A, and a list of old and new names mapping table B, how do I replace these names at once and keep remains still? I have try rename_taxa(tree, mapping_data, label, newlab) of treeio, but it could not support multiphylo.

GuangchuangYu commented 2 years ago

see https://yulab-smu.top/treedata-book/faq.html?q=rename#faq-modify-label.

neptuneyt commented 2 years ago

Thanks for your reply in time. As you mentioned, I have used rename_taxa function, but it does not support multiPhylo, and returns an error as below, I guess it used as.phylo function, but it does not support it multiPhylo obj. So do you have any good way to replace tip lables for multiPhylo object. Thanks a lot.

GuangchuangYu commented 2 years ago

you can use lapply to iterate each phylo object. The multiPhylo is just a list of phylo.