Browse code

fixed aes mapping in geom_strip <2016-10-11, Tue>

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@122185 bc3139a8-67e5-0310-9ffc-ced21a209358

Guangchuang Yu authored on 11/10/2016 06:41:39
Showing 5 changed files

... ...
@@ -1,8 +1,9 @@
1 1
 CHANGES IN VERSION 1.5.16
2 2
 ------------------------
3
+ o fixed aes mapping in geom_strip <2016-10-11, Tue>
3 4
  o fixed R check <2016-10-10, Mon>
4 5
    + check.aes parameter is not available in release version of ggplot2 yet
5
- 
6
+
6 7
 CHANGES IN VERSION 1.5.15
7 8
 ------------------------
8 9
  o check.aes for layers defined in ggtree <2016-10-07, Fri>
... ...
@@ -1,6 +1,6 @@
1 1
 ##' bar of range (HPD, range etc) to present uncertainty of evolutionary inference
2 2
 ##'
3
-##' 
3
+##'
4 4
 ##' @title geom_range
5 5
 ##' @param range range, e.g. "height_0.95_HPD"
6 6
 ##' @param ... additional parameter, e.g. color, size, alpha
... ...
@@ -12,12 +12,12 @@ geom_range <- function(range="height_0.95_HPD", ...) {
12 12
     position = "identity"
13 13
     show.legend = NA
14 14
     na.rm = TRUE
15
-    inherit.aes = FALSE    
15
+    inherit.aes = FALSE
16 16
 
17 17
     default_aes <- aes_(x=~x, y=~y, xend=~x, yend=~y)
18
-    
18
+
19 19
     mapping <- modifyList(default_aes, aes_string(branch.length="branch.length", label=range))
20
-        
20
+
21 21
     layer(
22 22
         stat = StatRange,
23 23
         mapping = mapping,
... ...
@@ -26,15 +26,16 @@ geom_range <- function(range="height_0.95_HPD", ...) {
26 26
         position = position,
27 27
         show.legend=show.legend,
28 28
         inherit.aes = inherit.aes,
29
-        params = list(na.rm = na.rm, ...)
29
+        params = list(na.rm = na.rm, ...),
30
+        if (packageVersion('ggplot2') > '2.1.0') check.aes = FALSE
30 31
     )
31
-    
32
+
32 33
 }
33 34
 
34 35
 StatRange <- ggproto("StatRange", Stat,
35 36
                      compute_group = function(self, data, scales, params) {
36 37
                          ## label is actually the range
37
-                         
38
+
38 39
                          df <- data[!is.na(data[,"label"]),]
39 40
                          rr <- gsub("\\[", "", df[,"label"])
40 41
                          rr <- gsub("\\]", "", rr)
... ...
@@ -1,6 +1,6 @@
1 1
 ##' annotate associated taxa (from taxa1 to taxa2, can be Monophyletic, Polyphyletic or Paraphyletc Taxa) with bar and (optional) text label
2 2
 ##'
3
-##' 
3
+##'
4 4
 ##' @title geom_strip
5 5
 ##' @param taxa1 taxa1
6 6
 ##' @param taxa2 taxa2
... ...
@@ -34,14 +34,14 @@ geom_strip <- function(taxa1, taxa2, label=NA, offset=0, offset.text=0,
34 34
 
35 35
     layer_bar <- stat_stripBar(taxa1=taxa1, taxa2=taxa2, label=label, offset=offset, align=align,
36 36
                                size=barsize, barextend=barextend,
37
-                               mapping=mapping, data=data, 
37
+                               mapping=mapping, data=data,
38 38
                                position=position, show.legend = show.legend,
39 39
                                inherit.aes = inherit.aes, na.rm=na.rm, ...)
40 40
 
41 41
     if (is.na(label) || is.null(label)) {
42 42
         return(layer_bar)
43 43
     }
44
-    
44
+
45 45
     if (geom == "text") {
46 46
         ## no fill parameter
47 47
         layer_text <- stat_stripText(taxa1=taxa1, taxa2=taxa2, label=label, offset=offset+offset.text,
... ...
@@ -49,7 +49,7 @@ geom_strip <- function(taxa1, taxa2, label=NA, offset=0, offset.text=0,
49 49
                                     mapping=mapping, data=data, geom=geom, hjust=hjust,
50 50
                                     position=position, show.legend = show.legend,
51 51
                                     inherit.aes = inherit.aes, na.rm=na.rm, parse=parse, ...)
52
-        
52
+
53 53
     } else {
54 54
         layer_text <- stat_stripText(taxa1=taxa1, taxa2=taxa2, label=label, offset=offset+offset.text,
55 55
                                     align=align, size=fontsize, barextend=barextend, angle=angle, fill=fill,family=family,
... ...
@@ -57,7 +57,7 @@ geom_strip <- function(taxa1, taxa2, label=NA, offset=0, offset.text=0,
57 57
                                     position=position, show.legend = show.legend,
58 58
                                     inherit.aes = inherit.aes, na.rm=na.rm, parse=parse, ...)
59 59
     }
60
-    
60
+
61 61
     list(
62 62
         layer_bar,
63 63
         layer_text
... ...
@@ -75,13 +75,13 @@ stat_stripText <- function(mapping=NULL, data=NULL,
75 75
     } else {
76 76
         default_aes <- aes_(x=~x, y=~y, node=~node)
77 77
     }
78
-    
78
+
79 79
     if (is.null(mapping)) {
80 80
         mapping <- default_aes
81 81
     } else {
82 82
         mapping <- modifyList(mapping, default_aes)
83 83
     }
84
-    
84
+
85 85
     layer(stat=StatStripText,
86 86
           data=data,
87 87
           mapping=mapping,
... ...
@@ -100,7 +100,7 @@ stat_stripText <- function(mapping=NULL, data=NULL,
100 100
                       ...),
101 101
           if (packageVersion('ggplot2') > '2.1.0') check.aes = FALSE
102 102
           )
103
-    
103
+
104 104
 }
105 105
 
106 106
 stat_stripBar <- function(mapping=NULL, data=NULL,
... ...
@@ -111,7 +111,7 @@ stat_stripBar <- function(mapping=NULL, data=NULL,
111 111
     if (is.null(label) || is.na(label)) {
112 112
         default_aes <- aes_(x=~x, y=~y, node=~node, label=~label, xend=~x, yend=~y)
113 113
     } else {
114
-        default_aes <- aes_(x=~x, y=~y, node=~node)
114
+        default_aes <- aes_(x=~x, y=~y, node=~node, xend=~x, yend=~y)
115 115
     }
116 116
 
117 117
     if (is.null(mapping)) {
... ...
@@ -119,7 +119,7 @@ stat_stripBar <- function(mapping=NULL, data=NULL,
119 119
     } else {
120 120
         mapping <- modifyList(mapping, default_aes)
121 121
     }
122
-    
122
+
123 123
     layer(stat=StatStripBar,
124 124
           data=data,
125 125
           mapping=mapping,
... ...
@@ -150,8 +150,8 @@ StatStripText <- ggproto("StatStripText", Stat,
150 150
                          required_aes = c("x", "y", "label")
151 151
                          )
152 152
 
153
-                         
154
-                          
153
+
154
+
155 155
 StatStripBar <- ggproto("StatStripBar", Stat,
156 156
                         compute_group = function(self, data, scales, params,
157 157
                                                  taxa1, taxa2, offset, align, barextend) {
... ...
@@ -193,7 +193,7 @@ taxa2node <- function(data, taxa) {
193 193
     if (length(idx) == 0) {
194 194
         stop("input taxa is not valid...")
195 195
     }
196
-    
196
+
197 197
     return(data$node[idx])
198 198
 }
199 199
 
... ...
@@ -1,6 +1,6 @@
1 1
 ##' link between taxa
2 2
 ##'
3
-##' 
3
+##'
4 4
 ##' @title geom_taxalink
5 5
 ##' @param taxa1 taxa1, can be label or node number
6 6
 ##' @param taxa2 taxa2, can be label or node number
... ...
@@ -16,12 +16,13 @@ geom_taxalink <- function(taxa1, taxa2, curvature=0.5, ...) {
16 16
     position = "identity"
17 17
     show.legend = NA
18 18
     na.rm = TRUE
19
-    inherit.aes = FALSE    
19
+    inherit.aes = FALSE
20 20
 
21 21
     mapping <- aes_(x=~x, y=~y, node=~node, label=~label, xend=~x, yend=~y)
22 22
 
23 23
     layer(stat=StatTaxalink,
24 24
           mapping=mapping,
25
+          data = NULL,
25 26
           geom=GeomCurve,
26 27
           position='identity',
27 28
           show.legend=show.legend,
... ...
@@ -42,12 +43,12 @@ StatTaxalink <- ggproto("StatTaxalink", Stat,
42 43
                             node2 <- taxa2node(data, taxa2)
43 44
                             x <- data$x
44 45
                             y <- data$y
45
-                            
46
+
46 47
                             data.frame(x = x[node1],
47 48
                                        xend = x[node2],
48 49
                                        y = y[node1],
49 50
                                        yend = y[node2])
50
-                            
51
+
51 52
                         },
52 53
                         required_aes = c("x", "y", "xend", "yend")
53 54
                         )
... ...
@@ -3,7 +3,7 @@ ggtree: an R package for visualization and annotation of phylogenetic trees with
3 3
 
4 4
 [![releaseVersion](https://img.shields.io/badge/release%20version-1.4.20-green.svg?style=flat)](https://bioconductor.org/packages/ggtree) [![develVersion](https://img.shields.io/badge/devel%20version-1.5.16-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-14940/total-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree) [![month](https://img.shields.io/badge/downloads-1678/month-blue.svg?style=flat)](https://bioconductor.org/packages/stats/bioc/ggtree)
5 5
 
6
-[![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-2016--10--10-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)
6
+[![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-2016--10--11-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)
7 7
 
8 8
 [![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) [![install with bioconda](https://img.shields.io/badge/install%20with-bioconda-green.svg?style=flat)](http://bioconda.github.io/recipes/bioconductor-ggtree/README.html)
9 9
 
... ...
@@ -17,7 +17,7 @@ Please cite the following article when using `ggtree`:
17 17
 
18 18
 **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***. *accepted*
19 19
 
20
-[![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) [![citation](https://img.shields.io/badge/cited%20by-1-green.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627) [![Altmetric](https://img.shields.io/badge/Altmetric-171-green.svg?style=flat)](https://www.altmetric.com/details/10533079)
20
+[![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) [![citation](https://img.shields.io/badge/cited%20by-1-green.svg?style=flat)](https://scholar.google.com.hk/scholar?oi=bibs&hl=en&cites=7268358477862164627) [![Altmetric](https://img.shields.io/badge/Altmetric-125-green.svg?style=flat)](https://www.altmetric.com/details/10533079)
21 21
 
22 22
 ------------------------------------------------------------------------
23 23