gheatmap fails in complex tree

831 views
Skip to first unread message

chin...@qq.com

unread,
Oct 23, 2017, 5:43:06 AM10/23/17
to ggtree


I have a phylogenetic tree with a lot of tips. When I want to annotate some traits to the tree using gheatmap, I find it presents nothing. As I struggled to catch the bug, I found it's because gheatmap makes wrong in case of many tips. The pictures above shows how the window height influences the result using gheatmap and ggtree. In the attach file, I uploaded the tree I tested. Other tested data was produced via:


rnorm(397)->test

data.frame(test=test)->test

phylotre$tip.label->rownames(test)

gheatmap(ggtree(phylotre),test)


Thanks in advance.


Loojuen,

10.23

AOA.tre

Yu, Guangchuang

unread,
Oct 23, 2017, 5:49:02 AM10/23/17
to chin...@qq.com, ggtree

the tree you attached is not that large, only has 397 tips and of course ggtree can handle it well. please follow the guide, https://guangchuangyu.github.io/2016/07/how-to-bug-author/, before posting your question.


--
G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data, Methods in Ecology and Evolution, 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
 
Homepage: https://guangchuangyu.github.io/ggtree
---
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree+unsubscribe@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/999c8261-6a06-46c3-b595-02b350d37768%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
--~--~---------~--~----~------------~-------~--~----~
Guangchuang Yu, Postdoc researcher
State Key Laboratory of Emerging Infectious Diseases
School of Public Health
The University of Hong Kong
Hong Kong SAR, China
-~----------~----~----~----~------~----~------~--~---

chin...@qq.com

unread,
Oct 23, 2017, 5:55:38 AM10/23/17
to ggtree
No, I don't think so. Look at the first picture, the gheatmap has produced nothing, and for second picture, it produced a wrong graph.

在 2017年10月23日星期一 UTC+8下午5:43:06,chin...@qq.com写道:

chin...@qq.com

unread,
Oct 23, 2017, 7:23:07 AM10/23/17
to ggtree
Maybe you are right, but would you kindly point out if there anything else I can provide?

Maybe you mean the package version?

> sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936 
[2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936   
[3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
[4] LC_NUMERIC=C                                                   
[5] LC_TIME=Chinese (Simplified)_People's Republic of China.936    

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

other attached packages:
[1] ggtree_1.8.2  treeio_1.0.2  ggplot2_2.2.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.13     bindr_0.1        magrittr_1.5     tidyselect_0.2.1
 [5] munsell_0.4.3    colorspace_1.3-2 ape_4.1          lattice_0.20-35 
 [9] R6_2.2.2         rlang_0.1.2      plyr_1.8.4       dplyr_0.7.4     
[13] parallel_3.4.2   grid_3.4.2       gtable_0.2.0     nlme_3.1-131    
[17] digest_0.6.12    lazyeval_0.2.0   assertthat_0.2.0 tibble_1.3.4    
[21] bindrcpp_0.2     purrr_0.2.3      tidyr_0.7.1      glue_1.1.1      
[25] labeling_0.3     compiler_3.4.2   rvcheck_0.0.9    scales_0.5.0    
[29] jsonlite_1.5     pkgconfig_2.0.1 

And I have already searched everywhere everything about gheatmap, but I still haven't found a topic about how the gheatmap turned blank.

Or do you mean reproducible example? Here I just use example post on https://www.bioconductor.org/packages/devel/bioc/vignettes/ggtree/inst/doc/advanceTreeAnnotation.html to illustrate:

beast_file <- system.file("examples/MCC_FluA_H3.tree", package="ggtree")
beast_tree <- read.beast(beast_file)

genotype_file <- system.file("examples/Genotype.txt", package="ggtree")
genotype <- read.table(genotype_file, sep="\t", stringsAsFactor=F)
colnames(genotype) <- sub("\\.$", "", colnames(genotype))
p <- ggtree(beast_tree, mrsd="2013-01-01") + geom_treescale(x=2008, y=1, offset=2)
p <- p + geom_tiplab(size=2)
gheatmap(p, genotype, offset = 5, width=0.5, font.size=3, colnames_angle=-45, hjust=0) +
    scale_fill_manual(breaks=c("HuH3N2", "pdm", "trig"), values=c("steelblue", "firebrick", "darkgreen"))

And if I narrow down the window, gheatmap just disappears (while the tree was scaled well):

If I still make it unclear, please let me know.

在 2017年10月23日星期一 UTC+8下午5:43:06,chin...@qq.com写道:

Guangchuang Yu

unread,
Oct 23, 2017, 7:41:01 AM10/23/17
to chin...@qq.com, ggtree
if you do follow the guide, you are supposed to present a reproducible example.

DO NOT JUST SAY: NO IT DIDN'T WORK.

For the example presented in vignette, it didn't disappear on your plot. It is due to the tip label plotted above the heatmap. You can still see some colors on the figure.




--~--~---------~--~----~------------~-------~--~----~
Guangchuang Yu, PhD Candidate

State Key Laboratory of Emerging Infectious Diseases
School of Public Health
The University of Hong Kong
Hong Kong SAR, China
-~----------~----~----~----~------~----~------~--~---

--
G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data, Methods in Ecology and Evolution, 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
 
Homepage: https://guangchuangyu.github.io/ggtree
---
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree+unsubscribe@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.

chin...@qq.com

unread,
Oct 23, 2017, 8:03:36 AM10/23/17
to ggtree
Please try this tree in Newick format in the attach file. I can't make it show by any means.


在 2017年10月23日星期一 UTC+8下午5:43:06,chin...@qq.com写道:

16S.tre

Yu, Guangchuang

unread,
Oct 23, 2017, 8:29:31 AM10/23/17
to chin...@qq.com, ggtree
as you ignore my msg, I will ignore yours.

--
G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data, Methods in Ecology and Evolution, 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
 
Homepage: https://guangchuangyu.github.io/ggtree
---
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree+unsubscribe@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
--~--~---------~--~----~------------~-------~--~----~
Guangchuang Yu, Postdoc researcher

State Key Laboratory of Emerging Infectious Diseases
School of Public Health
The University of Hong Kong

chin...@qq.com

unread,
Oct 23, 2017, 9:13:57 AM10/23/17
to ggtree
Try this code ("tree" and "value" is in attach file):
library(ggtree)
dget("tree")->phylotre
dget("value")->annotation
gheatmap(ggtree(phylotre),annotation)

You will get:

The environment tested:

R version 3.4.2 (2017-09-28)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936 
[2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936   
[3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
[4] LC_NUMERIC=C                                                   
[5] LC_TIME=Chinese (Simplified)_People's Republic of China.936    

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

other attached packages:
[1] ggtree_1.8.2  treeio_1.0.2  ggplot2_2.2.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.13     bindr_0.1        magrittr_1.5     tidyselect_0.2.1
 [5] munsell_0.4.3    colorspace_1.3-2 ape_4.1          lattice_0.20-35 
 [9] R6_2.2.2         rlang_0.1.2      plyr_1.8.4       dplyr_0.7.4     
[13] parallel_3.4.2   grid_3.4.2       gtable_0.2.0     nlme_3.1-131    
[17] digest_0.6.12    lazyeval_0.2.0   assertthat_0.2.0 tibble_1.3.4    
[21] bindrcpp_0.2     purrr_0.2.3      tidyr_0.7.1      glue_1.1.1      
[25] labeling_0.3     compiler_3.4.2   rvcheck_0.0.9    scales_0.5.0    
[29] jsonlite_1.5     pkgconfig_2.0.1 


在 2017年10月23日星期一 UTC+8下午5:43:06,chin...@qq.com写道:

tree
value

chin...@qq.com

unread,
Oct 24, 2017, 1:15:34 AM10/24/17
to ggtree
I'm also bored to argue whether I have put a reproducible example at the FIRST BEGINNING or not. I notice you licensed the "ggtree" under Artistic-2.0, hence, I've modified it under the Original License.

To other users:
Since I have pointed out the bug was resulted from the borders of the heatmap (ie. geom_tile), I have modified the "gheatmap" function (in the attach file) to set "size=0" as well as rename the parameter "color" as "border_color" and it's now ready for microbiome analysis. 

In my fist example:
Using defualt gheatmap:

Using modified "gheatmap":

btw, the bug will only occur in case of more than 100 tips. For other occasion, use the default funtion is recommended.

Questions and comments can be sent to ChungL...@zju.edu.cn

Loojuen,
Oct 24, 2017




在 2017年10月23日星期一 UTC+8下午5:43:06,chin...@qq.com写道:

gheatmap.R

Yu, Guangchuang

unread,
Oct 24, 2017, 1:40:39 AM10/24/17
to chin...@qq.com, ggtree
On Tue, Oct 24, 2017 at 1:15 PM, <chin...@qq.com> wrote:
I'm also bored to argue whether I have put a reproducible example at the FIRST BEGINNING or not. I notice you licensed the "ggtree" under Artistic-2.0, hence, I've modified it under the Original License.



THE EXAMPLE IN YOUR FIRST POST WAS FINE. I MENTIONED THE TREE WITH 397 TAXA IS NOT BIG, THAT MEANS I DID TEST YOUR SCRIPT.


 
To other users:
Since I have pointed out the bug was resulted from the borders of the heatmap (ie. geom_tile), I have modified the "gheatmap" function (in the attach file) to set "size=0" as well as rename the parameter "color" as "border_color" and it's now ready for microbiome analysis. 

In my fist example:
Using defualt gheatmap:


YOUR PROBLEM IS `I find it presents nothing.`, AND IT IS NOT AS IT WAS DISPLAYED ABOVE. THAT'S WHY I ASKED YOU TO PROVIDE AN EXAMPLE.


THE ISSUE HERE IS THAT YOU CAN'T DESCRIBE YOUR PROBLEM ACCURATELY.


YOU JUST REPLIED `NO, I DIDN'T THING SO`, THAT WAS RUDE AND I CAN'T HELP AS I DON'T KNOW WHAT EXACTLY YOUR PROBLEM IS.


 
Using modified "gheatmap":

btw, the bug will only occur in case of more than 100 tips. For other occasion, use the default funtion is recommended.



THE BORDER COLOR IS TO MAKE THE HEATMAP MORE BEAUTIFUL WHEN THE SIZE IS SMALL.

FOR LARGE HEATMAP, YOU CAN JUST SIMPLY SET `color = NULL`.

KEEP CALM AND RTFM.
KEEP CALM AND SHOW RESPECT TO PEOPLE WHO MAY HELP YOU.
KEEP CALM AND REALIZE THAT NO ONE HAS RESPONSIBILITY TO HELP OTHERS.

Questions and comments can be sent to ChungL...@zju.edu.cn

Loojuen,
Oct 24, 2017




在 2017年10月23日星期一 UTC+8下午5:43:06,chin...@qq.com写道:


I have a phylogenetic tree with a lot of tips. When I want to annotate some traits to the tree using gheatmap, I find it presents nothing. As I struggled to catch the bug, I found it's because gheatmap makes wrong in case of many tips. The pictures above shows how the window height influences the result using gheatmap and ggtree. In the attach file, I uploaded the tree I tested. Other tested data was produced via:


rnorm(397)->test

data.frame(test=test)->test

phylotre$tip.label->rownames(test)

gheatmap(ggtree(phylotre),test)


Thanks in advance.


Loojuen,

10.23

--
G Yu, DK Smith, H Zhu, Y Guan, TTY Lam*. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data, Methods in Ecology and Evolution, 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
 
Homepage: https://guangchuangyu.github.io/ggtree
---
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree+unsubscribe@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

chin...@qq.com

unread,
Oct 24, 2017, 3:27:17 AM10/24/17
to ggtree
ggtree is a splendid project and of course it'll facing challenges cross disciplines. I think this idea attractive and then I use it instead of iTOL or other method. 

在 2017年10月24日星期二 UTC+8下午1:40:39,Yu, Guangchuang写道:


To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree...@googlegroups.com.

To post to this group, send email to bioc-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages