git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@118985 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -20,6 +20,7 @@ S3method(fortify,phylo4d) |
20 | 20 |
S3method(fortify,phyloseq) |
21 | 21 |
S3method(fortify,r8s) |
22 | 22 |
S3method(fortify,raxml) |
23 |
+S3method(identify,gg) |
|
23 | 24 |
S3method(print,beastList) |
24 | 25 |
export("%<%") |
25 | 26 |
export("%<+%") |
... | ... |
@@ -215,7 +216,12 @@ importFrom(ggplot2,ylab) |
215 | 216 |
importFrom(grDevices,col2rgb) |
216 | 217 |
importFrom(grDevices,colorRampPalette) |
217 | 218 |
importFrom(grDevices,rgb) |
219 |
+importFrom(graphics,identify) |
|
220 |
+importFrom(grid,convertX) |
|
221 |
+importFrom(grid,convertY) |
|
222 |
+importFrom(grid,dataViewport) |
|
218 | 223 |
importFrom(grid,grid.layout) |
224 |
+importFrom(grid,grid.locator) |
|
219 | 225 |
importFrom(grid,grid.newpage) |
220 | 226 |
importFrom(grid,pushViewport) |
221 | 227 |
importFrom(grid,rasterGrob) |
... | ... |
@@ -43,7 +43,7 @@ ggtree <- function(tr, |
43 | 43 |
branch.length = "branch.length", |
44 | 44 |
ndigits = NULL, |
45 | 45 |
...) { |
46 |
- |
|
46 |
+ |
|
47 | 47 |
layout %<>% match.arg(c("rectangular", "slanted", "fan", "circular", "radial", "unrooted")) |
48 | 48 |
|
49 | 49 |
if (is(tr, "r8s") && branch.length == "branch.length") { |
... | ... |
@@ -90,6 +90,6 @@ ggtree <- function(tr, |
90 | 90 |
} else if (layout == "fan") { |
91 | 91 |
p <- layout_fan(p, open.angle) |
92 | 92 |
} |
93 |
- |
|
93 |
+ |
|
94 | 94 |
return(p) |
95 | 95 |
} |
96 | 96 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,37 @@ |
1 |
+ |
|
2 |
+##' identify node by interactive click |
|
3 |
+##' |
|
4 |
+##' |
|
5 |
+##' @rdname identify |
|
6 |
+##' @title identify |
|
7 |
+##' @param x tree view |
|
8 |
+##' @param ... additional parameters |
|
9 |
+##' @return node id |
|
10 |
+##' @importFrom grid convertX |
|
11 |
+##' @importFrom grid convertY |
|
12 |
+##' @importFrom grid pushViewport |
|
13 |
+##' @importFrom grid grid.locator |
|
14 |
+##' @importFrom grid unit |
|
15 |
+##' @importFrom grid dataViewport |
|
16 |
+##' @importFrom graphics identify |
|
17 |
+##' @method identify gg |
|
18 |
+##' @export |
|
19 |
+##' @author Guangchuang Yu |
|
20 |
+identify.gg <- function(x, ...) { |
|
21 |
+ tree_view <- x |
|
22 |
+ ## not used, since if x=NULL, it will call graphics::identify |
|
23 |
+ ## tree_view %<>% get_tree_view |
|
24 |
+ |
|
25 |
+ x <- tree_view$data$x |
|
26 |
+ y <- tree_view$data$y |
|
27 |
+ |
|
28 |
+ pushViewport(dataViewport(x, y)) |
|
29 |
+ loc <- grid.locator('in') %>% as.numeric |
|
30 |
+ |
|
31 |
+ xx <- as.numeric(convertX( unit(x,'native'), 'in' )) |
|
32 |
+ yy <- as.numeric(convertY( unit(y,'native'), 'in' )) |
|
33 |
+ |
|
34 |
+ idx <- which.min( (xx-loc[1])^2 + (yy-loc[2])^2 ) |
|
35 |
+ return(tree_view$data$node[idx]) |
|
36 |
+} |
|
37 |
+ |
0 | 38 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,23 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/method-identify.R |
|
3 |
+\name{identify.gg} |
|
4 |
+\alias{identify.gg} |
|
5 |
+\title{identify} |
|
6 |
+\usage{ |
|
7 |
+\method{identify}{gg}(x, ...) |
|
8 |
+} |
|
9 |
+\arguments{ |
|
10 |
+\item{x}{tree view} |
|
11 |
+ |
|
12 |
+\item{...}{additional parameters} |
|
13 |
+} |
|
14 |
+\value{ |
|
15 |
+node id |
|
16 |
+} |
|
17 |
+\description{ |
|
18 |
+identify node by interactive click |
|
19 |
+} |
|
20 |
+\author{ |
|
21 |
+Guangchuang Yu |
|
22 |
+} |
|
23 |
+ |