R Under development (unstable) (2024-01-28 r85838 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(phylobase) > library(ape) Attaching package: 'ape' The following object is masked from 'package:phylobase': edges > > ## set.seed(1) > ## t0A <- rcoal(5) > t0 <- read.tree(text="((t4:0.3210275554,(t2:0.2724586465,t3:0.2724586465):0.0485689089):0.1397952619,(t5:0.07551818331,t1:0.07551818331):0.385304634);") > ## hack around variability in ape: > ## read.tree() and rcoal() produce sets of > ## elements in different orders > t0 <- unclass(t0)[c("edge","edge.length","tip.label","Nnode")] > class(t0) <- "phylo" > > ## phylo -> phylo4 -> phylo > t1 <- as(t0,"phylo4") > t5 <- as(t1,"phylo") Warning message: In asMethod(object) : trees with unknown order may be unsafe in ape > stopifnot(identical(t0,t5)) > > ## phylo4 -> phylo4vcov -> phylo4 -> phylo > t2<-as(t1,"phylo4vcov") Warning message: In asMethod(object) : trees with unknown order may be unsafe in ape > t3<-as(t2,"phylo4") > t4<-as(t3,"phylo") > stopifnot(identical(t4$edge,t0$edge) && + identical(t4$tip.label,t0$tip.label) && + identical(t4$Nnode,t0$Nnode) && + max(abs(t4$edge.length-t0$edge.length))<1e-10) > > ## UNROOTED > t6 <- ape::unroot(t0) > ## hack around ape conversion issues: > ## unroot() converts integer to double > storage.mode(t6$edge) <- "integer" > storage.mode(t6$Nnode) <- "integer" > t7 <- as(as(t6,"phylo4"),"phylo") > stopifnot(identical(t6,t7)) > > > ## EXPLICIT ROOT EDGE > t8 <- t0 > t8$root.edge <- 0.5 > t9 <- as(as(t8,"phylo4"),"phylo") Warning message: In asMethod(object) : trees with unknown order may be unsafe in ape > stopifnot(identical(t8,t9)) > > proc.time() user system elapsed 1.85 0.37 2.21