0

I'm attempting to produce an ancestral reconstruction using the ape and phytools package in Rstudio. My problem is that in my phylogenetic tree the tip labels / species names are overcrowded and illegible. Currently, my tree has a dataset of 262 species.

An example nexus file of the data can be found here.

The Ancestral reconstruction tree I have produced so far is here: https://i.stack.imgur.com/y0oC7.png.

Each species has a character state of 0 or 1 and has node and tip labels addressing each state. Eventually i'd like to color the branches with their respective character state(which I have as either red or black.)

Ideally, I wish to produce a non-ultrametric tree similar to a previous question on stack overflow in this link here.

I've tried implementing the R code from this link for my own tree with little success.

Below is my code in R. I am still learning R and am unfamiliar with certain plotting methods and suspect that may be the issue here:

tree = read.nexus("test_nexus")
dichot_tree = multi2di(tree) 

dichot_tree$edge.length<-runif(n=nrow(dichot_tree$edge),min=0,max=1)

dichot_tree$edge.length[dichot_tree$edge.length<1]<-1
domest = read.nexus.data("test_nexus")    

aceDISCRETE<-ace(as.numeric(domest), dichot_tree, type="discrete")

plot(dichot_tree, cex=0.5, label.offset=1, no.margin=TRUE)
tiplabels(pch=22, bg=as.numeric(domest),cex=1, adj=1)
nodelabels(pie=aceDISCRETE$lik.anc, piecol=c("black", "red"), cex=0.25)    
Community
  • 1
  • 1
notesosa
  • 1
  • 2
  • Please create a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data. We don't have access to your "test_nexus" file so we can't run the code to see what it does. – MrFlick Jan 27 '15 at 19:58
  • I apologize. Here is a similar example [nexus file](http://pastebin.com/RMACBP1u) -The tree i'm trying to emulate has it's tip labels vertically aligned on the edge of the page using dots and can be seen here: http://i.stack.imgur.com/y31Bg.png. – notesosa Jan 27 '15 at 21:42
  • PROGRESS UPDATE: I've managed to get the tip labels vertical and to the left with grey spaced dots using Mr. Flicks brilliant code from the previous example! I still am unsure how it works, but i'll spend time braking it down later. Here's what I made: http://i.imgur.com/Oi186eJ.png The issue now is the overcrowded species labels – notesosa Jan 28 '15 at 02:01
  • Have you tried just making your plot taller? I'm not sure what else you want to do. You have an awful lot of labels. – MrFlick Jan 28 '15 at 02:53
  • Hi MrFlick, Effectively yes that is what I am looking to do, but I don't exactly now how to do it. I have been having issues with quark() on mac as well. Overall, I do not know how to make the plot taller or break the phylogeny into sections for visibility. – notesosa Jan 28 '15 at 16:55

1 Answers1

0

There are a couple possible ways to make the tip labels more readable. First, you could decrease the font size (that would be the cex parameter of the plot function). Second, you are using RStudio, and it looks like you currently have your plot area as a square. You can adjust the different panels to make the plot area a very tall rectangle, which would extend your tree when you plot it. Alternatively, you could create an external plot area (I use windows() and you can specify height and width.) Alternatively, when saving a plot in RStudio, you should be able to change the output height/width/aspect ratio. You should be able to make it much taller here as well.

William Gearty
  • 166
  • 1
  • 8