git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@114159 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -13,16 +13,17 @@ Depends: |
13 | 13 |
Imports: |
14 | 14 |
ape, |
15 | 15 |
Biostrings, |
16 |
+ grDevices, |
|
16 | 17 |
grid, |
17 | 18 |
jsonlite, |
18 | 19 |
magrittr, |
19 | 20 |
methods, |
20 | 21 |
stats4, |
21 |
- tidyr |
|
22 |
+ tidyr, |
|
23 |
+ utils |
|
22 | 24 |
Suggests: |
23 | 25 |
colorspace, |
24 | 26 |
EBImage, |
25 |
- gridExtra, |
|
26 | 27 |
knitr, |
27 | 28 |
phylobase, |
28 | 29 |
phytools, |
... | ... |
@@ -198,6 +198,7 @@ importFrom(ggplot2,xlab) |
198 | 198 |
importFrom(ggplot2,xlim) |
199 | 199 |
importFrom(ggplot2,ylab) |
200 | 200 |
importFrom(grDevices,col2rgb) |
201 |
+importFrom(grDevices,colorRampPalette) |
|
201 | 202 |
importFrom(grDevices,rgb) |
202 | 203 |
importFrom(grid,grid.layout) |
203 | 204 |
importFrom(grid,grid.newpage) |
... | ... |
@@ -213,4 +214,6 @@ importFrom(magrittr,equals) |
213 | 214 |
importFrom(methods,show) |
214 | 215 |
importFrom(stats4,plot) |
215 | 216 |
importFrom(tidyr,gather) |
217 |
+importFrom(utils,download.file) |
|
218 |
+importFrom(utils,modifyList) |
|
216 | 219 |
importMethodsFrom(Biostrings,width) |
... | ... |
@@ -32,12 +32,8 @@ download.phylopic <- function(id, size=512, color="black", alpha=1) { |
32 | 32 |
imgfile <- tempfile(fileext = ".png") |
33 | 33 |
download.phylopic_internal(id, size, imgfile) |
34 | 34 |
|
35 |
- EBImage <- "EBImage" |
|
36 |
- require(EBImage, character.only = TRUE) |
|
37 |
- |
|
38 |
- readImage <- eval(parse(text="readImage")) |
|
39 |
- channel <- eval(parse(text="channel")) |
|
40 |
- |
|
35 |
+ requireNamespace("EBImage") |
|
36 |
+ channel <- eval(parse(text=paste0("EBImage::", "channel"))) |
|
41 | 37 |
img <- readImage(imgfile) |
42 | 38 |
|
43 | 39 |
color <- col2rgb(color) / 255 |
... | ... |
@@ -51,6 +47,8 @@ download.phylopic <- function(id, size=512, color="black", alpha=1) { |
51 | 47 |
return(img) |
52 | 48 |
} |
53 | 49 |
|
50 |
+##' @importFrom utils download.file |
|
51 |
+##' @importFrom utils modifyList |
|
54 | 52 |
download.phylopic_internal <- function(id, size=512, outfile=NULL) { |
55 | 53 |
size %<>% as.character %>% |
56 | 54 |
match.arg(c("64", "128", "256", "512", "1024")) |
... | ... |
@@ -20,7 +20,7 @@ subview <- function(mainview, subview, x, y, width=.1, height=.1) { |
20 | 20 |
|
21 | 21 |
xrng <- mainview$data[, aes_x] %>% range %>% diff |
22 | 22 |
yrng <- mainview$data[, aes_y] %>% range %>% diff |
23 |
- |
|
23 |
+ |
|
24 | 24 |
if (!any(class(subview) %in% c("ggplot", "grob", "character"))) { |
25 | 25 |
stop("subview should be a ggplot or grob object, or an image file...") |
26 | 26 |
} |
... | ... |
@@ -34,11 +34,11 @@ subview <- function(mainview, subview, x, y, width=.1, height=.1) { |
34 | 34 |
} else { |
35 | 35 |
stop("subview should be a ggplot or grob object, or an image file...") |
36 | 36 |
} |
37 |
- |
|
37 |
+ |
|
38 | 38 |
mainview + annotation_custom( |
39 |
- sv, |
|
40 |
- xmin = x - width*xrng, |
|
41 |
- xmax = x + width*xrng, |
|
42 |
- ymin = y - height*yrng, |
|
43 |
- ymax = y + height*yrng) |
|
39 |
+ sv, |
|
40 |
+ xmin = x - width*xrng, |
|
41 |
+ xmax = x + width*xrng, |
|
42 |
+ ymin = y - height*yrng, |
|
43 |
+ ymax = y + height*yrng) |
|
44 | 44 |
} |
... | ... |
@@ -462,6 +462,7 @@ roundDigit <- function(d) { |
462 | 462 |
|
463 | 463 |
|
464 | 464 |
## from ChIPseeker |
465 |
+##' @importFrom grDevices colorRampPalette |
|
465 | 466 |
getCols <- function (n) { |
466 | 467 |
col <- c("#8dd3c7", "#ffffb3", "#bebada", "#fb8072", "#80b1d3", |
467 | 468 |
"#fdb462", "#b3de69", "#fccde5", "#d9d9d9", "#bc80bd", |
... | ... |
@@ -475,9 +476,16 @@ getCols <- function (n) { |
475 | 476 |
colorRampPalette(col3)(n) |
476 | 477 |
} |
477 | 478 |
|
478 |
-readImage <- function(...) { |
|
479 |
- EBImage <- "EBImage" |
|
480 |
- require(EBImage, character.only = TRUE) |
|
481 |
- EBImage_readImage <- eval(parse(text="readImage")) |
|
482 |
- EBImage_readImage(...) |
|
479 |
+ |
|
480 |
+get_fun_from_pkg <- function(pkg, fun) { |
|
481 |
+ requireNamespace(pkg) |
|
482 |
+ eval(parse(text=paste0(pkg, "::", fun))) |
|
483 | 483 |
} |
484 |
+ |
|
485 |
+hist <- get_fun_from_pkg("graphics", "hist") |
|
486 |
+ |
|
487 |
+readImage <- get_fun_from_pkg("EBImage", "readImage") |
|
488 |
+ |
|
489 |
+ |
|
490 |
+ |
|
491 |
+ |
... | ... |
@@ -14,6 +14,8 @@ The `ggtree` package extending the `ggplot2` package. It based on grammar of gra |
14 | 14 |
|
15 | 15 |
`ggtree` is designed for not only viewing phylogenetic tree but also displaying annotation data in the tree. |
16 | 16 |
|
17 |
+A discussion forum can be found at <https://groups.google.com/forum/#!forum/bioc-ggtree> |
|
18 |
+ |
|
17 | 19 |
## Authors ## |
18 | 20 |
|
19 | 21 |
Guangchuang Yu and Tommy Tsan-Yuk Lam, School of Public Health, The University of Hong Kong. |