查看原文
其他

进化树改名

Y叔 YuLabSMU 2022-09-20

I don't know whether 'rename taxa' is a common task or not. It seems not a good idea to rename taxa in Newick tree text, since it may introduce problems when mapping the original sequence alignment to the tree.

If you just want to show different or additional information when plotting the tree, it is fine and easy to do it using ggtree:

require(treeio)
require(ggtree)
tr <- read.tree(text = "((a,(b,c)),d);")
genus <- c("Gorilla", "Pan", "Homo", "Pongo")
species <- c("gorilla", "spp.", "sapiens", "pygmaeus")
geo <- c("Africa", "Africa", "World", "Asia")
d <- data.frame(label = tr$tip.label, genus = genus,
               species = species, geo = geo)
ggtree(tr) %<+% d + xlim(NA, 5) +
   geom_tiplab(aes(label=paste0('italic(', genus, ')~bolditalic(', species, ')~', geo)), parse=T)

However, it is also possible to rename taxa of the tree object (either treedata or phylo) in treeio:

tr2 = rename_taxa(tr, d, label, genus)
write.tree(tr2)
d2 = dplyr::mutate(d, newlab = paste(genus, species, sep='|'))
tr3 = rename_taxa(tr, d2, label, newlab)
write.tree(tr3)

If the input tree object is a treedata instance, you can use write.beast to export the tree with associated data to a BEAST compatible NEXUS file.

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存