François,

François Michonneau wrote on 12/02/2010 19:08:
Hi Dave,

  Maybe this example will help you:

foo <- vector("list", 2) #create an empty list of 2 elements
class(foo) <- "multiPhylo" #make this list a multiPhylo object
foo[[1]] <- rtree(10) #put a random tree with 10 tips in the first slot of the 
list
foo[[2]] <- rtree(10) #put another random tree in the second slot
foo[[3]] <- rtree(10) #here you add another tree to your mutlPhylo object
foo
3 phylogenetic trees

That's a solution indeed. You could even add several trees at once:

foo[4:5] <- list(rtree(10), rtree(10))

A problem may occur though because some "multiPhylo" objects have a unique vector of tip labels for all the trees (eg, if read from a NEXUS file with a translate block), so this kind of manipulation may lead to problems.

The advantage of having a unique vector of tip labels is to save memory and speed-up some computations (eg, in prop.part). But there's a problem here that needs to be solved. There are solutions at the R level of course, but they depend on what we want to have in practice. Any feed-back will be welcome.

Best,

Emmanuel

PS: technical details may be found here:

http://ape.mpl.ird.fr/misc/FormatTreeR_28July2008.pdf

  Cheers,
  -- François


On Fri, Feb 12, 2010 at 12:43, David Williams
<david.2.willi...@uconn.edu> wrote:
Hi

How can separate phylo objects be combined or added to an already existing
multiPhylo object? Using 'c()' loses attributes and various attempts with
as.list() failed as well. I resorted to writing to a tree file with
'append=T' then reading from that file into a multiPhylo object but
presumably there is a quicker way.

thanks

DaveW

_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo


_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

--
Emmanuel Paradis
IRD, Montpellier, France
  ph: +33 (0)4 67 16 64 47
 fax: +33 (0)4 67 16 64 40
http://ape.mpl.ird.fr/

_______________________________________________
R-sig-phylo mailing list
R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo

Reply via email to