Hi Liam and others,

read.nexus() can read NEXUS files that have no TRANSLATE block. There are two problems with this file: the extra spaces between "begin.../end" and the semicolon, and the linebreak between the tree declaration and the Newick string. So the following file can be read by read.nexus:

#NEXUS
begin trees;
tree tagged_tree = [&U] (A,(B,(C,D)60)100);
end;

Best,

Emmanuel

Le 29/08/2014 23:25, Liam J. Revell a écrit :
Hi Daniel.

I think the problem is actually that read.nexus expects a translation
table, and has nothing to do with the labels.

You could use this simplified reading function which does not permit a
translation table & uses phytools read.newick internally:

library(phytools)

readNexus<-function(file){
     obj<-readLines(file)
     obj<-strsplit(obj[grep("=",obj)]," ")
     obj<-sapply(obj,function(x) x[length(x)])
     if(length(obj)>1) trees<-read.newick(text=obj)
     else {
         trees<-lapply(obj,read.newick)
         class(trees)<-"multiPhylo"
     }
     trees
}

Let me know if this works.

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/29/2014 4:42 PM, Daniel Rafael Miranda-Esquivel wrote:
Dear all,

I tried to read a tree like this:

#NEXUS
begin trees ;
tree tagged_tree = [&U]
(A,(B,(C,D)60)100);

end ;

using read.nexus; while figtree reads it, ape refuses, telling that
there is an error:

Error in start:end : NA/NaN argument

I tried readNexus in phylobase, but there is a problem reading the
labels (in the real tree, not in this example), as the program
complains that a label is duplicated.


I will be grateful for any tip to solve this problem,


All the best,


Daniel

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


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

Reply via email to