... | ... |
@@ -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.9002 |
|
5 |
+Version: 1.13.2 |
|
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,6 @@ |
1 |
-# ggtree 1.13.1.9002 |
|
1 |
+# ggtree 1.13.2 |
|
2 | 2 |
|
3 |
++ update rd of `facet_plot` by adding description and example (2018-07-19, Thu) |
|
3 | 4 |
+ order by y in `facet_plot` (2018-07-09, Mon) |
4 | 5 |
+ `extend` parameter in `geom_cladelabel` and `geom_strip` supports specifying |
5 | 6 |
extension of both sides (2018-07-06, Fri) |
... | ... |
@@ -1,6 +1,9 @@ |
1 | 1 |
##' plot tree associated data in an additional panel |
2 | 2 |
##' |
3 | 3 |
##' |
4 |
+##' 'facet_plot()' automatically re-arranges the input 'data' according to the tree structure, |
|
5 |
+##' visualizes the 'data' on specific 'panel' using the 'geom' function with aesthetic 'mapping' and other parameters, |
|
6 |
+##' and align the graph with the tree 'p' side by side. |
|
4 | 7 |
##' @title facet_plot |
5 | 8 |
##' @param p tree view |
6 | 9 |
##' @param panel panel name for plot of input data |
... | ... |
@@ -9,6 +12,11 @@ |
9 | 12 |
##' @param mapping aes mapping for 'geom' |
10 | 13 |
##' @param ... additional parameters for 'geom' |
11 | 14 |
##' @return ggplot object |
15 |
+##' @examples |
|
16 |
+##' tr <- rtree(10) |
|
17 |
+##' dd = data.frame(id=tr$tip.label, value=abs(rnorm(10))) |
|
18 |
+##' p <- ggtree(tr) |
|
19 |
+##' facet_plot(p, 'Trait', data = dd, geom=geom_point, mapping=aes(x=value)) |
|
12 | 20 |
##' @export |
13 | 21 |
##' @author Guangchuang Yu |
14 | 22 |
facet_plot <- function(p, panel, data, geom, mapping=NULL, ...) { |
... | ... |
@@ -20,7 +28,7 @@ facet_plot <- function(p, panel, data, geom, mapping=NULL, ...) { |
20 | 28 |
##' @importFrom ggplot2 facet_grid |
21 | 29 |
add_panel <- function(p, panel) { |
22 | 30 |
df <- p$data |
23 |
- if (is.null(df$.panel)) { |
|
31 |
+ if (is.null(df[[".panel"]])) { |
|
24 | 32 |
df[[".panel"]] <- factor("Tree") |
25 | 33 |
} |
26 | 34 |
levels(df$.panel) %<>% c(., panel) |
... | ... |
@@ -82,7 +82,7 @@ gheatmap <- function(p, data, offset=0, width=1, low="green", high="red", color= |
82 | 82 |
|
83 | 83 |
dd$x <- V2 |
84 | 84 |
dd$width <- width |
85 |
- |
|
85 |
+ dd[[".panel"]] <- factor("Tree") |
|
86 | 86 |
if (is.null(color)) { |
87 | 87 |
p2 <- p + geom_tile(data=dd, aes(x, y, fill=value), width=width, inherit.aes=FALSE) |
88 | 88 |
} else { |
... | ... |
@@ -101,6 +101,7 @@ gheatmap <- function(p, data, offset=0, width=1, low="green", high="red", color= |
101 | 101 |
y <- max(p$data$y) + 1 |
102 | 102 |
} |
103 | 103 |
mapping$y <- y |
104 |
+ mapping[[".panel"]] <- factor("Tree") |
|
104 | 105 |
p2 <- p2 + geom_text(data=mapping, aes(x=to, y = y, label=from), size=font.size, inherit.aes = FALSE, |
105 | 106 |
angle=colnames_angle, nudge_x=colnames_offset_x, nudge_y = colnames_offset_y, hjust=hjust) |
106 | 107 |
} |
... | ... |
@@ -4,9 +4,9 @@ ggtree: an R package for visualization and annotation of phylogenetic trees with |
4 | 4 |
|
5 | 5 |
<img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/ggtree/ggtree.png" height="200" align="right" /> |
6 | 6 |
|
7 |
-[](https://bioconductor.org/packages/ggtree) [](https://github.com/guangchuangyu/ggtree) [](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#since) [](https://awesome-r.com/#awesome-r-graphic-displays) |
|
7 |
+[](https://bioconductor.org/packages/ggtree) [](https://github.com/guangchuangyu/ggtree) [](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#since) [](https://awesome-r.com/#awesome-r-graphic-displays) |
|
8 | 8 |
|
9 |
-[](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#archives) [](http://www.repostatus.org/#active) [](https://codecov.io/gh/GuangchuangYu/ggtree) [](https://github.com/GuangchuangYu/ggtree/commits/master) |
|
9 |
+[](https://www.bioconductor.org/packages/devel/bioc/html/ggtree.html#archives) [](http://www.repostatus.org/#active) [](https://codecov.io/gh/GuangchuangYu/ggtree) [](https://github.com/GuangchuangYu/ggtree/commits/master) |
|
10 | 10 |
|
11 | 11 |
The `ggtree` package extending the `ggplot2` package. It based on grammar of graphics and takes all the good parts of `ggplot2`. `ggtree` is designed for not only viewing phylogenetic tree but also displaying annotation data on the tree. |
12 | 12 |
|
... | ... |
@@ -25,7 +25,7 @@ Please cite the following article when using `ggtree`: |
25 | 25 |
|
26 | 26 |
**G Yu**, DK Smith, H Zhu, Y Guan, TTY Lam<sup>\*</sup>. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data. ***Methods in Ecology and Evolution***. 2017, 8(1):28-36. |
27 | 27 |
|
28 |
-[](http://dx.doi.org/10.1111/2041-210X.12628) [](https://www.altmetric.com/details/10533079) |
|
28 |
+[](http://dx.doi.org/10.1111/2041-210X.12628) [](https://www.altmetric.com/details/10533079) |
|
29 | 29 |
|
30 | 30 |
------------------------------------------------------------------------ |
31 | 31 |
|
... | ... |
@@ -35,7 +35,7 @@ Please cite the following article when using `ggtree`: |
35 | 35 |
|
36 | 36 |
### Download stats |
37 | 37 |
|
38 |
-[](https://bioconductor.org/packages/stats/bioc/ggtree) [](https://bioconductor.org/packages/stats/bioc/ggtree) [](https://bioconductor.org/packages/stats/bioc/ggtree) |
|
38 |
+[](https://bioconductor.org/packages/stats/bioc/ggtree) [](https://bioconductor.org/packages/stats/bioc/ggtree) [](https://bioconductor.org/packages/stats/bioc/ggtree) |
|
39 | 39 |
|
40 | 40 |
<img src="https://guangchuangyu.github.io/software/ggtree/index_files/figure-html/dlstats-1.png" width="890"/> |
41 | 41 |
|
... | ... |
@@ -25,6 +25,17 @@ ggplot object |
25 | 25 |
\description{ |
26 | 26 |
plot tree associated data in an additional panel |
27 | 27 |
} |
28 |
+\details{ |
|
29 |
+'facet_plot()' automatically re-arranges the input 'data' according to the tree structure, |
|
30 |
+visualizes the 'data' on specific 'panel' using the 'geom' function with aesthetic 'mapping' and other parameters, |
|
31 |
+and align the graph with the tree 'p' side by side. |
|
32 |
+} |
|
33 |
+\examples{ |
|
34 |
+tr <- rtree(10) |
|
35 |
+dd = data.frame(id=tr$tip.label, value=abs(rnorm(10))) |
|
36 |
+p <- ggtree(tr) |
|
37 |
+facet_plot(p, 'Trait', data = dd, geom=geom_point, mapping=aes(x=value)) |
|
38 |
+} |
|
28 | 39 |
\author{ |
29 | 40 |
Guangchuang Yu |
30 | 41 |
} |