I use the R programming language and environment frequently. Over the years, I have written various functions to analyze and display data, mostly related to phylogenetic comparative methods. In the hope that some of these might be of use to others, I will make an effort to post them here. Many have been inspired by other blog posts and various forums and I am sure there are more than one way to do the same thing.
This is an R package I am working on that simplifies the workflow of combining data sets from different sources that use different taxonomic nomenclature for amphibians, by using the list of synonyms of the Amphibian Species of the World database (http://research.amnh.org/vz/herpetology/amphibia/).
The most current version is available on GitHub. User Tutorial coming soon.
This function labels phylogenetic trees not with tip labels (e.g. species) but with clade names. Usually this would be genera, families or other higher level taxonomy but it could equally be used for geographic regions, morphotypes etc. After plotting a tree with the plot.phylo() function from the ape package, this function, with the input of a data frame with tip labels and the corresponding clade names, then adds coloured segments for each clade and the given clade labels. Pretty self explanatory and works with any of the 5 types of trees that ape can plot. This is what the results look like:
The function requires that the ape package is loaded. After plotting a tree without tip labels (show.tip.label = FALSE), run the cladelablR function like so:
> clade.labelR(tree,clades, seg.cols=seg.cols)
tree: phylo object
clades: data frame with two columns, the first with the tip labels of the tree (e.g. species) and the second which clade each tip belongs to
seg.cols: an object of class character, listing the colours to be used for the segment. e.g. seg.cols<-topo.colors(n=length(unique(clades$families)))
additional arguments include:
f.size: font size (same as cex)
lwd: weight of the segments marking the clades
download the example script I used to produce the above plots, including the tree and clade file and of course the function itself here.