... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
# ggtree 1.17.1 |
2 | 2 |
|
3 |
++ `root.position` parameter for `fortify` and `ggtree` (2019-05-27, Mon) |
|
3 | 4 |
+ `geom_facet`, a geom layer version of `facet_plot` (2019-05-23, Thu) |
4 | 5 |
+ update `scale_x_ggtree`, now we can use `gheatmap() + scale_x_ggtree()` (2019-05-22, Wed) |
5 | 6 |
+ extend `xlim_expand` to work with `ggplot2` (2019-05-20, Tue) |
... | ... |
@@ -19,7 +19,8 @@ geom_rootedge <- function(rootedge = NULL, ...) { |
19 | 19 |
position = "identity", |
20 | 20 |
show.legend = NA, |
21 | 21 |
params = list(rootedge = rootedge, ...), |
22 |
- check.aes = FALSE |
|
22 |
+ check.aes = FALSE, |
|
23 |
+ inherit.aes = FALSE |
|
23 | 24 |
) |
24 | 25 |
|
25 | 26 |
} |
... | ... |
@@ -32,7 +33,9 @@ StatRootEdge <- ggproto("StatRootEdge", Stat, |
32 | 33 |
if (is.null(rootedge)) { |
33 | 34 |
rootedge <- d$branch.length |
34 | 35 |
} |
35 |
- if (is.null(rootedge) || is.na(rootedge)) { |
|
36 |
+ if (is.null(rootedge)) { |
|
37 |
+ xend <- d$x |
|
38 |
+ } else if (is.na(rootedge)) { |
|
36 | 39 |
xend <- d$x |
37 | 40 |
} else { |
38 | 41 |
xend <- d$x - rootedge |
... | ... |
@@ -30,7 +30,7 @@ stat_tree <- function(mapping=NULL, data=NULL, geom="segment", position="identit |
30 | 30 |
if (is.null(mapping)) { |
31 | 31 |
mapping <- default_aes |
32 | 32 |
} else { |
33 |
- mapping <- modifyList(mapping, default_aes) |
|
33 |
+ mapping <- modifyList(default_aes, mapping) |
|
34 | 34 |
} |
35 | 35 |
|
36 | 36 |
if (layout %in% c("rectangular", "fan", "circular")) { |
... | ... |
@@ -14,6 +14,7 @@ |
14 | 14 |
##' @param right logical. If \code{ladderize = TRUE}, should the ladder have the smallest clade on the |
15 | 15 |
##' right-hand side? See \code{\link[ape]{ladderize}} for more information. |
16 | 16 |
##' @param branch.length variable for scaling branch, if 'none' draw cladogram |
17 |
+##' @param root.position position of the root node (default = 0) |
|
17 | 18 |
##' @return tree |
18 | 19 |
##' @importFrom ggplot2 ggplot |
19 | 20 |
##' @importFrom ggplot2 xlab |
... | ... |
@@ -41,6 +42,7 @@ ggtree <- function(tr, |
41 | 42 |
ladderize = TRUE, |
42 | 43 |
right = FALSE, |
43 | 44 |
branch.length = "branch.length", |
45 |
+ root.position = 0, |
|
44 | 46 |
...) { |
45 | 47 |
|
46 | 48 |
# Check if layout string is valid. |
... | ... |
@@ -71,6 +73,7 @@ ggtree <- function(tr, |
71 | 73 |
ladderize = ladderize, |
72 | 74 |
right = right, |
73 | 75 |
branch.length = branch.length, |
76 |
+ root.position = root.position, |
|
74 | 77 |
...) |
75 | 78 |
|
76 | 79 |
if (is(tr, "multiPhylo")) { |
... | ... |
@@ -14,6 +14,7 @@ fortify.phylo <- function(model, data, |
14 | 14 |
mrsd = NULL, |
15 | 15 |
as.Date = FALSE, |
16 | 16 |
yscale = "none", |
17 |
+ root.position = 0, |
|
17 | 18 |
...) { |
18 | 19 |
|
19 | 20 |
x <- as.phylo(model) ## reorder.phylo(get.tree(model), "postorder") |
... | ... |
@@ -39,7 +40,7 @@ fortify.phylo <- function(model, data, |
39 | 40 |
|
40 | 41 |
ypos <- getYcoord(x) |
41 | 42 |
N <- Nnode(x, internal.only=FALSE) |
42 |
- xypos <- tibble::data_frame(node=1:N, x=xpos, y=ypos) |
|
43 |
+ xypos <- tibble::data_frame(node=1:N, x=xpos + root.position, y=ypos) |
|
43 | 44 |
|
44 | 45 |
df <- as_tibble(model) %>% |
45 | 46 |
mutate_(isTip = ~(! node %in% parent)) |
... | ... |
@@ -11,7 +11,7 @@ |
11 | 11 |
ggtree(tr, mapping = NULL, layout = "rectangular", open.angle = 0, |
12 | 12 |
mrsd = NULL, as.Date = FALSE, yscale = "none", |
13 | 13 |
yscale_mapping = NULL, ladderize = TRUE, right = FALSE, |
14 |
- branch.length = "branch.length", ...) |
|
14 |
+ branch.length = "branch.length", root.position = 0, ...) |
|
15 | 15 |
} |
16 | 16 |
\arguments{ |
17 | 17 |
\item{tr}{phylo object} |
... | ... |
@@ -38,6 +38,8 @@ right-hand side? See \code{\link[ape]{ladderize}} for more information.} |
38 | 38 |
|
39 | 39 |
\item{branch.length}{variable for scaling branch, if 'none' draw cladogram} |
40 | 40 |
|
41 |
+\item{root.position}{position of the root node (default = 0)} |
|
42 |
+ |
|
41 | 43 |
\item{...}{additional parameter} |
42 | 44 |
} |
43 | 45 |
\value{ |