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: [email protected]
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 - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/


_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/

Reply via email to