Monday, February 1, 2016

Standardization method for dotTree, and comparison of two different methods for visualizing quantitative character data at the tips of the tree

In the past few days I have posted two different visualization methods that can both be used to visualize continuous trait data for multiple characters across the tips of a tree. The first, phylo.heatmap, plots a multivariate 'heatmap' of trait values for multiple characters in a grid (e.g., 1, 2). The second, dotTree, shows one or multiple traits plotted on the tips of the tree using different sized circles or dots (e.g., 1, 2).

Tonight, I added the same standardization option that was already available in phylo.heatmap to dotTree. This update can be seen here. Having done this, I thought it might be interesting to visually compare the two methods, since they are effectively being used to represent the same data. Here is what that looks like:

library(phytools)
## Loading required package: ape
## Loading required package: maps
## 
##  # ATTENTION: maps v3.0 has an updated 'world' map.        #
##  # Many country borders and names have changed since 1990. #
##  # Type '?world' or 'news(package="maps")'. See README_v3. #
## simulate tree & data for 6 traits
tree<-rtree(n=26,tip.label=LETTERS)
X<-fastBM(tree,nsim=6)
## unstandardized
phylo.heatmap(tree,X)

plot of chunk unnamed-chunk-1

dotTree(tree,X,length=8) ## lengthen the legend

plot of chunk unnamed-chunk-1

## standardized
phylo.heatmap(tree,X,standardize=TRUE)

plot of chunk unnamed-chunk-1

dotTree(tree,X,standardize=TRUE,length=8)

plot of chunk unnamed-chunk-1

That's it.

5 comments:

  1. When characters are binary or multistate, the legend could change accordingly, instead of showing them as continuous.

    ReplyDelete
    Replies
    1. This is already done for one or multiple discrete characters: here. Let me know if you're having problems and how. If you have numerically coded your discrete traits then the function will treat them as numerical values, unless instructed otherwise.

      Delete
  2. Hi Liam,

    I just ran the code and I get this graph with dotTree:

    https://www.dropbox.com/s/0bltga5mfxd0ovl/dotTree.jpeg?dl=0

    Cheers

    ReplyDelete
  3. Replies
    1. Hola Marcelo.

      Yes, this is a known bug - but it is with plotrix, not phytools. To get it to work try installing a previous version of plotrix as follows:

      install.packages(
      "https://cran.r-project.org/src/contrib/Archive/plotrix/plotrix_3.6-1.tar.gz",
      type="source")

      Let me know if this works. - Liam

      Delete