Browse code

mrsd for treedata object

guangchuang yu authored on 15/11/2017 07:45:39
Showing6 changed files

... ...
@@ -2,7 +2,7 @@ Package: ggtree
2 2
 Type: Package
3 3
 Title: an R package for visualization and annotation of phylogenetic trees with
4 4
     their covariates and other associated data
5
-Version: 1.11.0
5
+Version: 1.11.1
6 6
 Authors@R: c(
7 7
 	   person("Guangchuang", "Yu",     email = "guangchuangyu@gmail.com", role = c("aut", "cre", "cph")),
8 8
 	   person("Tommy Tsan-Yuk", "Lam", email = "tylam.tommy@gmail.com",   role = c("aut", "ths")),
... ...
@@ -1,3 +1,9 @@
1
+CHANGES IN VERSION 1.11.1
2
+------------------------
3
+ o enable mrsd parameter for treedata object <2017-11-15, Wed>
4
+ o set_hilight_legend supports alpha parameter <2017-11-15, Wed>
5
+   + https://github.com/GuangchuangYu/ggtree/issues/149
6
+
1 7
 CHANGES IN VERSION 1.9.4
2 8
 ------------------------
3 9
  o geom_hilight_encircle and geom_cladelabel2 <2017-09-12, Tue>
... ...
@@ -267,11 +267,13 @@ coplot <- function(tree1, tree2, hjust=0) {
267 267
 ##' @param p ggtree object
268 268
 ##' @param color color vector
269 269
 ##' @param label label vector
270
+##' @param alpha transparency of color
270 271
 ##' @return updated ggtree object
271 272
 ##' @export
273
+##' @importFrom scales alpha
272 274
 ##' @author guangchuang yu
273
-set_hilight_legend <- function(p, color, label) {
274
-	d <- data.frame(color=color, clade=label, x=0, y=1)
275
+set_hilight_legend <- function(p, color, label, alpha=1) {
276
+	d <- data.frame(color=color, clade=label, x=0, y=1, alpha=alpha)
275 277
 	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)))
278
+		guides(fill=guide_legend(override.aes=list(fill=alpha(d$color, d$alpha))))
277 279
 }
... ...
@@ -3,7 +3,7 @@
3 3
 ##' @export
4 4
 fortify.treedata <- function(model, data, layout="rectangular", yscale="none",
5 5
                              ladderize=TRUE, right=FALSE, branch.length ="branch.length",
6
-                             mrsd=NULL, ...) {
6
+                             mrsd=NULL, as.Date = FALSE, ...) {
7 7
 
8 8
     model <- set_branch_length(model, branch.length)
9 9
 
... ...
@@ -30,6 +30,10 @@ fortify.treedata <- function(model, data, layout="rectangular", yscale="none",
30 30
     ## add branch mid position
31 31
     res <- calculate_branch_mid(res)
32 32
 
33
+    if (!is.null(mrsd)) {
34
+        res <- scaleX_by_time_from_mrsd(res, mrsd, as.Date)
35
+    }
36
+
33 37
     ## ## angle for all layout, if 'rectangular', user use coord_polar, can still use angle
34 38
     res <- calculate_angle(res)
35 39
     scaleY(as.phylo(model), res, yscale, layout, ...)
... ...
@@ -4,30 +4,63 @@ 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.10.0-green.svg?style=flat)](https://bioconductor.org/packages/ggtree) [![develVersion](https://img.shields.io/badge/devel%20version-1.11.0-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-21118/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) [![month](https://img.shields.io/badge/downloads-1156/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
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--11--14-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
-
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
-
13
-The `ggtree` package extending the `ggplot2` package. It based on grammar of graphics and takes all the good parts of `ggplot2`. `ggtree` is designed for not only viewing phylogenetic tree but also displaying annotation data on the tree.
7
+[![releaseVersion](https://img.shields.io/badge/release%20version-1.10.0-green.svg?style=flat)](https://bioconductor.org/packages/ggtree)
8
+[![develVersion](https://img.shields.io/badge/devel%20version-1.11.1-green.svg?style=flat)](https://github.com/guangchuangyu/ggtree)
9
+[![Bioc](http://www.bioconductor.org/shields/years-in-bioc/ggtree.svg)](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#since)
10
+[![total](https://img.shields.io/badge/downloads-21262/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
11
+[![month](https://img.shields.io/badge/downloads-1156/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
12
+
13
+[![Project Status: Active - The project has reached a stable, usable
14
+state and is being actively
15
+developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
16
+[![codecov](https://codecov.io/gh/GuangchuangYu/ggtree/branch/master/graph/badge.svg)](https://codecov.io/gh/GuangchuangYu/ggtree)
17
+[![Last-changedate](https://img.shields.io/badge/last%20change-2017--11--15-green.svg)](https://github.com/GuangchuangYu/ggtree/commits/master)
18
+[![GitHub
19
+forks](https://img.shields.io/github/forks/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/network)
20
+[![GitHub
21
+stars](https://img.shields.io/github/stars/GuangchuangYu/ggtree.svg)](https://github.com/GuangchuangYu/ggtree/stargazers)
22
+[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://awesome-r.com/#awesome-r-graphic-displays)
23
+
24
+[![platform](http://www.bioconductor.org/shields/availability/devel/ggtree.svg)](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#archives)
25
+[![Build
26
+Status](http://www.bioconductor.org/shields/build/devel/bioc/ggtree.svg)](https://bioconductor.org/checkResults/devel/bioc-LATEST/ggtree/)
27
+[![Linux/Mac Travis Build
28
+Status](https://img.shields.io/travis/GuangchuangYu/ggtree/master.svg?label=Mac%20OSX%20%26%20Linux)](https://travis-ci.org/GuangchuangYu/ggtree)
29
+[![AppVeyor Build
30
+Status](https://img.shields.io/appveyor/ci/Guangchuangyu/ggtree/master.svg?label=Windows)](https://ci.appveyor.com/project/GuangchuangYu/ggtree)
31
+[![Backers on Open
32
+Collective](https://opencollective.com/ggtree/backers/badge.svg)](#backers)
33
+[![Sponsors on Open
34
+Collective](https://opencollective.com/ggtree/sponsors/badge.svg)](#sponsors)
35
+
36
+The `ggtree` package extending the `ggplot2` package. It based on
37
+grammar of graphics and takes all the good parts of `ggplot2`. `ggtree`
38
+is designed for not only viewing phylogenetic tree but also displaying
39
+annotation data on the tree.
14 40
 
15 41
 [![Twitter](https://img.shields.io/twitter/url/https/github.com/GuangchuangYu/ggtree.svg?style=social)](https://twitter.com/intent/tweet?hashtags=ggtree&url=http://onlinelibrary.wiley.com/doi/10.1111/2041-210X.12628/abstract&screen_name=guangchuangyu)
16 42
 
17
-For details, please visit our project website, <https://guangchuangyu.github.io/ggtree>.
43
+For details, please visit our project website,
44
+<https://guangchuangyu.github.io/ggtree>.
18 45
 
19 46
 -   [Documentation](https://guangchuangyu.github.io/ggtree/documentation/)
20 47
 -   [FAQ](https://guangchuangyu.github.io/ggtree/faq/)
21
--   [Featured Articles](https://guangchuangyu.github.io/ggtree/featuredArticles/)
48
+-   [Featured
49
+    Articles](https://guangchuangyu.github.io/ggtree/featuredArticles/)
22 50
 -   [Feedback](https://guangchuangyu.github.io/ggtree/#feedback)
23 51
 
24 52
 ------------------------------------------------------------------------
25 53
 
26 54
 Please cite the following article when using `ggtree`:
27 55
 
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.
56
+**G Yu**, DK Smith, H Zhu, Y Guan, TTY Lam<sup>\*</sup>. ggtree: an R
57
+package for visualization and annotation of phylogenetic trees with
58
+their covariates and other associated data. ***Methods in Ecology and
59
+Evolution***. 2017, 8(1):28-36.
29 60
 
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-336-green.svg?style=flat)](https://www.altmetric.com/details/10533079) [![citation](https://img.shields.io/badge/cited%20by-47-green.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627)
61
+[![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)
62
+[![Altmetric](https://img.shields.io/badge/Altmetric-336-green.svg?style=flat)](https://www.altmetric.com/details/10533079)
63
+[![citation](https://img.shields.io/badge/cited%20by-47-green.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627)
31 64
 
32 65
 ------------------------------------------------------------------------
33 66
 
... ...
@@ -37,25 +70,41 @@ Please cite the following article when using `ggtree`:
37 70
 
38 71
 ### Download stats
39 72
 
40
-[![download](http://www.bioconductor.org/shields/downloads/ggtree.svg)](https://bioconductor.org/packages/stats/bioc/ggtree) [![total](https://img.shields.io/badge/downloads-21118/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) [![month](https://img.shields.io/badge/downloads-1156/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
73
+[![download](http://www.bioconductor.org/shields/downloads/ggtree.svg)](https://bioconductor.org/packages/stats/bioc/ggtree)
74
+[![total](https://img.shields.io/badge/downloads-21262/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
75
+[![month](https://img.shields.io/badge/downloads-1156/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
41 76
 
42 77
 <img src="docs/images/dlstats.png" width="890"/>
43 78
 
44 79
 Contributors
45 80
 ------------
46 81
 
47
-This project exists thanks to all the people who contribute. [\[Contribute\]](CONTRIBUTING.md). <a href="https://github.com/GuangchuangYu/ggtree/graphs/contributors"><img src="https://opencollective.com/ggtree/contributors.svg?width=890" /></a>
82
+This project exists thanks to all the people who contribute.
83
+[\[Contribute\]](CONTRIBUTING.md).
84
+<a href="https://github.com/GuangchuangYu/ggtree/graphs/contributors"><img src="https://opencollective.com/ggtree/contributors.svg?width=890" /></a>
48 85
 
49 86
 Backers
50 87
 -------
51 88
 
52
-Thank you to all our backers! 🙏 \[[Become a backer](https://opencollective.com/ggtree#backer)\]
89
+Thank you to all our backers! 🙏 \[[Become a
90
+backer](https://opencollective.com/ggtree#backer)\]
53 91
 
54 92
 <a href="https://opencollective.com/ggtree#backers" target="_blank"><img src="https://opencollective.com/ggtree/backers.svg?width=890"></a>
55 93
 
56 94
 Sponsors
57 95
 --------
58 96
 
59
-Support this project by becoming a sponsor. Your logo will show up here with a link to your website. \[[Become a sponsor](https://opencollective.com/ggtree#sponsor)\]
60
-
61
-<a href="https://opencollective.com/ggtree/sponsor/0/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/0/avatar.svg"></a> <a href="https://opencollective.com/ggtree/sponsor/1/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/1/avatar.svg"></a> <a href="https://opencollective.com/ggtree/sponsor/2/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/2/avatar.svg"></a> <a href="https://opencollective.com/ggtree/sponsor/3/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/3/avatar.svg"></a> <a href="https://opencollective.com/ggtree/sponsor/4/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/4/avatar.svg"></a> <a href="https://opencollective.com/ggtree/sponsor/5/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/5/avatar.svg"></a> <a href="https://opencollective.com/ggtree/sponsor/6/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/6/avatar.svg"></a> <a href="https://opencollective.com/ggtree/sponsor/7/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/7/avatar.svg"></a> <a href="https://opencollective.com/ggtree/sponsor/8/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/8/avatar.svg"></a> <a href="https://opencollective.com/ggtree/sponsor/9/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/9/avatar.svg"></a>
97
+Support this project by becoming a sponsor. Your logo will show up here
98
+with a link to your website. \[[Become a
99
+sponsor](https://opencollective.com/ggtree#sponsor)\]
100
+
101
+<a href="https://opencollective.com/ggtree/sponsor/0/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/0/avatar.svg"></a>
102
+<a href="https://opencollective.com/ggtree/sponsor/1/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/1/avatar.svg"></a>
103
+<a href="https://opencollective.com/ggtree/sponsor/2/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/2/avatar.svg"></a>
104
+<a href="https://opencollective.com/ggtree/sponsor/3/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/3/avatar.svg"></a>
105
+<a href="https://opencollective.com/ggtree/sponsor/4/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/4/avatar.svg"></a>
106
+<a href="https://opencollective.com/ggtree/sponsor/5/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/5/avatar.svg"></a>
107
+<a href="https://opencollective.com/ggtree/sponsor/6/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/6/avatar.svg"></a>
108
+<a href="https://opencollective.com/ggtree/sponsor/7/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/7/avatar.svg"></a>
109
+<a href="https://opencollective.com/ggtree/sponsor/8/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/8/avatar.svg"></a>
110
+<a href="https://opencollective.com/ggtree/sponsor/9/website" target="_blank"><img src="https://opencollective.com/ggtree/sponsor/9/avatar.svg"></a>
... ...
@@ -4,7 +4,7 @@
4 4
 \alias{set_hilight_legend}
5 5
 \title{set_hilight_legend}
6 6
 \usage{
7
-set_hilight_legend(p, color, label)
7
+set_hilight_legend(p, color, label, alpha = 1)
8 8
 }
9 9
 \arguments{
10 10
 \item{p}{ggtree object}
... ...
@@ -12,6 +12,8 @@ set_hilight_legend(p, color, label)
12 12
 \item{color}{color vector}
13 13
 
14 14
 \item{label}{label vector}
15
+
16
+\item{alpha}{transparency of color}
15 17
 }
16 18
 \value{
17 19
 updated ggtree object