... | ... |
@@ -1,5 +1,7 @@ |
1 | 1 |
# ggtree 1.13.1.9002 |
2 | 2 |
|
3 |
++ `extend` parameter in `geom_cladelabel` and `geom_strip` supports specifying |
|
4 |
+ extension of both sides (2018-07-06, Fri) |
|
3 | 5 |
+ `geom_nodelab2` for circular layout (2018-07-03, Tue) |
4 | 6 |
- <https://groups.google.com/d/msgid/bioc-ggtree/cbe5e1e3-99c4-481d-8523-d5b50cf0460b%40googlegroups.com> |
5 | 7 |
+ re-export `ggplot2::fortify` |
... | ... |
@@ -21,7 +21,7 @@ facet_plot <- function(p, panel, data, geom, mapping=NULL, ...) { |
21 | 21 |
add_panel <- function(p, panel) { |
22 | 22 |
df <- p$data |
23 | 23 |
if (is.null(df$.panel)) { |
24 |
- df$.panel <- factor("Tree") |
|
24 |
+ df[[".panel"]] <- factor("Tree") |
|
25 | 25 |
} |
26 | 26 |
levels(df$.panel) %<>% c(., panel) |
27 | 27 |
p$data <- df |
... | ... |
@@ -232,6 +232,9 @@ get_cladelabel_position <- function(data, node, offset, align, adjustRatio, angl |
232 | 232 |
|
233 | 233 |
# get x, y and yend of clade region. |
234 | 234 |
get_cladelabel_position_ <- function(data, node, angle = "auto", extend = 0) { |
235 |
+ if (length(extend) == 1) { |
|
236 |
+ extend = rep(extend, 2) |
|
237 |
+ } |
|
235 | 238 |
|
236 | 239 |
sp <- get.offspring.df(data, node) |
237 | 240 |
sp2 <- c(sp, node) |
... | ... |
@@ -241,7 +244,7 @@ get_cladelabel_position_ <- function(data, node, angle = "auto", extend = 0) { |
241 | 244 |
y <- y[!is.na(y)] |
242 | 245 |
mx <- max(sp.df$x, na.rm=TRUE) |
243 | 246 |
|
244 |
- d <- data.frame(x=mx, y=min(y) - extend, yend=max(y) + extend) |
|
247 |
+ d <- data.frame(x=mx, y=min(y) - extend[2], yend=max(y) + extend[1]) |
|
245 | 248 |
if (missing(angle)) |
246 | 249 |
return(d) |
247 | 250 |
|
... | ... |
@@ -9,7 +9,7 @@ |
9 | 9 |
##' @param offset.text offset of text from bar |
10 | 10 |
##' @param align logical |
11 | 11 |
##' @param barsize size of bar |
12 |
-##' @param barextend extend bar vertically |
|
12 |
+##' @param extend extend bar vertically |
|
13 | 13 |
##' @param fontsize size of text |
14 | 14 |
##' @param angle angle of text |
15 | 15 |
##' @param geom one of 'text' or 'label' |
... | ... |
@@ -22,7 +22,7 @@ |
22 | 22 |
##' @export |
23 | 23 |
##' @author Guangchuang Yu |
24 | 24 |
geom_strip <- function(taxa1, taxa2, label=NA, offset=0, offset.text=0, |
25 |
- align=TRUE, barsize=0.5, barextend=0, fontsize=3.88, |
|
25 |
+ align=TRUE, barsize=0.5, extend=0, fontsize=3.88, |
|
26 | 26 |
angle=0, geom="text", hjust=0, fill=NA, family="sans", |
27 | 27 |
parse=FALSE, ...) { |
28 | 28 |
mapping <- NULL |
... | ... |
@@ -33,7 +33,7 @@ geom_strip <- function(taxa1, taxa2, label=NA, offset=0, offset.text=0, |
33 | 33 |
inherit.aes <- FALSE |
34 | 34 |
|
35 | 35 |
layer_bar <- stat_stripBar(taxa1=taxa1, taxa2=taxa2, label=label, offset=offset, align=align, |
36 |
- size=barsize, barextend=barextend, |
|
36 |
+ size=barsize, barextend=extend, |
|
37 | 37 |
mapping=mapping, data=data, |
38 | 38 |
position=position, show.legend = show.legend, |
39 | 39 |
inherit.aes = inherit.aes, na.rm=na.rm, ...) |
... | ... |
@@ -45,14 +45,14 @@ geom_strip <- function(taxa1, taxa2, label=NA, offset=0, offset.text=0, |
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, |
48 |
- align=align, size=fontsize, barextend=barextend, angle=angle, family=family, |
|
48 |
+ align=align, size=fontsize, barextend=extend, angle=angle, family=family, |
|
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 |
- align=align, size=fontsize, barextend=barextend, angle=angle, fill=fill,family=family, |
|
55 |
+ align=align, size=fontsize, barextend=extend, angle=angle, fill=fill,family=family, |
|
56 | 56 |
mapping=mapping, data=data, geom=geom, hjust=hjust, |
57 | 57 |
position=position, show.legend = show.legend, |
58 | 58 |
inherit.aes = inherit.aes, na.rm=na.rm, parse=parse, ...) |
... | ... |
@@ -174,13 +174,16 @@ get_striplabel_position <- function(data, taxa1, taxa2, offset, align, barextend |
174 | 174 |
|
175 | 175 |
|
176 | 176 |
get_striplabel_position_ <- function(data, taxa1, taxa2, barextend=0) { |
177 |
+ if (length(barextend) == 1) { |
|
178 |
+ barextend <- rep(barextend, 2) |
|
179 |
+ } |
|
177 | 180 |
node1 <- taxa2node(data, taxa1) |
178 | 181 |
node2 <- taxa2node(data, taxa2) |
179 | 182 |
|
180 | 183 |
xx <- with(data, c(x[node == node1], x[node == node2])) |
181 | 184 |
yy <- with(data, c(y[node == node1], y[node == node2])) |
182 | 185 |
|
183 |
- data.frame(x=max(xx), y=min(yy)-barextend, yend=max(yy)+barextend) |
|
186 |
+ data.frame(x=max(xx), y=min(yy)-barextend[2], yend=max(yy)+barextend[1]) |
|
184 | 187 |
} |
185 | 188 |
|
186 | 189 |
## used in geom_strip, geom_taxalink |
... | ... |
@@ -5,9 +5,9 @@ |
5 | 5 |
\title{geom_strip} |
6 | 6 |
\usage{ |
7 | 7 |
geom_strip(taxa1, taxa2, label = NA, offset = 0, offset.text = 0, |
8 |
- align = TRUE, barsize = 0.5, barextend = 0, fontsize = 3.88, |
|
9 |
- angle = 0, geom = "text", hjust = 0, fill = NA, family = "sans", |
|
10 |
- parse = FALSE, ...) |
|
8 |
+ align = TRUE, barsize = 0.5, extend = 0, fontsize = 3.88, angle = 0, |
|
9 |
+ geom = "text", hjust = 0, fill = NA, family = "sans", parse = FALSE, |
|
10 |
+ ...) |
|
11 | 11 |
} |
12 | 12 |
\arguments{ |
13 | 13 |
\item{taxa1}{taxa1} |
... | ... |
@@ -24,7 +24,7 @@ geom_strip(taxa1, taxa2, label = NA, offset = 0, offset.text = 0, |
24 | 24 |
|
25 | 25 |
\item{barsize}{size of bar} |
26 | 26 |
|
27 |
-\item{barextend}{extend bar vertically} |
|
27 |
+\item{extend}{extend bar vertically} |
|
28 | 28 |
|
29 | 29 |
\item{fontsize}{size of text} |
30 | 30 |
|