ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

Multiple trees are plotted by shape instead of label

Open richelbilderbeek opened this issue 6 years ago • 2 comments
trafficstars

Prerequisites

  • [x] Have you read Feedback and follow the guide?
    • [x] make sure your are using the latest release version
    • [x] read the documents
    • [x] google your quesion/issue

Describe you issue

  • [x] Make a reproducible example (e.g. 1)
  • [x] your code should contain comments to describe the problem (e.g. what expected and actually happened?)

Hi @GuangchuangYu, thanks for ggtree! There is some behavior that I think may be incorrect. I hope you can fix that, or my misunderstanding :+1:. Cheers, @richelbilderbeek

Here is the reprex:

library(ape)
library(ggplot2)

# Here I create two trees. In one tree, taxon 'C' is the outlier. In the other tree, taxon 'B' is the outlier
tree_1 <- ape::read.tree(text = "((A:2,B:2):1, C:3);")
tree_2 <- ape::read.tree(text = "((A:1,C:1):2, B:3);")

# Show it in a picture:
plot(tree_1)
plot(tree_2)

tree_1

tree_2

# Combine the trees
trees <- c(tree_1, tree_2)

# Show them overlapping
ggtree::ggtree(trees) + ggtree::geom_tiplab()

The tree created by ggtree shows that C is the outlier in both cases:

tree_created

This is a plot I would have expected, in which B and C are outliers each once:

tree_expected

Ask in right place

  • [x] for bugs or feature requests, post here (github issue)
  • [ ] for questions, please post to google group

richelbilderbeek avatar Jan 25 '19 10:01 richelbilderbeek

Yes, it is a bug. This bug was caused by supporting phyloseq object, we need to allow node duplications, see https://github.com/GuangchuangYu/ggtree/blob/master/R/method-fortify.R#L185.

So that I have a setup_tree_data function to keep non-duplicated one for drawing branches and labels, etc.

So, in your case, only tip labels of tree_1 were plotted.

If I fixed this bug, then I should remove the support of phyloseq.

I will think about it to figure out a better way. Don't hesitate to let me know, if you have ideas.

GuangchuangYu avatar Jan 25 '19 19:01 GuangchuangYu

It now works in my fork. See #222 . Though I think this functionality should be available in ggtree proper at some point.

brj1 avatar Jan 25 '19 20:01 brj1