update ggtree to compatible with the ggplot2 3.4.0
... | ... |
@@ -38,7 +38,7 @@ |
38 | 38 |
#' \item \code{extend} extend xmax of the rectangle, defaults to 0. |
39 | 39 |
#' \item \code{extendto} specify a value, meaning the rectangle extend to, defaults to NULL. |
40 | 40 |
#' \item \code{linetype} the line type of margin, defaults to 1. |
41 |
-#' \item \code{size} the width of line of margin, defaults to 0.5. |
|
41 |
+#' \item \code{linewidth} the width of line of margin, defaults to 0.5. |
|
42 | 42 |
#' } |
43 | 43 |
#' \code{geom_hilight()} understands the following aesthethics for encircle layer (required |
44 | 44 |
#' aesthetics are in bold): |
... | ... |
@@ -49,7 +49,7 @@ |
49 | 49 |
#' \item \code{alpha} the transparency of fill, defaults to 0.5. |
50 | 50 |
#' \item \code{expand} expands the xspline clade region, defaults to 0. |
51 | 51 |
#' \item \code{spread} control the size, when only one point. |
52 |
-#' \item \code{size} the width of line of margin, defaults to 0.5. |
|
52 |
+#' \item \code{linewidth} the width of line of margin, defaults to 0.5. |
|
53 | 53 |
#' \item \code{linetype} the line type of margin, defaults to 1. |
54 | 54 |
#' \item \code{s_shape} the shape of the spline relative to the control points, defaults to 0.5. |
55 | 55 |
#' \item \code{s_open} whether the spline is a line or a closed shape, defaults to FALSE. |
... | ... |
@@ -125,10 +125,11 @@ geom_hilight_rect2 <- function(data=NULL, |
125 | 125 |
#' @importFrom grid rectGrob gpar grobTree |
126 | 126 |
GeomHilightRect <- ggproto("GeomHilightRect", Geom, |
127 | 127 |
default_aes = aes(colour = NA, fill = "steelblue", |
128 |
- size = 0.5, linetype = 1, alpha = 0.5, |
|
128 |
+ linewidth = 0.5, linetype = 1, alpha = 0.5, |
|
129 | 129 |
extend=0, extendto=NULL), |
130 | 130 |
required_aes = c("xmin", "xmax", "ymin", "ymax", "clade_root_node"), |
131 | 131 |
draw_key = draw_key_polygon, |
132 |
+ rename_size = TRUE, |
|
132 | 133 |
draw_panel = function(self, data, panel_params, coord, |
133 | 134 |
linejoin = "mitre", align="none", |
134 | 135 |
gradient = FALSE, |
... | ... |
@@ -195,7 +196,7 @@ GeomHilightRect <- ggproto("GeomHilightRect", Geom, |
195 | 196 |
#data <- data %>% dplyr::left_join(df, by="clade_root_node") |
196 | 197 |
polys <- lapply(split(data, seq_len(nrow(data))), function(row) { |
197 | 198 |
poly <- rect_to_poly(row$xmin, row$xmax, row$ymin, row$ymax) |
198 |
- aes <- new_data_frame(row[aesthetics])[rep(1,5), ] |
|
199 |
+ aes <- row[rep(1,5), aesthetics] |
|
199 | 200 |
#draw_panel_polar(data = cbind(poly, aes), |
200 | 201 |
# panel_params = panel_params, |
201 | 202 |
# coord = coord, |
... | ... |
@@ -203,7 +204,7 @@ GeomHilightRect <- ggproto("GeomHilightRect", Geom, |
203 | 204 |
# gradient.direction = gradient.direction, |
204 | 205 |
# gradient.length.out = gradient.length.out |
205 | 206 |
# ) |
206 |
- GeomPolygon$draw_panel(cbind(poly, aes), panel_params, coord) |
|
207 |
+ GeomPolygon$draw_panel(vctrs::vec_cbind(poly, aes), panel_params, coord) |
|
207 | 208 |
}) |
208 | 209 |
ggname("geom_hilight_rect2", do.call("grobTree", polys)) |
209 | 210 |
}else{ |
... | ... |
@@ -235,7 +236,7 @@ GeomHilightRect <- ggproto("GeomHilightRect", Geom, |
235 | 236 |
just = c("left", "top"), |
236 | 237 |
gp = gpar(col = row$colour, |
237 | 238 |
fill = fill, |
238 |
- lwd = row$size * ggplot2:::.pt, |
|
239 |
+ lwd = row$linewidth * ggplot2:::.pt, |
|
239 | 240 |
lty = row$linetype, |
240 | 241 |
linejoin = linejoin, |
241 | 242 |
lineend = if (identical(linejoin, "round")) "round" else "square") |
... | ... |
@@ -255,7 +256,7 @@ GeomHilightRect <- ggproto("GeomHilightRect", Geom, |
255 | 256 |
gp = grid::gpar( |
256 | 257 |
col = row$colour, |
257 | 258 |
fill = alpha(row$fill, row$alpha), |
258 |
- lwd = row$size * ggplot2::.pt, |
|
259 |
+ lwd = row$linewidth * ggplot2::.pt, |
|
259 | 260 |
lty = row$linetype, |
260 | 261 |
lineend = "butt" |
261 | 262 |
) |
... | ... |
@@ -271,7 +272,7 @@ GeomHilightRect <- ggproto("GeomHilightRect", Geom, |
271 | 272 |
just = c("left", "top"), |
272 | 273 |
gp = gpar(col = coords$colour, |
273 | 274 |
fill = alpha(coords$fill, coords$alpha), |
274 |
- lwd = coords$size * ggplot2:::.pt, |
|
275 |
+ lwd = coords$linewidth * ggplot2:::.pt, |
|
275 | 276 |
lty = coords$linetype, |
276 | 277 |
linejoin = linejoin, |
277 | 278 |
lineend = if (identical(linejoin, "round")) "round" else "square") |
... | ... |
@@ -306,9 +307,10 @@ geom_hilight_encircle2 <- function(data=NULL, |
306 | 307 |
GeomHilightEncircle <- ggproto("GeomHilightEncircle", Geom, |
307 | 308 |
required_aes = c("x", "y", "clade_root_node"), |
308 | 309 |
default_aes = aes(colour="black", fill="steelblue", alpha = 0.5, |
309 |
- expand=0, spread=0.1, linetype=1, size=0.5, |
|
310 |
+ expand=0, spread=0.1, linetype=1, linewidth = 0.5, |
|
310 | 311 |
s_shape=0.5, s_open=FALSE), |
311 | 312 |
draw_key = draw_key_polygon, |
313 |
+ rename_size = TRUE, |
|
312 | 314 |
draw_panel = function(data, panel_scales, coord){ |
313 | 315 |
globs <- lapply(split(data, data$clade_root_node), function(i) |
314 | 316 |
get_glob_encircle(i, panel_scales, coord)) |
... | ... |
@@ -477,9 +479,14 @@ build_align_data <- function(data, align){ |
477 | 479 |
|
478 | 480 |
|
479 | 481 |
#' @importFrom utils getFromNamespace |
480 |
-warning_wrap <- getFromNamespace("warning_wrap", "ggplot2") |
|
482 |
+#warning_wrap <- getFromNamespace("warning_wrap", "ggplot2") |
|
483 |
+warning_wrap <- function(...){ |
|
484 |
+ x = paste0(...) |
|
485 |
+ x = paste(strwrap(x), collapse = "\n") |
|
486 |
+ warning(x, call. = FALSE) |
|
487 |
+} |
|
481 | 488 |
rect_to_poly <- getFromNamespace("rect_to_poly", "ggplot2") |
482 |
-new_data_frame <- getFromNamespace("new_data_frame", "ggplot2") |
|
489 |
+#new_data_frame <- getFromNamespace("new_data_frame", "ggplot2") |
|
483 | 490 |
|
484 | 491 |
## ##' layer of hilight clade with rectangle |
485 | 492 |
## ##' |
... | ... |
@@ -4,7 +4,7 @@ |
4 | 4 |
##' @title geom_range |
5 | 5 |
##' @param range range(interval) to be displayed, e.g. "height_0.95_HPD" |
6 | 6 |
##' @param center center of the range, mean, median or auto (default, the center of the range) |
7 |
-##' @param ... additional parameter, e.g. color, size, alpha |
|
7 |
+##' @param ... additional parameter, e.g. color, linewidth, alpha |
|
8 | 8 |
##' @return ggplot layer |
9 | 9 |
##' @importFrom ggplot2 aes_string |
10 | 10 |
##' @export |
... | ... |
@@ -7,12 +7,12 @@ |
7 | 7 |
##' @title geom_aline |
8 | 8 |
##' @param mapping aes mapping |
9 | 9 |
##' @param linetype set line type of the line, defaults to "dotted" |
10 |
-##' @param size set line size of the line, defaults to 1 |
|
10 |
+##' @param linewidth set width of the line, defaults to 1 |
|
11 | 11 |
##' @param ... additional parameter |
12 | 12 |
##' @return aline layer |
13 | 13 |
##' @export |
14 | 14 |
##' @author Yu Guangchuang |
15 |
-geom_aline <- function(mapping=NULL, linetype="dotted", size=1, ...) { |
|
15 |
+geom_aline <- function(mapping=NULL, linetype="dotted", linewidth = 1, ...) { |
|
16 | 16 |
x <- y <- isTip <- NULL |
17 | 17 |
dot_mapping <- aes(xend=x+diff(range(x))/200, x=max(x), yend=y, subset=isTip) |
18 | 18 |
if (!is.null(mapping)) { |
... | ... |
@@ -21,7 +21,7 @@ geom_aline <- function(mapping=NULL, linetype="dotted", size=1, ...) { |
21 | 21 |
|
22 | 22 |
geom_segment2(dot_mapping, |
23 | 23 |
linetype=linetype, |
24 |
- size=size, stat = StatTreeData, ...) |
|
24 |
+ linewidth = linewidth, stat = StatTreeData, ...) |
|
25 | 25 |
} |
26 | 26 |
|
27 | 27 |
|
... | ... |
@@ -98,7 +98,7 @@ GeomSegmentGGtree <- ggproto("GeomSegmentGGtree", GeomSegment, |
98 | 98 |
data$x <- data$x + nudge_x |
99 | 99 |
|
100 | 100 |
data <- ggplot2::remove_missing(data, na.rm = na.rm, c("x", "y", "xend", |
101 |
- "yend", "linetype", "size", "shape"), name = "geom_segment") |
|
101 |
+ "yend", "linetype", "linewidth", "shape"), name = "geom_segment") |
|
102 | 102 |
if (empty(data)) |
103 | 103 |
return(zeroGrob()) |
104 | 104 |
if (!coord$is_linear()) { |
... | ... |
@@ -123,7 +123,7 @@ GeomSegmentGGtree <- ggproto("GeomSegmentGGtree", GeomSegment, |
123 | 123 |
return(grid::segmentsGrob(data$x, data$y, data$xend, data$yend, |
124 | 124 |
default.units = "native", gp = gpar(col = alpha(data$colour, |
125 | 125 |
data$alpha), fill = alpha(arrow.fill, data$alpha), |
126 |
- lwd = data$size * ggplot2::.pt, lty = data$linetype, |
|
126 |
+ lwd = data$linewidth * ggplot2::.pt, lty = data$linetype, |
|
127 | 127 |
lineend = lineend, linejoin = linejoin), arrow = arrow) |
128 | 128 |
) |
129 | 129 |
|
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
#' link between taxa |
2 | 2 |
#' |
3 | 3 |
#' `geom_taxalink` supports data.frame as input, |
4 |
-#' the `colour`, `size`, `linetype` and `alpha` can be mapped. When the `data` was provided, |
|
4 |
+#' the `colour`, `linewidth`, `linetype` and `alpha` can be mapped. When the `data` was provided, |
|
5 | 5 |
#' the `mapping` should be also provided, which `taxa1` and `taxa2` should be mapped created |
6 | 6 |
#' by `aes`, `aes_` or `aes_string`. In addition, the `hratio`, control the height of curve line, |
7 | 7 |
#' when tree layout is `cirular`, default is 1. `ncp`, the number of control points used to draw the |
... | ... |
@@ -25,7 +25,7 @@ |
25 | 25 |
#' \item \code{group} group category of link. |
26 | 26 |
#' \item \code{colour} control the color of line, default is black. |
27 | 27 |
#' \item \code{linetype} control the type of line, default is 1 (solid). |
28 |
-#' \item \code{size} control the width of line, default is 0.5. |
|
28 |
+#' \item \code{linewidth} control the width of line, default is 0.5. |
|
29 | 29 |
#' \item \code{curvature} control the curvature of line, default is 0.5, |
30 | 30 |
#' it will be created automatically in polar coordinate . |
31 | 31 |
#' \item \code{hratio} control the height of curve line, default is 1. |
... | ... |
@@ -175,7 +175,8 @@ geom_curvelink <- function(data=NULL, |
175 | 175 |
#' @importFrom scales alpha |
176 | 176 |
GeomCurvelink <- ggproto("GeomCurvelink", GeomSegment, |
177 | 177 |
required_aes = c("x", "y", "xend", "yend"), |
178 |
- default_aes = aes(colour = "black", size = 0.5, linetype = 1, alpha = NA, curvature=0.5, hratio=1, ncp=1, curveangle=90, square=FALSE), |
|
178 |
+ default_aes = aes(colour = "black", linewidth = 0.5, linetype = 1, alpha = NA, curvature=0.5, hratio=1, ncp=1, curveangle=90, square=FALSE), |
|
179 |
+ rename_size = TRUE, |
|
179 | 180 |
draw_panel = function(data, panel_params, coord, shape=0.5, outward=TRUE, |
180 | 181 |
arrow = NULL, arrow.fill=NULL, lineend = "butt", na.rm = FALSE) { |
181 | 182 |
if (!coord$is_linear()) { |
... | ... |
@@ -218,7 +219,7 @@ GeomCurvelink <- ggproto("GeomCurvelink", GeomSegment, |
218 | 219 |
square = trans$square[i], squareShape = 1, inflect = FALSE, open = TRUE, |
219 | 220 |
gp = gpar(col = alpha(trans$colour[i], trans$alpha[i]), |
220 | 221 |
fill = alpha(arrow.fill[i], trans$alpha[i]), |
221 |
- lwd = trans$size[i] * ggplot2::.pt, |
|
222 |
+ lwd = trans$linewidth[i] * ggplot2::.pt, |
|
222 | 223 |
lty = trans$linetype[i], |
223 | 224 |
lineend = lineend), |
224 | 225 |
arrow = arrow, |
... | ... |
@@ -17,7 +17,7 @@ |
17 | 17 |
##' to the left side of tip labels, defaults to "FALSE" |
18 | 18 |
##' with a line connecting each tip and its corresponding label, defaults to "FALSE" |
19 | 19 |
##' @param linetype set linetype of the line if align = TRUE, defaults to "dotted" |
20 |
-##' @param linesize set line size of the line if align = TRUE, defaults to 0.5 |
|
20 |
+##' @param linesize set line width if align = TRUE, defaults to 0.5 |
|
21 | 21 |
##' @param geom one of 'text', 'label', 'shadowtext', 'image' and 'phylopic' |
22 | 22 |
##' @param as_ylab display tip labels as y-axis label, |
23 | 23 |
##' only works for rectangular and dendrogram layouts, defaults to "FALSE" |
... | ... |
@@ -207,7 +207,7 @@ geom_tiplab_rectangular <- function(mapping=NULL, hjust = 0, align = FALSE, |
207 | 207 |
"bg.colour", "bg.r")) |
208 | 208 |
list( |
209 | 209 |
if (show_segment){ |
210 |
- lineparams <- list(mapping = segment_mapping, linetype=linetype, nudge_x = offset, size = linesize, stat = StatTreeData) |
|
210 |
+ lineparams <- list(mapping = segment_mapping, linetype=linetype, nudge_x = offset, linewidth = linesize, stat = StatTreeData) |
|
211 | 211 |
lineparams <- extract_params(lineparams, params, c("data", "color", "colour", "alpha", "show.legend", "na.rm", |
212 | 212 |
"inherit.aes", "arrow", "arrow.fill", "lineend")) |
213 | 213 |
do.call("geom_segment2", lineparams) |
... | ... |
@@ -74,7 +74,7 @@ aesthetics are in bold): |
74 | 74 |
\item \code{extend} extend xmax of the rectangle, defaults to 0. |
75 | 75 |
\item \code{extendto} specify a value, meaning the rectangle extend to, defaults to NULL. |
76 | 76 |
\item \code{linetype} the line type of margin, defaults to 1. |
77 |
-\item \code{size} the width of line of margin, defaults to 0.5. |
|
77 |
+\item \code{linewidth} the width of line of margin, defaults to 0.5. |
|
78 | 78 |
} |
79 | 79 |
\code{geom_hilight()} understands the following aesthethics for encircle layer (required |
80 | 80 |
aesthetics are in bold): |
... | ... |
@@ -85,7 +85,7 @@ aesthetics are in bold): |
85 | 85 |
\item \code{alpha} the transparency of fill, defaults to 0.5. |
86 | 86 |
\item \code{expand} expands the xspline clade region, defaults to 0. |
87 | 87 |
\item \code{spread} control the size, when only one point. |
88 |
-\item \code{size} the width of line of margin, defaults to 0.5. |
|
88 |
+\item \code{linewidth} the width of line of margin, defaults to 0.5. |
|
89 | 89 |
\item \code{linetype} the line type of margin, defaults to 1. |
90 | 90 |
\item \code{s_shape} the shape of the spline relative to the control points, defaults to 0.5. |
91 | 91 |
\item \code{s_open} whether the spline is a line or a closed shape, defaults to FALSE. |
... | ... |
@@ -4,14 +4,14 @@ |
4 | 4 |
\alias{geom_aline} |
5 | 5 |
\title{geom_aline} |
6 | 6 |
\usage{ |
7 |
-geom_aline(mapping = NULL, linetype = "dotted", size = 1, ...) |
|
7 |
+geom_aline(mapping = NULL, linetype = "dotted", linewidth = 1, ...) |
|
8 | 8 |
} |
9 | 9 |
\arguments{ |
10 | 10 |
\item{mapping}{aes mapping} |
11 | 11 |
|
12 | 12 |
\item{linetype}{set line type of the line, defaults to "dotted"} |
13 | 13 |
|
14 |
-\item{size}{set line size of the line, defaults to 1} |
|
14 |
+\item{linewidth}{set width of the line, defaults to 1} |
|
15 | 15 |
|
16 | 16 |
\item{...}{additional parameter} |
17 | 17 |
} |
... | ... |
@@ -11,7 +11,7 @@ geom_range(range, center = "auto", ...) |
11 | 11 |
|
12 | 12 |
\item{center}{center of the range, mean, median or auto (default, the center of the range)} |
13 | 13 |
|
14 |
-\item{...}{additional parameter, e.g. color, size, alpha} |
|
14 |
+\item{...}{additional parameter, e.g. color, linewidth, alpha} |
|
15 | 15 |
} |
16 | 16 |
\value{ |
17 | 17 |
ggplot layer |
... | ... |
@@ -36,7 +36,7 @@ a list object. |
36 | 36 |
} |
37 | 37 |
\description{ |
38 | 38 |
\code{geom_taxalink} supports data.frame as input, |
39 |
-the \code{colour}, \code{size}, \code{linetype} and \code{alpha} can be mapped. When the \code{data} was provided, |
|
39 |
+the \code{colour}, \code{linewidth}, \code{linetype} and \code{alpha} can be mapped. When the \code{data} was provided, |
|
40 | 40 |
the \code{mapping} should be also provided, which \code{taxa1} and \code{taxa2} should be mapped created |
41 | 41 |
by \code{aes}, \code{aes_} or \code{aes_string}. In addition, the \code{hratio}, control the height of curve line, |
42 | 42 |
when tree layout is \code{cirular}, default is 1. \code{ncp}, the number of control points used to draw the |
... | ... |
@@ -52,7 +52,7 @@ a column of data. |
52 | 52 |
\item \code{group} group category of link. |
53 | 53 |
\item \code{colour} control the color of line, default is black. |
54 | 54 |
\item \code{linetype} control the type of line, default is 1 (solid). |
55 |
-\item \code{size} control the width of line, default is 0.5. |
|
55 |
+\item \code{linewidth} control the width of line, default is 0.5. |
|
56 | 56 |
\item \code{curvature} control the curvature of line, default is 0.5, |
57 | 57 |
it will be created automatically in polar coordinate . |
58 | 58 |
\item \code{hratio} control the height of curve line, default is 1. |
... | ... |
@@ -27,7 +27,7 @@ with a line connecting each tip and its corresponding label, defaults to "FALSE" |
27 | 27 |
|
28 | 28 |
\item{linetype}{set linetype of the line if align = TRUE, defaults to "dotted"} |
29 | 29 |
|
30 |
-\item{linesize}{set line size of the line if align = TRUE, defaults to 0.5} |
|
30 |
+\item{linesize}{set line width if align = TRUE, defaults to 0.5} |
|
31 | 31 |
|
32 | 32 |
\item{geom}{one of 'text', 'label', 'shadowtext', 'image' and 'phylopic'} |
33 | 33 |
|