It works. Yay!  Thank you so much!
Stacey

Quoting Simon Blomberg <[EMAIL PROTECTED]>:

Hmm. I should try solutions before I post them. You need to make sure
that each tree in the list is of class phylo too. This works:

phylist<-read.tree(text="((((A:0.21,B:0.21):0.28,C:0.49):0.13,D:0.62):0.38,E:1.00);((((A:0.21,B:0.21):0.28,C:0.49):0.13,D:0.62):0.38,E:1.00);")
newnames<-c("G","H","I","J","K")
newlist <- lapply(phylist,
   function(z) {
   z$tip.label <- c("G","H","I","J","K")
   class(z) <- "phylo"
   z
  })

class(newlist) <- "multiPhylo"
write.tree(newlist,file="newlist")



On Mon, 2008-09-01 at 10:55 +1000, Simon Blomberg wrote:
Try

class(newlist) <- "multiPhylo"

Then use write.tree.

Cheers,

Simon.

On Sun, 2008-08-31 at 20:39 -0400, [EMAIL PROTECTED] wrote:
> Hi all,
> I have hit an obstacle and I hope someone will know a quick fix.  I
> want to read
> a list of trees, do something to those trees and then write them to a
> file. The list is seen as multiPhylo until I apply some function then
> it becomes a
> list that I cannot write to a file with write.tree. I put an example below, > where I read in two trees, and then use a function to change the tip names and
> then try to write the trees to a file.
> Thanks in advance for your help!
> Stacey
>
> > phylist<-read.tree(text="((((A:0.21,B:0.21):0.28,C:0.49):0.13,D:0.62):0.38,E:1.00);
> > ((((A:0.21,B:0.21):0.28,C:0.49):0.13,D:0.62):0.38,E:1.00);")
> > class(phylist)
> [1] "multiPhylo"
> > newnames<-c("G","H","I","J","K")
> > newlist <- lapply(phylist,
> +    function(z) {
> +        z$tip.label <- c("G","H","I","J","K")
> +        z
> +    })
> > write.tree(newlist,file="newlist")
> Error in write.tree(newlist, file = "newlist") :
>   object "phy" is not of class "phylo"
>
> (and yes, write.tree did work on the multiphylo object before I did the
> function)
>
> _______________________________________________
> R-sig-phylo mailing list
> R-sig-phylo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
--
Simon Blomberg, BSc (Hons), PhD, MAppStat.
Lecturer and Consultant Statistician
Faculty of Biological and Chemical Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for
an answer does not ensure that a reasonable answer can
be extracted from a given body of data. - John Tukey.



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

Reply via email to