Re: [R-sig-phylo] Can't load a tree with multitomies into 'ape'

2014-08-15 Thread Liam J. Revell

Hi Anna.

Your attached file with extension .nwk is also a Nexus style file so it 
cannot be read with read.tree or read.newick. read.tree and read.newick 
read a simple Newick style text string, or a set of such strings on 
separate lines in a file.


It looks like the problem with your Nexus file, extension .nex, is that 
there are line breaks or spaces within the Newick string. The problem 
with your Nexus file of extension .nwk is probably the figtree block 
(although this is just a guess).


Try this:

obj-readLines(IndTree.nwk)
ii-grep(tree_1,obj)
x-strsplit(obj[ii], )[[1]]
tree-read.tree(text=x[length(x)])

All the best, Liam

Liam J. Revell, Assistant Professor of Biology
University of Massachusetts Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 8/15/2014 9:56 AM, Anna Bastian wrote:

Dear list members,

I am trying to read a tree into R (‘ape’ package). I downloaded the
latest versions.

The tree has many polytomies and that might be the problem.

It contains ten species and each species contains of a different number
of individuals (those are the polytomies).

I attached it here.

I tried read.nexus

…and get:Error in trees[[i]] : subscript out of bounds

I tried read.tree #using a newick format for the tree)

…and get:Error in if (tp[3] != ) obj$node.label - tp[3] :

   missing value where TRUE/FALSE needed

I came across a “Robust Newick tree reader” by Liam Revell and tied the
code he provides
(http://www.phytools.org/read.newick/v0.5/read.newick.R) but I can’t
make it work.

Can somebody get the tree into R?

Please let me know if you know what’s wrong

Thanks a lot

Anna

**

** * * * * * * * * * * *

**

*University of Cape Town*
/Animal Evolution and Systematics Group/

Department of Biological Sciences
Room 3.32

Tel: +27 (0)21 6502405

Fax: +27 (0)21 6502718


UNIVERSITY OF CAPE TOWN

This e-mail is subject to the UCT ICT policies and e-mail disclaimer
published on our website at
http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable from
+27 21 650 9111. This e-mail is intended only for the person(s) to whom
it is addressed. If the e-mail has reached you in error, please notify
the author. If you are not the intended recipient of the e-mail you may
not use, disclose, copy, redirect or print the content. If this e-mail
is not related to the business of UCT it is sent by the sender in the
sender's individual capacity.




___
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] Can't load a tree with multitomies into 'ape'

2014-08-15 Thread Anna Bastian
Great, François.
Now I have the tree in R and can continue with the next steps.

Thanks a lot for your help

Anna



From: François Michonneau [mailto:francois.michonn...@gmail.com]
Sent: Freitag, 15. August 2014 16:07
To: Anna Bastian
Cc: r-sig-phylo@r-project.org
Subject: Re: [R-sig-phylo] Can't load a tree with multitomies into 'ape'


Hi Anna,
  I can read your tree using the package phylobase:
tr - readNexus(file=IndTree.nex)
  If you need it in the phylo format to use with other functions in ape, you 
can convert it with:
as(tr, phylo)
  cheers,
  -- François

On Fri, Aug 15, 2014 at 9:56 AM, Anna Bastian 
anna.bast...@uct.ac.zamailto:anna.bast...@uct.ac.za wrote:
Dear list members,

I am trying to read a tree into R (‘ape’ package). I downloaded the latest 
versions.

The tree has many polytomies and that might be the problem.
It contains ten species and each species contains of a different number of 
individuals (those are the polytomies).
I attached it here.

I tried read.nexus

…and get: Error in trees[[i]] : subscript out of bounds

I tried read.tree #using a newick format for the tree)

…and get: Error in if (tp[3] != ) obj$node.label - tp[3] :

  missing value where TRUE/FALSE needed

I came across a “Robust Newick tree reader” by Liam Revell and tied the code he 
provides (http://www.phytools.org/read.newick/v0.5/read.newick.R) but I can’t 
make it work.


Can somebody get the tree into R?

Please let me know if you know what’s wrong

Thanks a lot

Anna


* * * * * * * * * * *
University of Cape Town
Animal Evolution and Systematics Group
Department of Biological Sciences
Room 3.32
Tel: +27 (0)21 6502405tel:%2B27%20%280%2921%206502405
Fax: +27 (0)21 6502718tel:%2B27%20%280%2921%206502718


UNIVERSITY OF CAPE TOWN

This e-mail is subject to the UCT ICT policies and e-mail disclaimer published 
on our website at http://www.uct.ac.za/about/policies/emaildisclaimer/ or 
obtainable from +27 21 650 9111tel:%2B27%2021%20650%209111. This e-mail is 
intended only for the person(s) to whom it is addressed. If the e-mail has 
reached you in error, please notify the author. If you are not the intended 
recipient of the e-mail you may not use, disclose, copy, redirect or print the 
content. If this e-mail is not related to the business of UCT it is sent by the 
sender in the sender's individual capacity.

___
R-sig-phylo mailing list - 
R-sig-phylo@r-project.orgmailto: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/


[[alternative HTML version deleted]]

___
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] Can't load a tree with multitomies into 'ape'

2014-08-15 Thread Anna Bastian
Hi Liam,

Thanks for explaining what is wrong with the format of the newick tree file.
I will work in understanding and re-writing the tree with the correct 
formatting.

Your script worked fine and the tree is finally in R!

Thanks a lot. I appreciate your help

Regards,
Anna



-Original Message-
From: Liam J. Revell [mailto:liam.rev...@umb.edu]
Sent: Freitag, 15. August 2014 16:48
To: Anna Bastian; r-sig-phylo@r-project.org
Subject: Re: [R-sig-phylo] Can't load a tree with multitomies into 'ape'

Hi Anna.

Your attached file with extension .nwk is also a Nexus style file so it cannot 
be read with read.tree or read.newick. read.tree and read.newick read a simple 
Newick style text string, or a set of such strings on separate lines in a file.

It looks like the problem with your Nexus file, extension .nex, is that there 
are line breaks or spaces within the Newick string. The problem with your Nexus 
file of extension .nwk is probably the figtree block (although this is just a 
guess).

Try this:

obj-readLines(IndTree.nwk)
ii-grep(tree_1,obj)
x-strsplit(obj[ii], )[[1]]
tree-read.tree(text=x[length(x)])

All the best, Liam

Liam J. Revell, Assistant Professor of Biology University of Massachusetts 
Boston
web: http://faculty.umb.edu/liam.revell/
email: liam.rev...@umb.edu
blog: http://blog.phytools.org

On 8/15/2014 9:56 AM, Anna Bastian wrote:
 Dear list members,

 I am trying to read a tree into R ('ape' package). I downloaded the
 latest versions.

 The tree has many polytomies and that might be the problem.

 It contains ten species and each species contains of a different
 number of individuals (those are the polytomies).

 I attached it here.

 I tried read.nexus

 ...and get:Error in trees[[i]] : subscript out of bounds

 I tried read.tree #using a newick format for the tree)

 ...and get:Error in if (tp[3] != ) obj$node.label - tp[3] :

missing value where TRUE/FALSE needed

 I came across a Robust Newick tree reader by Liam Revell and tied
 the code he provides
 (http://www.phytools.org/read.newick/v0.5/read.newick.R) but I can't
 make it work.

 Can somebody get the tree into R?

 Please let me know if you know what's wrong

 Thanks a lot

 Anna

 **

 ** * * * * * * * * * * *

 **

 *University of Cape Town*
 /Animal Evolution and Systematics Group/

 Department of Biological Sciences
 Room 3.32

 Tel: +27 (0)21 6502405

 Fax: +27 (0)21 6502718

 --
 --
 UNIVERSITY OF CAPE TOWN

 This e-mail is subject to the UCT ICT policies and e-mail disclaimer
 published on our website at
 http://www.uct.ac.za/about/policies/emaildisclaimer/ or obtainable
 from
 +27 21 650 9111. This e-mail is intended only for the person(s) to
 +whom
 it is addressed. If the e-mail has reached you in error, please notify
 the author. If you are not the intended recipient of the e-mail you
 may not use, disclose, copy, redirect or print the content. If this
 e-mail is not related to the business of UCT it is sent by the sender
 in the sender's individual capacity.




 ___
 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/



 UNIVERSITY OF CAPE TOWN

This e-mail is subject to the UCT ICT policies and e-mai...{{dropped:9}}

___
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/