更改R中系统发育的尖端标签 [英] Change tip labels in phylogeny in R

查看:207
本文介绍了更改R中系统发育的尖端标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个csv文件,该文件由数百个物种的物种名称组成,它们的顺序与它们在我的系统进化树中出现在$tip.labels中的顺序相同.我想将这些物种名称换成新的物种名称,这样的顺序与我从$tip.labels输出的原始物种名称的顺序相同.我想保留我的树形拓扑,只是尝试使用新的分类名称来更新我的系统发育.

I have a csv file which consists of species names for several hundred species in the same order in which they appear in $tip.labels from my phylogeny. I want to swap out these species names with new species names such that is in the same order as my original species names output from $tip.labels. I want to preserve my tree topology, just trying to update my phylogeny with new taxonomic names.

$ tip.labels的输出:

output from $tip.labels:

old_taxonomic_names
old_species_name_1
old_species_name_2
old_species_name_3
...

输入具有更新的分类法:

input with updated taxonomy:

new_taxonomic_names
new_species_name_1
new_species_name_2
new_species_name_3
...

推荐答案

请考虑以下玩具示例:

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.label属性.这为我们提供了一个带有更新的提示标签的新"树,但是拓扑得以保留,如下所示.

Since we only want to change the tip labels, we can simply update the $tip.label attribute directly. This yields us a "new" tree with updated tip labels, but the topology preserved, as shown below.

只要新标签的数量与现有标签的数量(在树中)相同,并且使用相同的树对象,这将起作用.

This will work as long as the number of new labels is the same as the number of existing labels (in the tree), and the same tree object is used.

这篇关于更改R中系统发育的尖端标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆