ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Feature request: Density trees

Open jorgeamaya opened this issue 8 years ago • 3 comments
trafficstars

Hi! I'm trying to emulate DensiTree plots using ggtree. It is clear that ggtree can't generate trees like this at the moment: https://pbs.twimg.com/media/CNn5DgkWIAAQxmC.jpg .

I tried plotting all the trees at the same time but the outcome was a tree in which all the tips were aligned at different distances.

library(ape) library(ggtree) tree = read.tree("all_par.tree") #A file with many trees p <- ggtree(tree, layout="slanted", branch.length='none', color="lightblue", alpha=.3,) + geom_tiplab(cex=1) p

Could you try to implement this in the future? Thanks

jorgeamaya avatar Jun 19 '17 13:06 jorgeamaya

I've implemented a prototype for this in my fork: brj1/ggtree

You can make DensiTree like plots with my fork of ggtree with

library(ape)
library(ggtree)
tree = read.tree("all_par.tree") #A file with many trees
p <- ggdensitree(tree, layout="slanted", branch.length='none', color="lightblue", alpha=.3,) + geom_tiplab(cex=1)
p

EDIT: Upon @GuangchuangYu 's suggestion I have renamed ggmultitree to ggdensitree to avoid confusion with the multiPhylo class.

brj1 avatar Nov 14 '17 21:11 brj1

any progress and plan for PR @brj1 ?

GuangchuangYu avatar Aug 09 '19 08:08 GuangchuangYu

I don't think I have anything to add to ggdensitree. However, I have hesitated adding ggdensitree as a PR for several reasons:

  1. It cannot handle very many trees due to the time need to run (and R's transparency not working well for low values).
  2. It's functionality can probably be added to ggtree or geom_tree directly.

The main features that ggdensitree adds are the following:

  1. Can align tips (taxa) of multiple trees (vertically and horizontally)
  2. Can plot (and fortify) a list() of trees
  3. Can jitter placement the trees

To my knowledge multiPhylo objects are plotted with the roots aligned and the tips (taxa) ordered individually so that the tips at the same y values may not correspond to the same taxon in different trees. These were the main reasons why I wrote the ggdensitree function in the first place. Again, it may be better to just add this functionality into preexisting ggtree functions.

brj1 avatar Aug 09 '19 23:08 brj1