Thursday, May 23, 2013

Plotting the structure of a circular ("fan") tree

Rafael Maia asks:

It would be really cool if simmap and densityMap trees could be plotted as radial (type='fan' in plot.phylo) trees. I find it much easier to visualize the patterns when the tree is quite large.

Indeed this would be quite cool. The first step is to figure out how to plot the structure of a circular tree. Here is my attempt at that. (Note, the function requires plotrix - not presently a phytools dependency.)

  if(!require(plotrix)) stop("install 'plotrix'")
  # reorder
  # count nodes and tips
  # get Y coordinates on uncurved space
  for(i in 1:m){
  # now put into a circular coordinate system
  # plot nodes
  # plot radial lines (edges)
  for(i in 1:nrow(cw$edge)) lines(x[i,],y[i,])
  # plot circular lines
  for(i in 1:m+n){

OK - now let's try it out:

> tree<-pbtree(n=30)
> plotTree(tree)
> source("plotFan.R")
> plotFan(tree)

Cool. Well, this is a good start!

1 comment:

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.