Hi Luigi,

Try:

zoom(tr, which(tr$tip.label %in% leaf$tip), ......

You may also store the numbers extracted by which():

sel <- which(tr$tip.label %in% leaf$tip)
zoom(tr, sel, ......

HTH

Cheers,

Emmanuel

Le 02/01/2015 10:26, Luigi Marongiu a écrit :
Dear Liam,
I writing the tree itself is not a problem (I actually use the Newick
format) but I can't really plot the tree with plot(tree) because it is
too large. I am using instead zoom() which requires the definition of
one or more subtrees.
I could neither write the all code to reconstruct the Newick file
directly on the message because it is too cumbersome nor I can attach
the file to the message because too large.
Anyway, the tree is saved in the file tr.tre (Newick format),  and
passed to the zoom function as follows:

# read tree
tr<-read.tree("tr.tre")
# set margins of the plot
par(mar = c(1, 1, 1, 1))
# plot tree
zoom(
     tr,
     3:62,
     subtree = TRUE,
     col = "grey",
     no.margin = TRUE,
     show.tip.label = TRUE,
     font = 1,
     cex = 0.3
     )

This argument works fine but the subtree is provided by the argument
3:62, which required a bit to try-n-error to find the proper tips to
highlight.
The point is that I have another file, sub.txt which contains the names
of the tips to highlight (this file contains two columns: the number of
rows and the name of the tips and whose name is "tips"). This should
give more control to the definition of the subtree.  The code I wrote is:

# read subtree
leaf<-read.table("sub.txt",header=T,row.names=1,sep="\t")
# read tree
tr<-read.tree("tr.tre")
# set margins of the plot
par(mar = c(1, 1, 1, 1))
# plot tree
zoom(
     tr,
     leaf$tip,    # or even just leaf
     subtree = TRUE,
     col = "grey",
     no.margin = TRUE,
     show.tip.label = TRUE,
     font = 1,
     cex = 0.3
     )

But this gives the error:

Warning message:
In Ops.factor(focus[[i]]) : - not meaningful for factors

and the zoom does not work because the main tree is plotted again in the
portion of the figure that should provide the zoom.
Is there a way to overcome this problem?
Regards
Luigi


On 01/01/15 22:03, Liam J. Revell wrote:
Hi Luigi.

Unfortunately, I think you may need to supply us with some more
details to try and figure out what your problem is.

Does your code look like:

D<-dist.dna(obj)
## obj is class "DNAbin", e.g.:
## data(woodmouse)
## obj<-woodmouse
tree<-upgma(D)
plot(tree) ## works
write.nexus(tree,file="filename.nex") ## does not work?

If so, I was able to get this to run on test datasets without a problem.

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 12/27/2014 6:57 PM, Luigi Marongiu wrote:
Dear Liam,
I ran in a similar problem as the one posed by Elaine, but when I used
the argument file = "filename.nex" I still obtained "Error in
y$tip.label : $ operator is invalid for atomic vectors".
To be clear I aligned the sequences using muscle(), created a distance
matrix using dist.dna(), computed the tree using upgma() and now I would
like to save the tree using nexus().
Any tip?
regards
Luigi

_______________________________________________
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