git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@121787 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -15,11 +15,27 @@ geom_tippoint <- function(mapping = NULL, data = NULL, |
15 | 15 |
if (is.null(mapping)) { |
16 | 16 |
mapping <- self_mapping |
17 | 17 |
} else { |
18 |
- mapping %<>% modifyList(self_mapping) |
|
18 |
+ mapping <- modifyList(self_mapping, mapping) |
|
19 | 19 |
} |
20 | 20 |
geom_point2(mapping, data, position, na.rm, show.legend, inherit.aes, ...) |
21 | 21 |
} |
22 | 22 |
|
23 |
+geom_tippoint2 <- function(mapping=NULL, hjust=0, ...) { |
|
24 |
+ angle <- NULL |
|
25 |
+ m1 <- aes(subset=(isTip & (angle < 90 | angle > 270)), angle=angle) |
|
26 |
+ m2 <- aes(subset=(isTip & (angle >= 90 & angle <=270)), angle=angle+180) |
|
27 |
+ |
|
28 |
+ if (!is.null(mapping)) { |
|
29 |
+ m1 <- modifyList(mapping, m1) |
|
30 |
+ m2 <- modifyList(mapping, m2) |
|
31 |
+ } |
|
32 |
+ |
|
33 |
+ list(geom_tippoint(m1, hjust=hjust, ...), |
|
34 |
+ geom_tippoint(m2, hjust=1-hjust, ...) |
|
35 |
+ ) |
|
36 |
+} |
|
37 |
+ |
|
38 |
+ |
|
23 | 39 |
##' add node point |
24 | 40 |
##' |
25 | 41 |
##' |
... | ... |
@@ -1,7 +1,7 @@ |
1 | 1 |
##' add tip label layer |
2 | 2 |
##' |
3 |
-##' |
|
4 |
-##' @title geom_tiplab |
|
3 |
+##' |
|
4 |
+##' @title geom_tiplab |
|
5 | 5 |
##' @param mapping aes mapping |
6 | 6 |
##' @param hjust horizontal adjustment |
7 | 7 |
##' @param offset tiplab offset |
... | ... |
@@ -34,19 +34,19 @@ geom_tiplab <- function(mapping=NULL, hjust = 0, align = FALSE, linetype = "dot |
34 | 34 |
} |
35 | 35 |
|
36 | 36 |
if (is.null(mapping)) { |
37 |
- text_mapping <- self_mapping |
|
37 |
+ text_mapping <- self_mapping |
|
38 | 38 |
} else { |
39 | 39 |
text_mapping <- modifyList(self_mapping, mapping) |
40 | 40 |
} |
41 | 41 |
|
42 |
- |
|
42 |
+ |
|
43 | 43 |
show_segment <- FALSE |
44 | 44 |
if (align && (!is.na(linetype) && !is.null(linetype))) { |
45 | 45 |
show_segment <- TRUE |
46 |
- } |
|
46 |
+ } |
|
47 | 47 |
|
48 | 48 |
list( |
49 |
- text_geom(mapping=text_mapping, |
|
49 |
+ text_geom(mapping=text_mapping, |
|
50 | 50 |
hjust = hjust, nudge_x = offset, ...) |
51 | 51 |
, |
52 | 52 |
if (show_segment) |
... | ... |
@@ -60,7 +60,7 @@ geom_tiplab <- function(mapping=NULL, hjust = 0, align = FALSE, linetype = "dot |
60 | 60 |
|
61 | 61 |
##' add tip label for circular layout |
62 | 62 |
##' |
63 |
-##' |
|
63 |
+##' |
|
64 | 64 |
##' @title geom_tiplab2 |
65 | 65 |
##' @param mapping aes mapping |
66 | 66 |
##' @param hjust horizontal adjustment |
... | ... |
@@ -72,11 +72,12 @@ geom_tiplab <- function(mapping=NULL, hjust = 0, align = FALSE, linetype = "dot |
72 | 72 |
geom_tiplab2 <- function(mapping=NULL, hjust=0, ...) { |
73 | 73 |
|
74 | 74 |
angle <- NULL |
75 |
+ isTip <- NULL |
|
75 | 76 |
## m1 <- aes(subset=(abs(angle) < 90), angle=angle) |
76 | 77 |
## m2 <- aes(subset=(abs(angle) >= 90), angle=angle+180) |
77 |
- m1 <- aes(subset=(angle < 90 | angle > 270), angle=angle) |
|
78 |
- m2 <- aes(subset=(angle >= 90 & angle <=270), angle=angle+180) |
|
79 |
- |
|
78 |
+ m1 <- aes(subset=(isTip & (angle < 90 | angle > 270)), angle=angle) |
|
79 |
+ m2 <- aes(subset=(isTip & (angle >= 90 & angle <=270)), angle=angle+180) |
|
80 |
+ |
|
80 | 81 |
if (!is.null(mapping)) { |
81 | 82 |
m1 <- modifyList(mapping, m1) |
82 | 83 |
m2 <- modifyList(mapping, m2) |
... | ... |
@@ -91,14 +92,14 @@ geom_tipsegment <- function(mapping=NULL, data=NULL, |
91 | 92 |
geom=GeomSegmentGGtree, position = "identity", |
92 | 93 |
offset, ..., |
93 | 94 |
show.legend=NA, inherit.aes=FALSE, na.rm=TRUE) { |
94 |
- |
|
95 |
+ |
|
95 | 96 |
default_aes <- aes_(x=~x, y=~y) |
96 | 97 |
if (is.null(mapping)) { |
97 | 98 |
mapping <- default_aes |
98 | 99 |
} else { |
99 | 100 |
mapping <- modifyList(default_aes, mapping) |
100 | 101 |
} |
101 |
- |
|
102 |
+ |
|
102 | 103 |
layer(stat=StatTipSegment, |
103 | 104 |
data = data, |
104 | 105 |
mapping = mapping, |