我有一个csv文件,其中包含数百个物种的物种名称,顺序与它们在我的系统发展史中的$tip.labels中出现的顺序相同。我想用新的物种名称替换这些物种名称,使其与从$tip.labels输出的原始物种名称的顺序相同。我想保留我的树状拓扑,只是想用新的分类法名称更新我的系统树。
$tip.labels的输出:
old_taxonomic_names
old_species_name_1
old_species_name_2
old_species_name_3
...具有更新的分类的输入:
new_taxonomic_names
new_species_name_1
new_species_name_2
new_species_name_3
...发布于 2019-08-19 05:11:41
考虑下面的玩具示例:
library("ape")
orig_tiplabels <- c("Alice", "Bob", "Cindy")
orig_tree <- rtree(n = 3, tip.label = orig_tiplabels)
plot(orig_tree)
new_tiplabels <- c("Debbie", "Elrond", "Frank")
orig_tree$tip.label <- new_tiplabels
plot(orig_tree)orig_tree是下面的树:

由于我们只想更改tip标签,因此可以直接更新$tip.label属性。这将生成一个“新”树,其中包含更新的提示标签,但拓扑结构保持不变,如下所示。

只要新标签的数量与现有标签的数量(在树中)相同,并且使用相同的树对象,就可以执行此操作。
https://stackoverflow.com/questions/57547769
复制相似问题