Re: [R-sig-phylo] Bug in ape?
Hi Simon and others, I ran into the same problems a few days ago and I suspect it's related to changes associated with R 3.4.0. Re-installing ape solved the issue for me. Cheers, -- François On Wed, Apr 26, 2017 at 11:01 PM, Simon Blombergwrote: > False alarm. I cleared my workspace and re-started R and the problem has > gone away. I'm curious to know how it occurred but I'm happy that it has > been resolved. We now return you to your scheduled R programming... > > Cheers, > > Simon. > > > > On 27/04/17 12:44, Simon Blomberg wrote: >> >> Hi Emmanuel and other list members. >> >> I am having some problems creating and working with trees (phylo objects) >> in ape. Has anyone else seen this error? The following code reproduces the >> errors: >> >> library(ape) >> tr1 <- rtree(10) >> >> plot(tr1) >> >> Error in .reorder_ape(x, order, index.only, length(x$tip.label), io) : >> object 'neworder_phylo' not found >> >> tr2 <- rcoal(10) >> >> Error in .reorder_ape(x, order, index.only, length(x$tip.label), io) : >> object 'neworder_phylo' not found >> >> tr3 <- read.tree(text="((a, b), (c, d));") >> >> compute.brlen(tr3) >> >> Error in .reorder_ape(x, order, index.only, length(x$tip.label), io) : >> object 'neworder_phylo' not found >> >> ## All have the same traceback: >> >> > traceback() >> 4: .reorder_ape(x, order, index.only, length(x$tip.label), io) >> 3: reorder.phylo(phy, "postorder") >> 2: reorder(phy, "postorder") >> 1: compute.brlen(tr3) >> >> > sessionInfo() >> >> R version 3.4.0 (2017-04-21) >> Platform: x86_64-pc-linux-gnu (64-bit) >> Running under: Ubuntu 17.04 >> >> Matrix products: default >> BLAS: /usr/lib/openblas-base/libblas.so.3 >> LAPACK: /usr/lib/libopenblasp-r0.2.19.so >> >> locale: >> [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C >> [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 >> [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 >> [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C >> [9] LC_ADDRESS=C LC_TELEPHONE=C >> [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C >> >> attached base packages: >> [1] stats graphics grDevices utils datasets methods base >> >> other attached packages: >> [1] ape_4.1 >> >> loaded via a namespace (and not attached): >> [1] Rcpp_0.12.10 magrittr_1.5 splines_3.4.0 MASS_7.3-47 >> [5] munsell_0.4.3colorspace_1.3-2 lattice_0.20-35 minqa_1.2.4 >> [9] stringr_1.2.0glmmADMB_0.8.3.3 plyr_1.8.4 tcltk_3.4.0 >> [13] tools_3.4.0 parallel_3.4.0 nnet_7.3-12 grid_3.4.0 >> [17] nlme_3.1-131 gtable_0.2.0 coda_0.19-1 fortunes_1.5-4 >> [21] lme4_1.1-13 lazyeval_0.2.0 tibble_1.3.0 Matrix_1.2-8 >> [25] R2admb_0.7.15nloptr_1.0.4 ggplot2_2.2.1 effects_3.1-2 >> [29] stringi_1.1.5compiler_3.4.0 scales_0.4.1 >> >> I am not getting the error on two other machines with the same OS and (as >> far as I can tell) the same setup. Any help would be greatly appreciated! >> >> Cheers, >> >> Simon. >> > > -- > Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat. > Senior Lecturer and Consultant Statistician > School of Biological Sciences > The University of Queensland > St. Lucia Queensland 4072 > Australia > T: +61 7 3365 2506 > email: S.Blomberg1_at_uq.edu.au > http://www.evolutionarystatistics.org > > Policies: > 1. I will NOT analyse your data for you. > 2. Your deadline is your problem. > > Basically, I'm not interested in doing research and > I never have been. I'm interested in understanding, > which is quite a different thing. And often to > understand something you have to work it out for > yourself because no one else has done it. > - David Blackwell > > ___ > R-sig-phylo mailing list - R-sig-phylo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-phylo > Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/ ___ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
Re: [R-sig-phylo] Bug in ape?
False alarm. I cleared my workspace and re-started R and the problem has gone away. I'm curious to know how it occurred but I'm happy that it has been resolved. We now return you to your scheduled R programming... Cheers, Simon. On 27/04/17 12:44, Simon Blomberg wrote: Hi Emmanuel and other list members. I am having some problems creating and working with trees (phylo objects) in ape. Has anyone else seen this error? The following code reproduces the errors: library(ape) tr1 <- rtree(10) plot(tr1) Error in .reorder_ape(x, order, index.only, length(x$tip.label), io) : object 'neworder_phylo' not found tr2 <- rcoal(10) Error in .reorder_ape(x, order, index.only, length(x$tip.label), io) : object 'neworder_phylo' not found tr3 <- read.tree(text="((a, b), (c, d));") compute.brlen(tr3) Error in .reorder_ape(x, order, index.only, length(x$tip.label), io) : object 'neworder_phylo' not found ## All have the same traceback: > traceback() 4: .reorder_ape(x, order, index.only, length(x$tip.label), io) 3: reorder.phylo(phy, "postorder") 2: reorder(phy, "postorder") 1: compute.brlen(tr3) > sessionInfo() R version 3.4.0 (2017-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 17.04 Matrix products: default BLAS: /usr/lib/openblas-base/libblas.so.3 LAPACK: /usr/lib/libopenblasp-r0.2.19.so locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ape_4.1 loaded via a namespace (and not attached): [1] Rcpp_0.12.10 magrittr_1.5 splines_3.4.0 MASS_7.3-47 [5] munsell_0.4.3colorspace_1.3-2 lattice_0.20-35 minqa_1.2.4 [9] stringr_1.2.0glmmADMB_0.8.3.3 plyr_1.8.4 tcltk_3.4.0 [13] tools_3.4.0 parallel_3.4.0 nnet_7.3-12 grid_3.4.0 [17] nlme_3.1-131 gtable_0.2.0 coda_0.19-1 fortunes_1.5-4 [21] lme4_1.1-13 lazyeval_0.2.0 tibble_1.3.0 Matrix_1.2-8 [25] R2admb_0.7.15nloptr_1.0.4 ggplot2_2.2.1 effects_3.1-2 [29] stringi_1.1.5compiler_3.4.0 scales_0.4.1 I am not getting the error on two other machines with the same OS and (as far as I can tell) the same setup. Any help would be greatly appreciated! Cheers, Simon. -- Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat. Senior Lecturer and Consultant Statistician School of Biological Sciences The University of Queensland St. Lucia Queensland 4072 Australia T: +61 7 3365 2506 email: S.Blomberg1_at_uq.edu.au http://www.evolutionarystatistics.org Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. Basically, I'm not interested in doing research and I never have been. I'm interested in understanding, which is quite a different thing. And often to understand something you have to work it out for yourself because no one else has done it. - David Blackwell ___ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
[R-sig-phylo] Bug in ape?
Hi Emmanuel and other list members. I am having some problems creating and working with trees (phylo objects) in ape. Has anyone else seen this error? The following code reproduces the errors: library(ape) tr1 <- rtree(10) plot(tr1) Error in .reorder_ape(x, order, index.only, length(x$tip.label), io) : object 'neworder_phylo' not found tr2 <- rcoal(10) Error in .reorder_ape(x, order, index.only, length(x$tip.label), io) : object 'neworder_phylo' not found tr3 <- read.tree(text="((a, b), (c, d));") compute.brlen(tr3) Error in .reorder_ape(x, order, index.only, length(x$tip.label), io) : object 'neworder_phylo' not found ## All have the same traceback: > traceback() 4: .reorder_ape(x, order, index.only, length(x$tip.label), io) 3: reorder.phylo(phy, "postorder") 2: reorder(phy, "postorder") 1: compute.brlen(tr3) > sessionInfo() R version 3.4.0 (2017-04-21) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 17.04 Matrix products: default BLAS: /usr/lib/openblas-base/libblas.so.3 LAPACK: /usr/lib/libopenblasp-r0.2.19.so locale: [1] LC_CTYPE=en_AU.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_AU.UTF-8LC_COLLATE=en_AU.UTF-8 [5] LC_MONETARY=en_AU.UTF-8LC_MESSAGES=en_AU.UTF-8 [7] LC_PAPER=en_AU.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ape_4.1 loaded via a namespace (and not attached): [1] Rcpp_0.12.10 magrittr_1.5 splines_3.4.0 MASS_7.3-47 [5] munsell_0.4.3colorspace_1.3-2 lattice_0.20-35 minqa_1.2.4 [9] stringr_1.2.0glmmADMB_0.8.3.3 plyr_1.8.4 tcltk_3.4.0 [13] tools_3.4.0 parallel_3.4.0 nnet_7.3-12 grid_3.4.0 [17] nlme_3.1-131 gtable_0.2.0 coda_0.19-1 fortunes_1.5-4 [21] lme4_1.1-13 lazyeval_0.2.0 tibble_1.3.0 Matrix_1.2-8 [25] R2admb_0.7.15nloptr_1.0.4 ggplot2_2.2.1 effects_3.1-2 [29] stringi_1.1.5compiler_3.4.0 scales_0.4.1 I am not getting the error on two other machines with the same OS and (as far as I can tell) the same setup. Any help would be greatly appreciated! Cheers, Simon. -- Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat. Senior Lecturer and Consultant Statistician School of Biological Sciences The University of Queensland St. Lucia Queensland 4072 Australia T: +61 7 3365 2506 email: S.Blomberg1_at_uq.edu.au http://www.evolutionarystatistics.org Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. Basically, I'm not interested in doing research and I never have been. I'm interested in understanding, which is quite a different thing. And often to understand something you have to work it out for yourself because no one else has done it. - David Blackwell ___ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
Re: [R-sig-phylo] Bug in ape: dropping tips from a ladderized tree (still) randomly shuffles the node labels
Hi Emannuel (and list), Just wanted to let you know that after some testing with my own cases, the new drop.tip appears to fix the error, so the issue is closed from my perspective. Cheers, -Dave On Tue, Jul 28, 2015 at 12:25 PM, Emmanuel Paradis emmanuel.para...@ird.fr wrote: Hi David, I've conducted more tests and the bug was really in drop.tip and sometimes apparent without calling ladderize. The fix seems to work well. I have built ape 3.3-0.6 which is available on ape-package.ird.fr as source package. Best, Emmanuel Le 25/07/2015 19:33, Emmanuel Paradis a écrit : David, I was thinking about some simple tests to check that the function still works correctly in other situations. It can happen that when fixing a bug which occurs in a special situation in a piece of code, the code then fails in other (possibly simpler) situations. In the present case, the fix is the part of the code that renumbers the nodes which is thus used in all cases (even if there are no node labels). I'll conduct some tests later, but in the mean time if you see something strange, just tell me. I attach the new source file. Best, Emmanuel Le 25/07/2015 18:54, David Bapst a écrit : Hi Emmanuel, Thank you for the fix! And, yes, I realize, its probably one of ape's most widely used functions. Perhaps what we need is a function that tests whether there is a mismatch in the node.labels, across trees that might have different sets of taxa, which will help in the future to alert us if this bug appears again. Of course, such a function would need to avoid using drop.tip entirely. I've looked and I'm not aware of any function across the entire Phylogenetics taskview that fulfills this criteria. So, I admit that's a tough order. I've made a particularly ugly first stab at such a thing, mostly depending on prop.part. Its rather clumsy, as I originally wrote it as code to fix node.labels, rather than find the mismatches. Unfortunately, at present, it misidentifies root-ward losses of clades, due to dropping of stem/out-group tips, as a mismatch between node labels. Perhaps someone else will see a cleaner, more accurate solution. ### library(ape) testNodeLabels-function(tree1,tree2,printMisMatch=TRUE,plot=FALSE){ nlab1-tree1$node.label if(!is.null(tree2$node.label)){ nlab2-tree2$node.label }else{ nlab2-rep(NA,Nnode(tree2)) } #if tree2 has any taxa not in tree1, stop noMatch-sapply(tree2$tip.label,function(x) !any(x==tree1$tip.label)) if(any(noMatch)){ stop(tree2 has taxa not found in tree1 and thus is uncomparable) } # desc1-lapply(prop.part(tree1),function(x) tree1$tip.label[x]) desc2-lapply(prop.part(tree2),function(x) tree2$tip.label[x]) #need to remove taxa not shared by one without using drop.tip taxa-c(tree1$tip.label,tree2$tip.label) shared-taxa[sapply(taxa,function(x) any(x==tree1$tip.label) any(x==tree2$tip.label))] #get ndesc for desc2 ndesc2-sapply(desc2,length) #reorder desc2 and nlab2 desc2-desc2[order(ndesc2)] nlab2-nlab2[order(ndesc2)] result-TRUE for(i in 1:length(desc1)){ target-desc1[[i]] targetName-nlab1[i] sharedDesc-target[sapply(target,function(x) any(x==shared))] if(length(sharedDesc)1){ #find matches in 2 matches-sapply(desc2,function(x) all(sapply(sharedDesc,function(z) any(z==x }else{ matches-FALSE } #get richest match - if there is no match, get NA matchClade-which(matches)[1] if(!is.na(matchClade)){ matchName-identical(nlab1[i],nlab2[matchClade]) if(!matchName){ result-FALSE if(printMisMatch){ warning(paste(\n A node with descendants:, paste0(sharedDesc,collapse=', '), \n is labeled:,nlab1[i], in tree1 but labeled:, nlab2[matchClade],in tree2 \n)) } } } } # if(plot){ #plot it layout(1:2) plot(tree1,show.tip.label=TRUE,use.edge.length=FALSE) nodelabels(tree1$node.label) plot(tree2,show.tip.label=TRUE,use.edge.length=FALSE) nodelabels(tree2$node.label) layout(1) } return(result) } set.seed(1) tree-rtree(10) tree$node.label-rep(NA,Nnode(tree)) tree$node.label[1]-ROOT tree$node.label[5]-HELLO tree$node.label[8]-NOPE tree1-drop.tip(tree,t2) tree2-ladderize(tree) tree3-drop.tip(tree2,t2) testNodeLabels(tree,tree1) testNodeLabels(tree,tree2) testNodeLabels(tree,tree3)
Re: [R-sig-phylo] Bug in ape: dropping tips from a ladderized tree (still) randomly shuffles the node labels
Hi David, I've conducted more tests and the bug was really in drop.tip and sometimes apparent without calling ladderize. The fix seems to work well. I have built ape 3.3-0.6 which is available on ape-package.ird.fr as source package. Best, Emmanuel Le 25/07/2015 19:33, Emmanuel Paradis a écrit : David, I was thinking about some simple tests to check that the function still works correctly in other situations. It can happen that when fixing a bug which occurs in a special situation in a piece of code, the code then fails in other (possibly simpler) situations. In the present case, the fix is the part of the code that renumbers the nodes which is thus used in all cases (even if there are no node labels). I'll conduct some tests later, but in the mean time if you see something strange, just tell me. I attach the new source file. Best, Emmanuel Le 25/07/2015 18:54, David Bapst a écrit : Hi Emmanuel, Thank you for the fix! And, yes, I realize, its probably one of ape's most widely used functions. Perhaps what we need is a function that tests whether there is a mismatch in the node.labels, across trees that might have different sets of taxa, which will help in the future to alert us if this bug appears again. Of course, such a function would need to avoid using drop.tip entirely. I've looked and I'm not aware of any function across the entire Phylogenetics taskview that fulfills this criteria. So, I admit that's a tough order. I've made a particularly ugly first stab at such a thing, mostly depending on prop.part. Its rather clumsy, as I originally wrote it as code to fix node.labels, rather than find the mismatches. Unfortunately, at present, it misidentifies root-ward losses of clades, due to dropping of stem/out-group tips, as a mismatch between node labels. Perhaps someone else will see a cleaner, more accurate solution. ### library(ape) testNodeLabels-function(tree1,tree2,printMisMatch=TRUE,plot=FALSE){ nlab1-tree1$node.label if(!is.null(tree2$node.label)){ nlab2-tree2$node.label }else{ nlab2-rep(NA,Nnode(tree2)) } #if tree2 has any taxa not in tree1, stop noMatch-sapply(tree2$tip.label,function(x) !any(x==tree1$tip.label)) if(any(noMatch)){ stop(tree2 has taxa not found in tree1 and thus is uncomparable) } # desc1-lapply(prop.part(tree1),function(x) tree1$tip.label[x]) desc2-lapply(prop.part(tree2),function(x) tree2$tip.label[x]) #need to remove taxa not shared by one without using drop.tip taxa-c(tree1$tip.label,tree2$tip.label) shared-taxa[sapply(taxa,function(x) any(x==tree1$tip.label) any(x==tree2$tip.label))] #get ndesc for desc2 ndesc2-sapply(desc2,length) #reorder desc2 and nlab2 desc2-desc2[order(ndesc2)] nlab2-nlab2[order(ndesc2)] result-TRUE for(i in 1:length(desc1)){ target-desc1[[i]] targetName-nlab1[i] sharedDesc-target[sapply(target,function(x) any(x==shared))] if(length(sharedDesc)1){ #find matches in 2 matches-sapply(desc2,function(x) all(sapply(sharedDesc,function(z) any(z==x }else{ matches-FALSE } #get richest match - if there is no match, get NA matchClade-which(matches)[1] if(!is.na(matchClade)){ matchName-identical(nlab1[i],nlab2[matchClade]) if(!matchName){ result-FALSE if(printMisMatch){ warning(paste(\n A node with descendants:, paste0(sharedDesc,collapse=', '), \n is labeled:,nlab1[i], in tree1 but labeled:, nlab2[matchClade],in tree2 \n)) } } } } # if(plot){ #plot it layout(1:2) plot(tree1,show.tip.label=TRUE,use.edge.length=FALSE) nodelabels(tree1$node.label) plot(tree2,show.tip.label=TRUE,use.edge.length=FALSE) nodelabels(tree2$node.label) layout(1) } return(result) } set.seed(1) tree-rtree(10) tree$node.label-rep(NA,Nnode(tree)) tree$node.label[1]-ROOT tree$node.label[5]-HELLO tree$node.label[8]-NOPE tree1-drop.tip(tree,t2) tree2-ladderize(tree) tree3-drop.tip(tree2,t2) testNodeLabels(tree,tree1) testNodeLabels(tree,tree2) testNodeLabels(tree,tree3) testNodeLabels(tree,tree3,plot=TRUE) Additionally, could you send the full revised source file? I have to admit, I always get lost looking for ape's newest source files on the ape website. Cheers, -Dave On Sat, Jul 25, 2015 at 6:20 AM, Emmanuel Paradis emmanuel.para...@ird.fr wrote: Hi David, Here is a fix for drop.tip (line numbers refer to the source
[R-sig-phylo] Bug in ape: dropping tips from a ladderized tree (still) randomly shuffles the node labels
Hello all, Recently I noticed a complex function of mine that does some tree transformations was randomly scrambling node.label elements. In the course of doing so, I found this old email (below) from Rebecca Best in 2012, which outlined an issue that occurred when a ladderized tree had tips dropped. It appears that bug has reappeared in more recent version of ape. Here's a slightly modified version of her example code, which appears to still replicate a node label shuffling in ape v3.3. # require(ape) #read tree mytree-read.tree() ((D,(E,G)1)1,((H,J)0.8,(K,(((L,M)0.5,(N,O)0.6)1,(P,(Q,R)1)1)0.7)1)1); #ladderize tree mytree.lad-ladderize(mytree) #node labels display on both trees correctly layout(1:2) plot(mytree,show.node.label=TRUE) plot(mytree.lad,show.node.label=TRUE) #drop tips from both trees drop.mytree-drop.tip(mytree,c(L,D,G)) drop.mytree.lad-drop.tip(mytree.lad,c(L,D,G)) #plot both trees, node labels are incorrect for ladderized tree dev.new() layout(1:2) plot(drop.mytree,show.node.label=TRUE) plot(drop.mytree.lad,show.node.label=TRUE) # Although I'm still in the process of dismantling my own issue, so I am not 100% certain, I strongly believe this is the culprit in my case, as my script partly drops.tips from an input tree (that happens to always be ladderized). Cheers, -Dave -- Forwarded message -- From: Rebecca Best rjb...@ucdavis.edu Date: Tue, Oct 2, 2012 at 12:26 AM Subject: [R-sig-phylo] ladderize + drop.tip = shuffled node labels To: r-sig-phylo@r-project.org Hi all I have been plotting some pruned trees recently, and have run into a problem using drop.tip() after ladderize(). If you ladderize() and then drop tips from the ladderized tree, then at least in my case the node labels are no longer correct. This may be an unlikely sequence of commands, but I thought I'd post this in case it is an easy fix, or it helps anyone else avoid issues. Thanks! Rebecca ## require(ape) #read tree mytree-read.tree() ((D,(E,G)1)1,((H,J)0.8,(K,(((L,M)0.5,(N,O)0.6)1,(P,(Q,R)1)1)0.7)1)1); #ladderize tree mytree.lad-ladderize(mytree) #node labels display on both trees correctly plot(mytree,show.node.label=TRUE) plot(mytree.lad,show.node.label=TRUE) #drop tips from both trees drop.mytree-drop.tip(mytree,c(L,D,G)) drop.mytree.lad-drop.tip(mytree.lad,c(L,D,G)) #plot both trees, node labels are incorrect for ladderized tree plot(drop.mytree,show.node.label=TRUE) plot(drop.mytree.lad,show.node.label=TRUE) ___ R-sig-phylo mailing list R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo -- David W. Bapst, PhD Adjunct Asst. Professor, Geology and Geol. Eng. South Dakota School of Mines and Technology 501 E. St. Joseph Rapid City, SD 57701 http://webpages.sdsmt.edu/~dbapst/ http://cran.r-project.org/web/packages/paleotree/index.html ___ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/