[Phylobase-devl] What I did with my summer vacation -- phylobase plotting

Thibaut Jombart jombart at biomserv.univ-lyon1.fr
Fri Aug 8 11:33:23 CEST 2008


Peter Cowan wrote:
> Hi all,
>
> Steve and I held a bit of a mini hackathon trying to wrap up some of
> the loose ends with my Google Summer of Code project, a new plotting
> interface.  The google thing ends has a hard deadline of the 18th.
> Before that time, I wanted to show the rest of the team where I am and
> see what bugs you could find or features that would be handy.  To get
> the code you'll need to install phylobase from the pdcgsoc branch,
> which is easily done by changing to the branch directory and running R
> CMD INSTALL pdcgsoc/
>
> Nearly all the code I've written can be found in the treePlot.R file.
> However there is only one end user interface, the treePlot() function.
>  Here are examples showing the some features already implemented.
>
> When running the examples, resize the plots to see some of the grid magic.
>
> I'm quite confident there will be bugs, particularly with edge cases,
> but I haven't found them yet, so please let me know if you have
> trees/parameter combinations that don't work.  I also haven't
> validated everything, I'm confident the node and tip labels show up at
> the right nodes, but less confident the data plot and edge coloring is
> proper, so don't be surprised if you find errors there -- please let
> me know if you do!
>
> Also suggestions for where this belongs in the package are welcome, do
> we want to keep the current default plotting methods, do they have
> function that can be rolled into the new commands?
>
> Cheers
>
> Peter
>
> data(geospiza)
>
> # for phylo4 objects
> treePlot(as(geospiza, 'phylo4'))
>
> # familiar -- yet rebuilt -- data default
> treePlot(geospiza)
> treePlot(geospiza, square = TRUE)
>
> # a different approach to data plotting
> # native grid plotting functions work quite well
> ff <- function(x) {grid.rect(); grid.points()}
> treePlot(geospiza, tip.plot.fun = ff)
>
> # this will require the gridBase package
> # there is an interface for base graphs, shown by the built in 'density' option
> treePlot(geospiza, tip.plot.fun = 'density')
>
> # fan style plotting
> treePlot(geospiza, type = 'fan')
>
> # tip and edge coloring
> treePlot(geospiza, plot.data = FALSE,
>     edge.color = rainbow(nrow(geospiza at edge)),
>     tip.color = c('red',  'black', 'blue'),
> )
>
> # non-ultrametric trees, note the extreme ability to resize this plot
> n <- 10
> tree1 <- as(rtree(n), 'phylo4')
> tree1 at tip.label <- replicate(n,
>                 paste(sample(LETTERS, sample(2:20, 1)), collapse = ""))
> treePlot(tree1)
> _______________________________________________
> Phylobase-devl mailing list
> Phylobase-devl at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/phylobase-devl
>
>
>   
Dear Peter,

What you've done looks great!

Here are a few comments or issues. It seems important to me to specify 
the size taken by the phylogeny (like the 'ratio' argument in former 
version). I am sure your function can implement that easily, but I did 
not find it from the arguments (I just looked at the arguments of 
treePlot). This would be especially valuable since some new 
functionalities for plotting data are awesome, but would require some 
more space (treePlot(geospiza, tip.plot.fun = 'density') is terrific!). 
BTW, it would be nice to have documentation for your new functions.

Playing with treePlot, I found some issues:
#### error
 > treePlot(geospiza, type="cladogram")
Error in xxyy$xx[phy at edge[, 2] <= Ntips] <- 1 : object "xxyy" not found


#### this one works, but data are not rotated
 > treePlot(geospiza, tip.plot.fun = ff, rot=90)

####
Argument show.tip.labels: it would be nice to have a vector of two 
logical, so that we could choose to represent tip.labels two times, 
once, or not at all (not at all is not possible currently).

####
Re-implementation of former plotting would require a legend for the 
symbols. Arguments for centring/scaling should be available, and I think 
data transformations should not be made inside phylobubbles.

#### edges
 > treePlot(geospiza,edge.color=c("blue","green","red"), edge.width=3)
works but I do not know if this is doing what is expected

####
Also, I am not sure what we can specify as a plotting function for 
argument 'tip.plot.fun'. My understanding is that it should be any 
function plotting a numeric vector.
I tried some without success:
 > treePlot(geospiza,show.tip=c(FALSE,FALSE),tip.plot.fun=plot)
Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

 > treePlot(geospiza,show.tip=c(FALSE,FALSE),tip.plot.fun=boxplot)
Error in plot.window(xlim = xlim, ylim = ylim, log = log, yaxs = 
pars$yaxs) :
need finite 'ylim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf

 > treePlot(geospiza,show.tip=c(FALSE,FALSE),tip.plot.fun=hist)
Error in hist.default(t(tdata(phy, which = "tip")[i, ])) :
invalid number of 'breaks'

Sorry if I am missing something (should plotting functions be 
grid-compatible? maybe these are not, I don't know).
Here is my sessionInfo():
 > sessionInfo()
R version 2.7.1 (2008-06-23)
i686-pc-linux-gnu

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] grid datasets utils stats graphics grDevices methods
[8] base

other attached packages:
[1] lattice_0.17-8 gridBase_0.4-3 phylobase_0.3 nlme_3.1-89 ape_2.2
[6] adegenet_1.2-1 ade4_1.4-9 MASS_7.2-42

loaded via a namespace (and not attached):
[1] tcltk_2.7.1 tools_2.7.1



I think that your new functions should replace the current one as soon 
as it does everything the previous did and adds new functionalities. 
Egocentrically, when replacement occurs, I would like the former version 
to be put in a branch, to that old version remains available. As a 
matter of fact, I currently use it for an article, and the code that 
will be provided will rely on the current 'stable' version. If this is a 
problem, I can of course juste store that locally and make it available 
elsewhere.

Best regards,

Thibaut.

-- 
######################################
Thibaut JOMBART
CNRS UMR 5558 - Laboratoire de Biométrie et Biologie Evolutive
Universite Lyon 1
43 bd du 11 novembre 1918
69622 Villeurbanne Cedex
Tél. : 04.72.43.29.35
Fax : 04.72.43.13.88
jombart at biomserv.univ-lyon1.fr
http://biomserv.univ-lyon1.fr/%7Ejombart/
http://adegenet.r-forge.r-project.org/


More information about the Phylobase-devl mailing list