1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,89 +0,0 @@ |
1 |
-##' plots simultaneously a whole phylogenetic tree and a portion of it. |
|
2 |
-##' |
|
3 |
-##' |
|
4 |
-##' @title gzoom |
|
5 |
-##' @param phy phylo object |
|
6 |
-##' @param focus selected tips |
|
7 |
-##' @param subtree logical |
|
8 |
-##' @param widths widths |
|
9 |
-##' @return a list of ggplot object |
|
10 |
-##' @importFrom ggplot2 xlim |
|
11 |
-##' @importFrom ggplot2 scale_color_manual |
|
12 |
-##' @author ygc |
|
13 |
-##' @examples |
|
14 |
-##' require(ape) |
|
15 |
-##' data(chiroptera) |
|
16 |
-##' gzoom(chiroptera, grep("Plecotus", chiroptera$tip.label)) |
|
17 |
-gzoom.phylo <- function(phy, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
18 |
- if (is.character(focus)) { |
|
19 |
- focus <- which(phy$tip.label %in% focus) |
|
20 |
- } |
|
21 |
- |
|
22 |
- group_name <- "focus" |
|
23 |
- phy <- gfocus(phy, focus, group_name) |
|
24 |
- |
|
25 |
- foc <- attr(phy, group_name) |
|
26 |
- ## foc should +1 since the group index start from 0 |
|
27 |
- cols <- c("black", "red")[foc+1] |
|
28 |
- |
|
29 |
- p1 <- ggtree(phy, colour=cols) |
|
30 |
- |
|
31 |
- subtr <- drop.tip(phy, phy$tip.label[-focus], |
|
32 |
- subtree=subtree, rooted=TRUE) |
|
33 |
- |
|
34 |
- p2 <- ggtree(subtr, colour="red") + geom_tiplab(hjust=-0.05) |
|
35 |
- p2 <- p2 + xlim(0, max(p2$data$x)*1.2) |
|
36 |
- multiplot(p1, p2, ncol=2, widths=widths) |
|
37 |
- |
|
38 |
- invisible(list(p1=p1, p2=p2)) |
|
39 |
-} |
|
40 |
- |
|
41 |
-gzoom.ggtree <- function(tree_view, focus, widths=c(.3, .7), xmax_adjust=0) { |
|
42 |
- node <- MRCA(tree_view, focus[1], focus[2]) |
|
43 |
- if (length(focus) > 2) { |
|
44 |
- for (i in 3:length(focus)) { |
|
45 |
- node <- MRCA(tree_view, focus[i], node) |
|
46 |
- } |
|
47 |
- } |
|
48 |
- |
|
49 |
- cpos <- get_clade_position(tree_view, node) |
|
50 |
- p2 <- with(cpos, tree_view+ |
|
51 |
- xlim(xmin, xmax+xmax_adjust)+ |
|
52 |
- ylim(ymin, ymax)) |
|
53 |
- multiplot(tree_view, p2, ncol=2, widths=widths) |
|
54 |
- invisible(list(p1=tree_view, p2=p2)) |
|
55 |
-} |
|
56 |
- |
|
57 |
-##' @name gzoom |
|
58 |
-##' @title gzoom method |
|
59 |
-##' @rdname gzoom-methods |
|
60 |
-##' @exportMethod gzoom |
|
61 |
-##' @param xmax_adjust adjust xmax (xlim[2]) |
|
62 |
-##' @aliases gzoom,ggtree-method |
|
63 |
-setMethod("gzoom", signature(object="ggtree"), |
|
64 |
- function(object, focus, widths=c(.3, .7), xmax_adjust=0) { |
|
65 |
- gzoom.ggtree(object, focus, widths, xmax_adjust) |
|
66 |
- }) |
|
67 |
- |
|
68 |
- |
|
69 |
-##' zoom selected subtree |
|
70 |
-##' |
|
71 |
-##' |
|
72 |
-##' @rdname gzoom-methods |
|
73 |
-##' @exportMethod gzoom |
|
74 |
-setMethod("gzoom", signature(object="treedata"), |
|
75 |
- function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
76 |
- gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
77 |
- }) |
|
78 |
- |
|
79 |
- |
|
80 |
-##' @rdname gzoom-methods |
|
81 |
-##' @exportMethod gzoom |
|
82 |
-setMethod("gzoom", signature(object="phylo"), |
|
83 |
- function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
84 |
- gzoom.phylo(object, focus, subtree, widths) |
|
85 |
- }) |
|
86 |
- |
|
87 |
- |
|
88 |
-gfocus <- getFromNamespace("gfocus", "treeio") |
|
89 |
- |
... | ... |
@@ -26,12 +26,12 @@ gzoom.phylo <- function(phy, focus, subtree=FALSE, widths=c(.3, .7)) { |
26 | 26 |
## foc should +1 since the group index start from 0 |
27 | 27 |
cols <- c("black", "red")[foc+1] |
28 | 28 |
|
29 |
- p1 <- ggtree(phy, color=cols) |
|
29 |
+ p1 <- ggtree(phy, colour=cols) |
|
30 | 30 |
|
31 | 31 |
subtr <- drop.tip(phy, phy$tip.label[-focus], |
32 | 32 |
subtree=subtree, rooted=TRUE) |
33 | 33 |
|
34 |
- p2 <- ggtree(subtr, color="red") + geom_tiplab(hjust=-0.05) |
|
34 |
+ p2 <- ggtree(subtr, colour="red") + geom_tiplab(hjust=-0.05) |
|
35 | 35 |
p2 <- p2 + xlim(0, max(p2$data$x)*1.2) |
36 | 36 |
multiplot(p1, p2, ncol=2, widths=widths) |
37 | 37 |
|
... | ... |
@@ -39,7 +39,13 @@ gzoom.phylo <- function(phy, focus, subtree=FALSE, widths=c(.3, .7)) { |
39 | 39 |
} |
40 | 40 |
|
41 | 41 |
gzoom.ggtree <- function(tree_view, focus, widths=c(.3, .7), xmax_adjust=0) { |
42 |
- node <- MRCA(tree_view, focus) |
|
42 |
+ node <- MRCA(tree_view, focus[1], focus[2]) |
|
43 |
+ if (length(focus) > 2) { |
|
44 |
+ for (i in 3:length(focus)) { |
|
45 |
+ node <- MRCA(tree_view, focus[i], node) |
|
46 |
+ } |
|
47 |
+ } |
|
48 |
+ |
|
43 | 49 |
cpos <- get_clade_position(tree_view, node) |
44 | 50 |
p2 <- with(cpos, tree_view+ |
45 | 51 |
xlim(xmin, xmax+xmax_adjust)+ |
... | ... |
@@ -60,31 +60,6 @@ setMethod("gzoom", signature(object="ggtree"), |
60 | 60 |
}) |
61 | 61 |
|
62 | 62 |
|
63 |
-## ##' @rdname gzoom-methods |
|
64 |
-## ##' @exportMethod gzoom |
|
65 |
-## setMethod("gzoom", signature(object="apeBootstrap"), |
|
66 |
-## function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
67 |
-## gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
68 |
-## }) |
|
69 |
- |
|
70 |
- |
|
71 |
-## ##' zoom selected subtree |
|
72 |
-## ##' |
|
73 |
-## ##' |
|
74 |
-## ##' @rdname gzoom-methods |
|
75 |
-## ##' @exportMethod gzoom |
|
76 |
-## setMethod("gzoom", signature(object="beast"), |
|
77 |
-## function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
78 |
-## gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
79 |
-## }) |
|
80 |
- |
|
81 |
-## ##' @rdname gzoom-methods |
|
82 |
-## ##' @exportMethod gzoom |
|
83 |
-## setMethod("gzoom", signature(object="codeml"), |
|
84 |
-## function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
85 |
-## gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
86 |
-## }) |
|
87 |
- |
|
88 | 63 |
##' zoom selected subtree |
89 | 64 |
##' |
90 | 65 |
##' |
... | ... |
@@ -96,14 +71,6 @@ setMethod("gzoom", signature(object="treedata"), |
96 | 71 |
}) |
97 | 72 |
|
98 | 73 |
|
99 |
-## ##' @rdname gzoom-methods |
|
100 |
-## ##' @exportMethod gzoom |
|
101 |
-## setMethod("gzoom", signature(object="paml_rst"), |
|
102 |
-## function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
103 |
-## gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
104 |
-## }) |
|
105 |
- |
|
106 |
- |
|
107 | 74 |
##' @rdname gzoom-methods |
108 | 75 |
##' @exportMethod gzoom |
109 | 76 |
setMethod("gzoom", signature(object="phylo"), |
... | ... |
@@ -112,4 +79,5 @@ setMethod("gzoom", signature(object="phylo"), |
112 | 79 |
}) |
113 | 80 |
|
114 | 81 |
|
115 |
-gfocus <- treeio:::gfocus |
|
82 |
+gfocus <- getFromNamespace("gfocus", "treeio") |
|
83 |
+ |
... | ... |
@@ -78,12 +78,12 @@ setMethod("gzoom", signature(object="ggtree"), |
78 | 78 |
## gzoom.phylo(get.tree(object), focus, subtree, widths) |
79 | 79 |
## }) |
80 | 80 |
|
81 |
-##' @rdname gzoom-methods |
|
82 |
-##' @exportMethod gzoom |
|
83 |
-setMethod("gzoom", signature(object="codeml"), |
|
84 |
- function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
85 |
- gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
86 |
- }) |
|
81 |
+## ##' @rdname gzoom-methods |
|
82 |
+## ##' @exportMethod gzoom |
|
83 |
+## setMethod("gzoom", signature(object="codeml"), |
|
84 |
+## function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
85 |
+## gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
86 |
+## }) |
|
87 | 87 |
|
88 | 88 |
##' zoom selected subtree |
89 | 89 |
##' |
... | ... |
@@ -96,12 +96,12 @@ setMethod("gzoom", signature(object="treedata"), |
96 | 96 |
}) |
97 | 97 |
|
98 | 98 |
|
99 |
-##' @rdname gzoom-methods |
|
100 |
-##' @exportMethod gzoom |
|
101 |
-setMethod("gzoom", signature(object="paml_rst"), |
|
102 |
- function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
103 |
- gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
104 |
- }) |
|
99 |
+## ##' @rdname gzoom-methods |
|
100 |
+## ##' @exportMethod gzoom |
|
101 |
+## setMethod("gzoom", signature(object="paml_rst"), |
|
102 |
+## function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
103 |
+## gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
104 |
+## }) |
|
105 | 105 |
|
106 | 106 |
|
107 | 107 |
##' @rdname gzoom-methods |
... | ... |
@@ -68,15 +68,15 @@ setMethod("gzoom", signature(object="ggtree"), |
68 | 68 |
## }) |
69 | 69 |
|
70 | 70 |
|
71 |
-##' zoom selected subtree |
|
72 |
-##' |
|
73 |
-##' |
|
74 |
-##' @rdname gzoom-methods |
|
75 |
-##' @exportMethod gzoom |
|
76 |
-setMethod("gzoom", signature(object="beast"), |
|
77 |
- function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
78 |
- gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
79 |
- }) |
|
71 |
+## ##' zoom selected subtree |
|
72 |
+## ##' |
|
73 |
+## ##' |
|
74 |
+## ##' @rdname gzoom-methods |
|
75 |
+## ##' @exportMethod gzoom |
|
76 |
+## setMethod("gzoom", signature(object="beast"), |
|
77 |
+## function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
78 |
+## gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
79 |
+## }) |
|
80 | 80 |
|
81 | 81 |
##' @rdname gzoom-methods |
82 | 82 |
##' @exportMethod gzoom |
... | ... |
@@ -85,7 +85,9 @@ setMethod("gzoom", signature(object="codeml"), |
85 | 85 |
gzoom.phylo(get.tree(object), focus, subtree, widths) |
86 | 86 |
}) |
87 | 87 |
|
88 |
- |
|
88 |
+##' zoom selected subtree |
|
89 |
+##' |
|
90 |
+##' |
|
89 | 91 |
##' @rdname gzoom-methods |
90 | 92 |
##' @exportMethod gzoom |
91 | 93 |
setMethod("gzoom", signature(object="treedata"), |
... | ... |
@@ -60,12 +60,12 @@ setMethod("gzoom", signature(object="ggtree"), |
60 | 60 |
}) |
61 | 61 |
|
62 | 62 |
|
63 |
-##' @rdname gzoom-methods |
|
64 |
-##' @exportMethod gzoom |
|
65 |
-setMethod("gzoom", signature(object="apeBootstrap"), |
|
66 |
- function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
67 |
- gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
68 |
- }) |
|
63 |
+## ##' @rdname gzoom-methods |
|
64 |
+## ##' @exportMethod gzoom |
|
65 |
+## setMethod("gzoom", signature(object="apeBootstrap"), |
|
66 |
+## function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
67 |
+## gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
68 |
+## }) |
|
69 | 69 |
|
70 | 70 |
|
71 | 71 |
##' zoom selected subtree |
... | ... |
@@ -53,6 +53,7 @@ gzoom.ggtree <- function(tree_view, focus, widths=c(.3, .7), xmax_adjust=0) { |
53 | 53 |
##' @rdname gzoom-methods |
54 | 54 |
##' @exportMethod gzoom |
55 | 55 |
##' @param xmax_adjust adjust xmax (xlim[2]) |
56 |
+##' @aliases gzoom,ggtree-method |
|
56 | 57 |
setMethod("gzoom", signature(object="ggtree"), |
57 | 58 |
function(object, focus, widths=c(.3, .7), xmax_adjust=0) { |
58 | 59 |
gzoom.ggtree(object, focus, widths, xmax_adjust) |
... | ... |
@@ -48,6 +48,8 @@ gzoom.ggtree <- function(tree_view, focus, widths=c(.3, .7), xmax_adjust=0) { |
48 | 48 |
invisible(list(p1=tree_view, p2=p2)) |
49 | 49 |
} |
50 | 50 |
|
51 |
+##' @name gzoom |
|
52 |
+##' @title gzoom method |
|
51 | 53 |
##' @rdname gzoom-methods |
52 | 54 |
##' @exportMethod gzoom |
53 | 55 |
##' @param xmax_adjust adjust xmax (xlim[2]) |
... | ... |
@@ -85,7 +87,7 @@ setMethod("gzoom", signature(object="codeml"), |
85 | 87 |
|
86 | 88 |
##' @rdname gzoom-methods |
87 | 89 |
##' @exportMethod gzoom |
88 |
-setMethod("gzoom", signature(object="nhx"), |
|
90 |
+setMethod("gzoom", signature(object="treedata"), |
|
89 | 91 |
function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
90 | 92 |
gzoom.phylo(get.tree(object), focus, subtree, widths) |
91 | 93 |
}) |
... | ... |
@@ -105,3 +107,6 @@ setMethod("gzoom", signature(object="phylo"), |
105 | 107 |
function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
106 | 108 |
gzoom.phylo(object, focus, subtree, widths) |
107 | 109 |
}) |
110 |
+ |
|
111 |
+ |
|
112 |
+gfocus <- treeio:::gfocus |
... | ... |
@@ -38,7 +38,7 @@ gzoom.phylo <- function(phy, focus, subtree=FALSE, widths=c(.3, .7)) { |
38 | 38 |
invisible(list(p1=p1, p2=p2)) |
39 | 39 |
} |
40 | 40 |
|
41 |
-gzoom.ggplot <- function(tree_view, focus, widths=c(.3, .7), xmax_adjust=0) { |
|
41 |
+gzoom.ggtree <- function(tree_view, focus, widths=c(.3, .7), xmax_adjust=0) { |
|
42 | 42 |
node <- MRCA(tree_view, focus) |
43 | 43 |
cpos <- get_clade_position(tree_view, node) |
44 | 44 |
p2 <- with(cpos, tree_view+ |
... | ... |
@@ -51,9 +51,9 @@ gzoom.ggplot <- function(tree_view, focus, widths=c(.3, .7), xmax_adjust=0) { |
51 | 51 |
##' @rdname gzoom-methods |
52 | 52 |
##' @exportMethod gzoom |
53 | 53 |
##' @param xmax_adjust adjust xmax (xlim[2]) |
54 |
-setMethod("gzoom", signature(object="gg"), |
|
54 |
+setMethod("gzoom", signature(object="ggtree"), |
|
55 | 55 |
function(object, focus, widths=c(.3, .7), xmax_adjust=0) { |
56 |
- gzoom.ggplot(object, focus, widths, xmax_adjust) |
|
56 |
+ gzoom.ggtree(object, focus, widths, xmax_adjust) |
|
57 | 57 |
}) |
58 | 58 |
|
59 | 59 |
|
... | ... |
@@ -1,6 +1,6 @@ |
1 |
-##' plots simultaneously a whole phylogenetic tree and a portion of it. |
|
1 |
+##' plots simultaneously a whole phylogenetic tree and a portion of it. |
|
2 |
+##' |
|
2 | 3 |
##' |
3 |
-##' |
|
4 | 4 |
##' @title gzoom |
5 | 5 |
##' @param phy phylo object |
6 | 6 |
##' @param focus selected tips |
... | ... |
@@ -9,7 +9,6 @@ |
9 | 9 |
##' @return a list of ggplot object |
10 | 10 |
##' @importFrom ggplot2 xlim |
11 | 11 |
##' @importFrom ggplot2 scale_color_manual |
12 |
-##' @importFrom ape drop.tip |
|
13 | 12 |
##' @author ygc |
14 | 13 |
##' @examples |
15 | 14 |
##' require(ape) |
... | ... |
@@ -28,14 +27,14 @@ gzoom.phylo <- function(phy, focus, subtree=FALSE, widths=c(.3, .7)) { |
28 | 27 |
cols <- c("black", "red")[foc+1] |
29 | 28 |
|
30 | 29 |
p1 <- ggtree(phy, color=cols) |
31 |
- |
|
30 |
+ |
|
32 | 31 |
subtr <- drop.tip(phy, phy$tip.label[-focus], |
33 | 32 |
subtree=subtree, rooted=TRUE) |
34 |
- |
|
33 |
+ |
|
35 | 34 |
p2 <- ggtree(subtr, color="red") + geom_tiplab(hjust=-0.05) |
36 | 35 |
p2 <- p2 + xlim(0, max(p2$data$x)*1.2) |
37 |
- multiplot(p1, p2, ncol=2, widths=widths) |
|
38 |
- |
|
36 |
+ multiplot(p1, p2, ncol=2, widths=widths) |
|
37 |
+ |
|
39 | 38 |
invisible(list(p1=p1, p2=p2)) |
40 | 39 |
} |
41 | 40 |
|
... | ... |
@@ -68,7 +67,7 @@ setMethod("gzoom", signature(object="apeBootstrap"), |
68 | 67 |
|
69 | 68 |
##' zoom selected subtree |
70 | 69 |
##' |
71 |
-##' |
|
70 |
+##' |
|
72 | 71 |
##' @rdname gzoom-methods |
73 | 72 |
##' @exportMethod gzoom |
74 | 73 |
setMethod("gzoom", signature(object="beast"), |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@113679 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -10,7 +10,6 @@ |
10 | 10 |
##' @importFrom ggplot2 xlim |
11 | 11 |
##' @importFrom ggplot2 scale_color_manual |
12 | 12 |
##' @importFrom ape drop.tip |
13 |
-##' @importFrom gridExtra grid.arrange |
|
14 | 13 |
##' @author ygc |
15 | 14 |
##' @examples |
16 | 15 |
##' require(ape) |
... | ... |
@@ -35,7 +34,7 @@ gzoom.phylo <- function(phy, focus, subtree=FALSE, widths=c(.3, .7)) { |
35 | 34 |
|
36 | 35 |
p2 <- ggtree(subtr, color="red") + geom_tiplab(hjust=-0.05) |
37 | 36 |
p2 <- p2 + xlim(0, max(p2$data$x)*1.2) |
38 |
- grid.arrange(p1, p2, ncol=2, widths=widths) |
|
37 |
+ multiplot(p1, p2, ncol=2, widths=widths) |
|
39 | 38 |
|
40 | 39 |
invisible(list(p1=p1, p2=p2)) |
41 | 40 |
} |
... | ... |
@@ -46,7 +45,7 @@ gzoom.ggplot <- function(tree_view, focus, widths=c(.3, .7), xmax_adjust=0) { |
46 | 45 |
p2 <- with(cpos, tree_view+ |
47 | 46 |
xlim(xmin, xmax+xmax_adjust)+ |
48 | 47 |
ylim(ymin, ymax)) |
49 |
- grid.arrange(tree_view, p2, ncol=2, widths=widths) |
|
48 |
+ multiplot(tree_view, p2, ncol=2, widths=widths) |
|
50 | 49 |
invisible(list(p1=tree_view, p2=p2)) |
51 | 50 |
} |
52 | 51 |
|
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@112112 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -1,3 +1,72 @@ |
1 |
+##' plots simultaneously a whole phylogenetic tree and a portion of it. |
|
2 |
+##' |
|
3 |
+##' |
|
4 |
+##' @title gzoom |
|
5 |
+##' @param phy phylo object |
|
6 |
+##' @param focus selected tips |
|
7 |
+##' @param subtree logical |
|
8 |
+##' @param widths widths |
|
9 |
+##' @return a list of ggplot object |
|
10 |
+##' @importFrom ggplot2 xlim |
|
11 |
+##' @importFrom ggplot2 scale_color_manual |
|
12 |
+##' @importFrom ape drop.tip |
|
13 |
+##' @importFrom gridExtra grid.arrange |
|
14 |
+##' @author ygc |
|
15 |
+##' @examples |
|
16 |
+##' require(ape) |
|
17 |
+##' data(chiroptera) |
|
18 |
+##' gzoom(chiroptera, grep("Plecotus", chiroptera$tip.label)) |
|
19 |
+gzoom.phylo <- function(phy, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
20 |
+ if (is.character(focus)) { |
|
21 |
+ focus <- which(phy$tip.label %in% focus) |
|
22 |
+ } |
|
23 |
+ |
|
24 |
+ group_name <- "focus" |
|
25 |
+ phy <- gfocus(phy, focus, group_name) |
|
26 |
+ |
|
27 |
+ foc <- attr(phy, group_name) |
|
28 |
+ ## foc should +1 since the group index start from 0 |
|
29 |
+ cols <- c("black", "red")[foc+1] |
|
30 |
+ |
|
31 |
+ p1 <- ggtree(phy, color=cols) |
|
32 |
+ |
|
33 |
+ subtr <- drop.tip(phy, phy$tip.label[-focus], |
|
34 |
+ subtree=subtree, rooted=TRUE) |
|
35 |
+ |
|
36 |
+ p2 <- ggtree(subtr, color="red") + geom_tiplab(hjust=-0.05) |
|
37 |
+ p2 <- p2 + xlim(0, max(p2$data$x)*1.2) |
|
38 |
+ grid.arrange(p1, p2, ncol=2, widths=widths) |
|
39 |
+ |
|
40 |
+ invisible(list(p1=p1, p2=p2)) |
|
41 |
+} |
|
42 |
+ |
|
43 |
+gzoom.ggplot <- function(tree_view, focus, widths=c(.3, .7), xmax_adjust=0) { |
|
44 |
+ node <- MRCA(tree_view, focus) |
|
45 |
+ cpos <- get_clade_position(tree_view, node) |
|
46 |
+ p2 <- with(cpos, tree_view+ |
|
47 |
+ xlim(xmin, xmax+xmax_adjust)+ |
|
48 |
+ ylim(ymin, ymax)) |
|
49 |
+ grid.arrange(tree_view, p2, ncol=2, widths=widths) |
|
50 |
+ invisible(list(p1=tree_view, p2=p2)) |
|
51 |
+} |
|
52 |
+ |
|
53 |
+##' @rdname gzoom-methods |
|
54 |
+##' @exportMethod gzoom |
|
55 |
+##' @param xmax_adjust adjust xmax (xlim[2]) |
|
56 |
+setMethod("gzoom", signature(object="gg"), |
|
57 |
+ function(object, focus, widths=c(.3, .7), xmax_adjust=0) { |
|
58 |
+ gzoom.ggplot(object, focus, widths, xmax_adjust) |
|
59 |
+ }) |
|
60 |
+ |
|
61 |
+ |
|
62 |
+##' @rdname gzoom-methods |
|
63 |
+##' @exportMethod gzoom |
|
64 |
+setMethod("gzoom", signature(object="apeBootstrap"), |
|
65 |
+ function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
66 |
+ gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
67 |
+ }) |
|
68 |
+ |
|
69 |
+ |
|
1 | 70 |
##' zoom selected subtree |
2 | 71 |
##' |
3 | 72 |
##' |
... | ... |
@@ -8,6 +77,13 @@ setMethod("gzoom", signature(object="beast"), |
8 | 77 |
gzoom.phylo(get.tree(object), focus, subtree, widths) |
9 | 78 |
}) |
10 | 79 |
|
80 |
+##' @rdname gzoom-methods |
|
81 |
+##' @exportMethod gzoom |
|
82 |
+setMethod("gzoom", signature(object="codeml"), |
|
83 |
+ function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
84 |
+ gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
85 |
+ }) |
|
86 |
+ |
|
11 | 87 |
|
12 | 88 |
##' @rdname gzoom-methods |
13 | 89 |
##' @exportMethod gzoom |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@111815 bc3139a8-67e5-0310-9ffc-ced21a209358
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,33 @@ |
1 |
+##' zoom selected subtree |
|
2 |
+##' |
|
3 |
+##' |
|
4 |
+##' @rdname gzoom-methods |
|
5 |
+##' @exportMethod gzoom |
|
6 |
+setMethod("gzoom", signature(object="beast"), |
|
7 |
+ function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
8 |
+ gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
9 |
+ }) |
|
10 |
+ |
|
11 |
+ |
|
12 |
+##' @rdname gzoom-methods |
|
13 |
+##' @exportMethod gzoom |
|
14 |
+setMethod("gzoom", signature(object="nhx"), |
|
15 |
+ function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
16 |
+ gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
17 |
+ }) |
|
18 |
+ |
|
19 |
+ |
|
20 |
+##' @rdname gzoom-methods |
|
21 |
+##' @exportMethod gzoom |
|
22 |
+setMethod("gzoom", signature(object="paml_rst"), |
|
23 |
+ function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
24 |
+ gzoom.phylo(get.tree(object), focus, subtree, widths) |
|
25 |
+ }) |
|
26 |
+ |
|
27 |
+ |
|
28 |
+##' @rdname gzoom-methods |
|
29 |
+##' @exportMethod gzoom |
|
30 |
+setMethod("gzoom", signature(object="phylo"), |
|
31 |
+ function(object, focus, subtree=FALSE, widths=c(.3, .7)) { |
|
32 |
+ gzoom.phylo(object, focus, subtree, widths) |
|
33 |
+ }) |