简体   繁体   中英

Link tip labels to phylogenetic tree using dots and fix overcrowded tip labels

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: http://i.imgur.com/WFoEu7S.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)    

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM