【问题标题】:Duplicate tips label removal: importing phylogenetic tree in R for comparison重复提示标签去除:在 R 中导入系统发育树进行比较
【发布时间】:2018-07-10 09:13:23
【问题描述】:

问题:

我正在尝试导入一个 newick 格式的系统发育树,我以前做过,(以相同方式制作的树,所以代码有效!)但是树似乎是问题所在。我收到重复提示标签错误。如果是这种情况,有没有办法轻松删除 R 中的重复提示?

当前代码:

library(ape)
library(geiger)
library(caper)


taxatree <- read.tree("test2.tre")
sumdata <- read.csv("ogtprop.csv")
    sumdataPGLS <-data.frame(A=sumdata$A,OGT=sumdata$OGT, Species=sumdata$Species)


sumdataPGLS$Species<-gsub(" ", "_", sumdata$Species)
#this line inserts an underscore between species and genus in my dataframe, (as the tree is formatted like this)

comp.dat <- comparative.data(taxatree, sumdataPGLS, "Species")

最后一行后出现以下错误:

Error in comparative.data(taxatree, sumdataPGLS, "Species") : 
  Duplicate tip labels present in phylogeny 

表明问题纯粹在于系统发育,而不是数据框。

期望的结果:

一种在 R 中删除重复提示标签的方法

输入数据:

不幸的是,树太大了,我不能把它全部放在这里,但是这里是数据的一个子集(注意,这不会单独工作),我在这里展示它以防万一对其他人来说显而易见的系统性错误:

(((('Acidilobus_saccharovorans':4,'Caldisphaera_lagunensis':4)Acidilobales:4,
('Sulfurisphaera_tokodaii':4,('Metallosphaera_hakonensis':4,
'Metallosphaera_sedula':4)Metallosphaera:4,('Acidianus_sulfidivorans':4,
'Acidianus_brierleyi':4)Acidianus:4,('Sulfolobus_metallicus':4,
'Sulfolobus_solfataricus':4,'Sulfolobus_acidocaldarius':4)Sulfolobus:4)
Sulfolobaceae:4,(('Pyrolobus_fumarii':4,'Hyperthermus_butylicus':4,
'Pyrodictium_occultum':4)Pyrodictiaceae:4,('Aeropyrum_camini':4,
('Ignicoccus_hospitalis':4,'Ignicoccus_islandicus':4)Ignicoccus:4,   

【问题讨论】:

    标签: r phylogeny


    【解决方案1】:

    我的比较数据也遇到了同样的问题。我有:

    maxillariinae <- comparative.data(tree_gs, data.000, spp_code, vcv=TRUE, vcv.dim=3)
    >Error in comparative.data(tree_gs, data.000, spp_code, vcv = TRUE, vcv.dim = 3) : 
    >Labels duplicated between tips and nodes in phylogeny
    

    我用一个非常简单的方法解决了它:

    # Removing node labels:
    tree_gs$node.label<-NULL
    

    然后,当我尝试设置比较数据时,它就起作用了。我接下来做的 pgls 也有效。 我希望它对你有用。

    【讨论】:

      【解决方案2】:

      一种可能的解决方案,因为问题似乎是输入到“phylo”类中的树的格式,在这种情况下,内部节点具有名称,其中一些名称与属相同。

      “清理”树的一种方法是对其进行格式化,我发现一种可行的方法是通过 python 包:ete3 (http://etetoolkit.org/)

      from ete3 import Tree
      import sys
      
      t = Tree(sys.argv[1], format=1)
      
      t.write(format=5, outfile="test4.tre")
      

      有用的函数是t.write(format=5,格式= 5,意味着它以R中使用的comparitive.data函数可接受的类型写入。在这种情况下,没有内部节点名称。

      【讨论】:

        【解决方案3】:

        我遇到了同样的问题,因为我的 Newick 树除了距离之外还包含引导支持值。 >comparative.data 删除支持值后工作正常。 (引导值为 0.97.. -0.99..) 以下是原始树和修改后的树:

        原创

        ((Alligator:0.09129139,(Turtle:0.12361699,(Lizard:0.18330984,
        ((TasmDevil:0.02519765,Opossum:0.01841396)0.998733:0.03121792,
        (Armadillo:0.05330751,((Cow:0.12244558,Dog:0.07483858)0.983085:0.02485452,
        (Mouse:0.14438626,GuineaPig:0.03974587)0.972224:0.02107559)0.889194:0.01974521)
        0.99985:0.03529365)0.99985:0.18024398)0.988266:0.074151)0.974215:0.11888747)
        :1.0964437,Frog:1.0964437):0.0;
        

        修改

        ((Alligator:0.09129139,(Turtle:0.12361699,(Lizard:0.18330984,
        ((TasmDevil:0.02519765,Opossum:0.01841396):0.03121792,
        (Armadillo:0.05330751,((Cow:0.12244558,Dog:0.07483858):0.02485452,
        (Mouse:0.14438626,GuineaPig:0.03974587):0.02107559):0.01974521):0.03529365)
        :0.18024398):0.074151):0.11888747):1.0964437,Frog:1.0964437):0.0;
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2021-08-23
          • 2011-10-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-02-13
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多