... | ... |
@@ -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.13.1.9001 |
|
5 |
+Version: 1.13.1.9002 |
|
6 | 6 |
Authors@R: c( |
7 | 7 |
person("Guangchuang", "Yu", email = "guangchuangyu@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0002-6485-8781")), |
8 | 8 |
person("Tommy Tsan-Yuk", "Lam", email = "tylam.tommy@gmail.com", role = c("aut", "ths")), |
... | ... |
@@ -1,5 +1,7 @@ |
1 |
-# ggtree 1.13.1.9001 |
|
1 |
+# ggtree 1.13.1.9002 |
|
2 | 2 |
|
3 |
++ `geom_nodelab2` for circular layout (2018-07-03, Tue) |
|
4 |
+ - <https://groups.google.com/d/msgid/bioc-ggtree/cbe5e1e3-99c4-481d-8523-d5b50cf0460b%40googlegroups.com> |
|
3 | 5 |
+ re-export `ggplot2::fortify` |
4 | 6 |
- <https://groups.google.com/d/msgid/bioc-ggtree/bf7a9b3c-9a8f-4d8d-a782-1b467fba38bc%40googlegroups.com> |
5 | 7 |
|
... | ... |
@@ -10,7 +10,7 @@ |
10 | 10 |
##' @param ... additional parameters |
11 | 11 |
##' @return geom layer |
12 | 12 |
##' @export |
13 |
-##' @author guangchuang yu |
|
13 |
+##' @author Guangchuang Yu |
|
14 | 14 |
geom_nodelab <- function(mapping = NULL, nudge_x = 0, nudge_y = 0, geom = "text", hjust = 0.5, ...) { |
15 | 15 |
self_mapping <- aes_(subset = ~!isTip) |
16 | 16 |
if (is.null(mapping)) { |
... | ... |
@@ -21,3 +21,32 @@ geom_nodelab <- function(mapping = NULL, nudge_x = 0, nudge_y = 0, geom = "text" |
21 | 21 |
|
22 | 22 |
geom_tiplab(mapping, offset = nudge_x, nudge_y = nudge_y, geom = geom, hjust = hjust, ...) |
23 | 23 |
} |
24 |
+ |
|
25 |
+##' add node label for circular layout |
|
26 |
+##' |
|
27 |
+##' |
|
28 |
+##' @title @geom_nodelab2 |
|
29 |
+##' @inheritParams geom_nodelab |
|
30 |
+##' @return node label layer |
|
31 |
+##' @export |
|
32 |
+##' @author Guangchuang Yu |
|
33 |
+geom_nodelab2 <- function(mapping = NULL, nudge_x = 0, nudge_y = 0, geom = "text", hjust = 0.5, ...) { |
|
34 |
+ angle <- isTip <- node <- NULL |
|
35 |
+ m1 <- aes(subset=(!isTip & (angle < 90 | angle > 270)), angle=angle, node = node) |
|
36 |
+ m2 <- aes(subset=(!isTip & (angle >= 90 & angle <=270)), angle=angle+180, node = node) |
|
37 |
+ |
|
38 |
+ if (!is.null(mapping)) { |
|
39 |
+ if (!is.null(mapping$subset)) { |
|
40 |
+ m1 <- aes_string(angle = "angle", node = "node", |
|
41 |
+ subset = paste0(as.expression(get_aes_var(mapping, "subset")), '& (!isTip & (angle < 90 | angle > 270))')) |
|
42 |
+ m2 <- aes_string(angle = "angle+180", node = "node", |
|
43 |
+ subset = paste0(as.expression(get_aes_var(mapping, "subset")), '& (!isTip & (angle >= 90 & angle <= 270))')) |
|
44 |
+ } |
|
45 |
+ m1 <- modifyList(mapping, m1) |
|
46 |
+ m2 <- modifyList(mapping, m2) |
|
47 |
+ } |
|
48 |
+ |
|
49 |
+ list(geom_nodelab(m1, hjust=hjust, nudge_x = nudge_x, nudge_y = nudge_y, geom = geom, ...), |
|
50 |
+ geom_nodelab(m2, hjust=1-hjust, nudge_x = nudge_x, nudge_y = nudge_y, geom = geom, ...) |
|
51 |
+ ) |
|
52 |
+} |
32 | 32 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,31 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/geom_nodelab.R |
|
3 |
+\name{geom_nodelab2} |
|
4 |
+\alias{geom_nodelab2} |
|
5 |
+\title{@geom_nodelab2} |
|
6 |
+\usage{ |
|
7 |
+geom_nodelab2(mapping = NULL, nudge_x = 0, nudge_y = 0, geom = "text", |
|
8 |
+ hjust = 0.5, ...) |
|
9 |
+} |
|
10 |
+\arguments{ |
|
11 |
+\item{mapping}{aes mapping} |
|
12 |
+ |
|
13 |
+\item{nudge_x}{horizontal adjustment to nudge label} |
|
14 |
+ |
|
15 |
+\item{nudge_y}{vertical adjustment to nudge label} |
|
16 |
+ |
|
17 |
+\item{geom}{one of 'text', 'label', 'image' and 'phylopic'} |
|
18 |
+ |
|
19 |
+\item{hjust}{horizontal alignment, one of 0, 0.5 or 1} |
|
20 |
+ |
|
21 |
+\item{...}{additional parameters} |
|
22 |
+} |
|
23 |
+\value{ |
|
24 |
+node label layer |
|
25 |
+} |
|
26 |
+\description{ |
|
27 |
+add node label for circular layout |
|
28 |
+} |
|
29 |
+\author{ |
|
30 |
+Guangchuang Yu |
|
31 |
+} |