Browse code

set_hilight_legend

guangchuang yu authored on 30/08/2017 06:34:31
Showing 8 changed files

... ...
@@ -87,6 +87,7 @@ export(rotate_tree)
87 87
 export(scaleClade)
88 88
 export(scale_color)
89 89
 export(scale_x_ggtree)
90
+export(set_hilight_legend)
90 91
 export(stat_balance)
91 92
 export(stat_hilight)
92 93
 export(subview)
... ...
@@ -1,5 +1,6 @@
1 1
 CHANGES IN VERSION 1.9.4
2 2
 ------------------------
3
+ o set_hilight_legend <2017-08-30, Wed>
3 4
  o geom_motif for aligned motif <2017-08-22, Tue>
4 5
    + https://github.com/GuangchuangYu/ggtree/issues/148
5 6
  o fixed `R CMD build` error: cannot stat 'ggtree/site_src/themes': No such file or directory <2017-08-22, Tue>
... ...
@@ -260,4 +260,18 @@ coplot <- function(tree1, tree2, hjust=0) {
260 260
 
261 261
 
262 262
 
263
-
263
+##' set legend for multiple geom_hilight layers
264
+##'
265
+##'
266
+##' @title set_hilight_legend
267
+##' @param p ggtree object
268
+##' @param color color vector
269
+##' @param label label vector
270
+##' @return updated ggtree object
271
+##' @export
272
+##' @author guangchuang yu
273
+set_hilight_legend <- function(p, color, label) {
274
+	d <- data.frame(color=color, clade=label, x=0, y=1)
275
+	p <- p + geom_rect(aes_(fill=~clade, xmin=~x, xmax=~x, ymin=~y, ymax=~y), data=d, inherit.aes=F) +
276
+		guides(fill=guide_legend(override.aes=list(fill=d$color)))
277
+}
... ...
@@ -4,9 +4,9 @@ ggtree: an R package for visualization and annotation of phylogenetic trees with
4 4
 
5 5
 <img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/ggtree/ggtree.png" height="200" align="right" />
6 6
 
7
-[![releaseVersion](https://img.shields.io/badge/release%20version-1.8.2-green.svg?style=flat)](https://bioconductor.org/packages/ggtree) [![develVersion](https://img.shields.io/badge/devel%20version-1.9.4-green.svg?style=flat)](https://github.com/guangchuangyu/ggtree) [![Bioc](http://www.bioconductor.org/shields/years-in-bioc/ggtree.svg)](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#since) [![total](https://img.shields.io/badge/downloads-18100/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) [![month](https://img.shields.io/badge/downloads-834/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
7
+[![releaseVersion](https://img.shields.io/badge/release%20version-1.8.2-green.svg?style=flat)](https://bioconductor.org/packages/ggtree) [![develVersion](https://img.shields.io/badge/devel%20version-1.9.4-green.svg?style=flat)](https://github.com/guangchuangyu/ggtree) [![Bioc](http://www.bioconductor.org/shields/years-in-bioc/ggtree.svg)](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#since) [![total](https://img.shields.io/badge/downloads-18441/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) [![month](https://img.shields.io/badge/downloads-834/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
8 8
 
9
-[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![codecov](https://codecov.io/gh/GuangchuangYu/ggtree/branch/master/graph/badge.svg)](https://codecov.io/gh/GuangchuangYu/ggtree) [![Last-changedate](https://img.shields.io/badge/last%20change-2017--08--22-green.svg)](https://github.com/GuangchuangYu/ggtree/commits/master) [![GitHub forks](https://img.shields.io/github/forks/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/network) [![GitHub stars](https://img.shields.io/github/stars/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/stargazers) [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://awesome-r.com/#awesome-r-graphic-displays)
9
+[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) [![codecov](https://codecov.io/gh/GuangchuangYu/ggtree/branch/master/graph/badge.svg)](https://codecov.io/gh/GuangchuangYu/ggtree) [![Last-changedate](https://img.shields.io/badge/last%20change-2017--08--30-green.svg)](https://github.com/GuangchuangYu/ggtree/commits/master) [![GitHub forks](https://img.shields.io/github/forks/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/network) [![GitHub stars](https://img.shields.io/github/stars/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/stargazers) [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://awesome-r.com/#awesome-r-graphic-displays)
10 10
 
11 11
 [![platform](http://www.bioconductor.org/shields/availability/devel/ggtree.svg)](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#archives) [![Build Status](http://www.bioconductor.org/shields/build/devel/bioc/ggtree.svg)](https://bioconductor.org/checkResults/devel/bioc-LATEST/ggtree/) [![Linux/Mac Travis Build Status](https://img.shields.io/travis/GuangchuangYu/ggtree/master.svg?label=Mac%20OSX%20%26%20Linux)](https://travis-ci.org/GuangchuangYu/ggtree) [![AppVeyor Build Status](https://img.shields.io/appveyor/ci/Guangchuangyu/ggtree/master.svg?label=Windows)](https://ci.appveyor.com/project/GuangchuangYu/ggtree) [![Backers on Open Collective](https://opencollective.com/ggtree/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/ggtree/sponsors/badge.svg)](#sponsors)
12 12
 
... ...
@@ -27,7 +27,7 @@ Please cite the following article when using `ggtree`:
27 27
 
28 28
 **G Yu**, DK Smith, H Zhu, Y Guan, TTY Lam<sup>\*</sup>. 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.
29 29
 
30
-[![doi](https://img.shields.io/badge/doi-10.1111/2041--210X.12628-green.svg?style=flat)](http://dx.doi.org/10.1111/2041-210X.12628) [![Altmetric](https://img.shields.io/badge/Altmetric-346-green.svg?style=flat)](https://www.altmetric.com/details/10533079) [![citation](https://img.shields.io/badge/cited%20by-34-green.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627)
30
+[![doi](https://img.shields.io/badge/doi-10.1111/2041--210X.12628-green.svg?style=flat)](http://dx.doi.org/10.1111/2041-210X.12628) [![Altmetric](https://img.shields.io/badge/Altmetric-346-green.svg?style=flat)](https://www.altmetric.com/details/10533079) [![citation](https://img.shields.io/badge/cited%20by-35-green.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627)
31 31
 
32 32
 ------------------------------------------------------------------------
33 33
 
... ...
@@ -37,7 +37,7 @@ Please cite the following article when using `ggtree`:
37 37
 
38 38
 ### Download stats
39 39
 
40
-[![download](http://www.bioconductor.org/shields/downloads/ggtree.svg)](https://bioconductor.org/packages/stats/bioc/ggtree) [![total](https://img.shields.io/badge/downloads-18100/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) [![month](https://img.shields.io/badge/downloads-834/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
40
+[![download](http://www.bioconductor.org/shields/downloads/ggtree.svg)](https://bioconductor.org/packages/stats/bioc/ggtree) [![total](https://img.shields.io/badge/downloads-18441/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) [![month](https://img.shields.io/badge/downloads-834/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
41 41
 
42 42
 <img src="docs/images/dlstats.png" width="890"/>
43 43
 
44 44
Binary files a/docs/images/citation.png and b/docs/images/citation.png differ
... ...
@@ -345,7 +345,7 @@
345 345
 
346 346
 				<p><link rel="stylesheet" href="https://guangchuangyu.github.io/css/font-awesome.min.css"> <link rel="stylesheet" href="https://guangchuangyu.github.io/css/academicons.min.css"></p>
347 347
 <p><img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/ggtree/ggtree.png" height="200" align="right" /></p>
348
-<p><a href="https://bioconductor.org/packages/ggtree"><img src="https://img.shields.io/badge/release%20version-1.8.2-blue.svg?style=flat" alt="releaseVersion" /></a> <a href="https://github.com/guangchuangyu/ggtree"><img src="https://img.shields.io/badge/devel%20version-1.9.3-blue.svg?style=flat" alt="develVersion" /></a> <a href="https://bioconductor.org/packages/stats/bioc/ggtree"><img src="https://img.shields.io/badge/downloads-18100/total-blue.svg?style=flat" alt="total" /></a> <a href="https://bioconductor.org/packages/stats/bioc/ggtree"><img src="https://img.shields.io/badge/downloads-834/month-blue.svg?style=flat" alt="month" /></a></p>
348
+<p><a href="https://bioconductor.org/packages/ggtree"><img src="https://img.shields.io/badge/release%20version-1.8.2-blue.svg?style=flat" alt="releaseVersion" /></a> <a href="https://github.com/guangchuangyu/ggtree"><img src="https://img.shields.io/badge/devel%20version-1.9.4-blue.svg?style=flat" alt="develVersion" /></a> <a href="https://bioconductor.org/packages/stats/bioc/ggtree"><img src="https://img.shields.io/badge/downloads-18441/total-blue.svg?style=flat" alt="total" /></a> <a href="https://bioconductor.org/packages/stats/bioc/ggtree"><img src="https://img.shields.io/badge/downloads-834/month-blue.svg?style=flat" alt="month" /></a></p>
349 349
 <p>The <code>ggtree</code> package extending the <em>ggplot2</em> package. It based on grammar of graphics and takes all the good parts of <em>ggplot2</em>. <em>ggtree</em> is designed for not only viewing phylogenetic tree but also displaying annotation data on the tree. <em>ggtree</em> is released within the <a href="https://bioconductor.org/packages/ggtree/">Bioconductor</a> project and the source code is hosted on <a href="https://github.com/GuangchuangYu/ggtree"><i class="fa fa-github fa-lg"></i> GitHub</a>.</p>
350 350
 <div id="authors" class="section level2">
351 351
 <h2><i class="fa fa-user"></i> Authors</h2>
... ...
@@ -354,7 +354,7 @@
354 354
 <div id="citation" class="section level2">
355 355
 <h2><i class="fa fa-book"></i> Citation</h2>
356 356
 <p>Please cite the following article when using <code>ggtree</code>:</p>
357
-<p><a href="http://dx.doi.org/10.1111/2041-210X.12628"><img src="https://img.shields.io/badge/doi-10.1111/2041--210X.12628-blue.svg?style=flat" alt="doi" /></a> <a href="https://www.altmetric.com/details/10533079"><img src="https://img.shields.io/badge/Altmetric-346-blue.svg?style=flat" alt="Altmetric" /></a> <a href="https://scholar.google.com.hk/scholar?oi=bibs&amp;hl=en&amp;cites=7268358477862164627"><img src="https://img.shields.io/badge/cited%20by-34-blue.svg?style=flat" alt="citation" /></a></p>
357
+<p><a href="http://dx.doi.org/10.1111/2041-210X.12628"><img src="https://img.shields.io/badge/doi-10.1111/2041--210X.12628-blue.svg?style=flat" alt="doi" /></a> <a href="https://www.altmetric.com/details/10533079"><img src="https://img.shields.io/badge/Altmetric-346-blue.svg?style=flat" alt="Altmetric" /></a> <a href="https://scholar.google.com.hk/scholar?oi=bibs&amp;hl=en&amp;cites=7268358477862164627"><img src="https://img.shields.io/badge/cited%20by-35-blue.svg?style=flat" alt="citation" /></a></p>
358 358
 <p><strong>G Yu</strong>, DK Smith, H Zhu, Y Guan, TTY Lam<sup>*</sup>. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data. <strong><em>Methods in Ecology and Evolution</em></strong>. 2017, 8(1):28-36.</p>
359 359
 </div>
360 360
 <div id="featured-articles" class="section level2">
361 361
new file mode 100644
... ...
@@ -0,0 +1,24 @@
1
+% Generated by roxygen2: do not edit by hand
2
+% Please edit documentation in R/experimental_function.R
3
+\name{set_hilight_legend}
4
+\alias{set_hilight_legend}
5
+\title{set_hilight_legend}
6
+\usage{
7
+set_hilight_legend(p, color, label)
8
+}
9
+\arguments{
10
+\item{p}{ggtree object}
11
+
12
+\item{color}{color vector}
13
+
14
+\item{label}{label vector}
15
+}
16
+\value{
17
+updated ggtree object
18
+}
19
+\description{
20
+set legend for multiple geom_hilight layers
21
+}
22
+\author{
23
+guangchuang yu
24
+}
... ...
@@ -9,7 +9,7 @@ weight: 1
9 9
 
10 10
 <p><link rel="stylesheet" href="https://guangchuangyu.github.io/css/font-awesome.min.css"> <link rel="stylesheet" href="https://guangchuangyu.github.io/css/academicons.min.css"></p>
11 11
 <p><img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/ggtree/ggtree.png" height="200" align="right" /></p>
12
-<p><a href="https://bioconductor.org/packages/ggtree"><img src="https://img.shields.io/badge/release%20version-1.8.2-blue.svg?style=flat" alt="releaseVersion" /></a> <a href="https://github.com/guangchuangyu/ggtree"><img src="https://img.shields.io/badge/devel%20version-1.9.3-blue.svg?style=flat" alt="develVersion" /></a> <a href="https://bioconductor.org/packages/stats/bioc/ggtree"><img src="https://img.shields.io/badge/downloads-18100/total-blue.svg?style=flat" alt="total" /></a> <a href="https://bioconductor.org/packages/stats/bioc/ggtree"><img src="https://img.shields.io/badge/downloads-834/month-blue.svg?style=flat" alt="month" /></a></p>
12
+<p><a href="https://bioconductor.org/packages/ggtree"><img src="https://img.shields.io/badge/release%20version-1.8.2-blue.svg?style=flat" alt="releaseVersion" /></a> <a href="https://github.com/guangchuangyu/ggtree"><img src="https://img.shields.io/badge/devel%20version-1.9.4-blue.svg?style=flat" alt="develVersion" /></a> <a href="https://bioconductor.org/packages/stats/bioc/ggtree"><img src="https://img.shields.io/badge/downloads-18441/total-blue.svg?style=flat" alt="total" /></a> <a href="https://bioconductor.org/packages/stats/bioc/ggtree"><img src="https://img.shields.io/badge/downloads-834/month-blue.svg?style=flat" alt="month" /></a></p>
13 13
 <p>The <code>ggtree</code> package extending the <em>ggplot2</em> package. It based on grammar of graphics and takes all the good parts of <em>ggplot2</em>. <em>ggtree</em> is designed for not only viewing phylogenetic tree but also displaying annotation data on the tree. <em>ggtree</em> is released within the <a href="https://bioconductor.org/packages/ggtree/">Bioconductor</a> project and the source code is hosted on <a href="https://github.com/GuangchuangYu/ggtree"><i class="fa fa-github fa-lg"></i> GitHub</a>.</p>
14 14
 <div id="authors" class="section level2">
15 15
 <h2><i class="fa fa-user"></i> Authors</h2>
... ...
@@ -18,7 +18,7 @@ weight: 1
18 18
 <div id="citation" class="section level2">
19 19
 <h2><i class="fa fa-book"></i> Citation</h2>
20 20
 <p>Please cite the following article when using <code>ggtree</code>:</p>
21
-<p><a href="http://dx.doi.org/10.1111/2041-210X.12628"><img src="https://img.shields.io/badge/doi-10.1111/2041--210X.12628-blue.svg?style=flat" alt="doi" /></a> <a href="https://www.altmetric.com/details/10533079"><img src="https://img.shields.io/badge/Altmetric-346-blue.svg?style=flat" alt="Altmetric" /></a> <a href="https://scholar.google.com.hk/scholar?oi=bibs&amp;hl=en&amp;cites=7268358477862164627"><img src="https://img.shields.io/badge/cited%20by-34-blue.svg?style=flat" alt="citation" /></a></p>
21
+<p><a href="http://dx.doi.org/10.1111/2041-210X.12628"><img src="https://img.shields.io/badge/doi-10.1111/2041--210X.12628-blue.svg?style=flat" alt="doi" /></a> <a href="https://www.altmetric.com/details/10533079"><img src="https://img.shields.io/badge/Altmetric-346-blue.svg?style=flat" alt="Altmetric" /></a> <a href="https://scholar.google.com.hk/scholar?oi=bibs&amp;hl=en&amp;cites=7268358477862164627"><img src="https://img.shields.io/badge/cited%20by-35-blue.svg?style=flat" alt="citation" /></a></p>
22 22
 <p><strong>G Yu</strong>, DK Smith, H Zhu, Y Guan, TTY Lam<sup>*</sup>. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data. <strong><em>Methods in Ecology and Evolution</em></strong>. 2017, 8(1):28-36.</p>
23 23
 </div>
24 24
 <div id="featured-articles" class="section level2">