Yesterday (more accurately, early this morning), I posted about a new plotting method for plotting a backbone phylogeny with diversities for each subtree represented as a triangle. This type of visualization is quite common in the literature; however, I'm told (by Luke Mahler, so blame him if this is incorrect) that there is no such plotting method so far in R.
The way I did this was by first creating a new type of phylogeny object, of class "backbonePhylo". This object is stored in a very similar way to the typical phylogeny object in R (class "phylo"), which the exception that we have replaced the vector tip.label with the list tip.clade. tip.clade is a list in which each element contains a label, a diversity (i.e., the number of tips hidden in the subtree), and a crown depth.
I have written some of the methods around this object as S3 methods, which means they can be dispatched using (for instance) calls to the generic plot, reorder, print, etc.
This morning, I did a little more work on this suite of functions. Most importantly, I created a new function (phylo.toBackbone) that converts an object of class "phylo" to an object of class "backbonePhylo" with the help of a translation table. The translation table is a data frame with four variables: tip.label (containing the names of the tips in the input tree - these might be exemplar taxa); label (containing the names of the subtrees - these might be the names of higher taxa); N (obviously, the diversities of each subtree); and depth (the age of each crown group, in terms of the branch lengths of the input tree - note that this cannot be longer then the corresponding tip edge). Note that not all tips in the original tree need to be in the translation table. Those that are not will be treated as clades containing one taxon in the backbone tree.
Here's a demo using random subtree sizes on a stochastic backbone tree. New code for this is here.
> library(geiger) # to help us build our tree
> ## now let's create our backbone tree
> ## for old versions of geiger, use lambdaTree
> ## create a translation table
> ## leaving a couple of single-taxon clades for fun
> ## set crown node depth to 1/2 the maximum depth
> depth<-sapply(tip.label,function(x,y) 0.5*y$edge.length[which(tree$edge[,2]==which(y$tip.label== x))],y=tree)
> ## here's what trans looks like
tip.label clade.label N depth
1 t2 A 6 0.8992932
2 t4 B 5 0.7617329
3 t3 C 16 0.8674696
4 t5 D 9 0.5984337
5 t1 E 5 0.8992932
6 t10 F 7 0.5554955
7 t7 G 8 0.5664347
8 t9 H 7 0.5554955
> ## convert
> ## plot
That's pretty good.