1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,97 +0,0 @@ |
1 |
-title: "ggtree utilities" |
|
2 |
-author: "Guangchuang Yu and Tommy Tsan-Yuk Lam\\ |
|
3 |
- |
|
4 |
- School of Public Health, The University of Hong Kong" |
|
5 |
-date: "`r Sys.Date()`" |
|
6 |
-bibliography: ggtree.bib |
|
7 |
-csl: nature.csl |
|
8 |
-output: |
|
9 |
- prettydoc::html_pretty: |
|
10 |
- toc: true |
|
11 |
- theme: cayman |
|
12 |
- highlight: github |
|
13 |
- pdf_document: |
|
14 |
- toc: true |
|
15 |
-vignette: > |
|
16 |
- %\VignetteIndexEntry{06 ggtree utilities} |
|
17 |
- %\VignetteEngine{knitr::rmarkdown} |
|
18 |
- %\usepackage[utf8]{inputenc} |
|
19 |
- |
|
20 |
-```{r style, echo=FALSE, results="asis", message=FALSE} |
|
21 |
-knitr::opts_chunk$set(tidy = FALSE, |
|
22 |
- message = FALSE) |
|
23 |
-``` |
|
24 |
- |
|
25 |
- |
|
26 |
-```{r echo=FALSE, results="hide", message=FALSE} |
|
27 |
-library("ape") |
|
28 |
-library("ggplot2") |
|
29 |
-library("ggtree") |
|
30 |
-``` |
|
31 |
- |
|
32 |
-# Layers that allows subsetting |
|
33 |
- |
|
34 |
-`Subsetting` is not supported in layers defined in `ggplot2`, while it is quite useful in phylogenetic annotation since it allows us to annotate at specific node(s). |
|
35 |
- |
|
36 |
-In `ggtree`, we provides modified version of layers defined in `ggplot2` to support `subsetting`, including: |
|
37 |
- |
|
38 |
-+ geom_segment2 |
|
39 |
-+ geom_point2 |
|
40 |
-+ geom_text2 |
|
41 |
-+ geom_label2 |
|
42 |
- |
|
43 |
-```{r fig.width=5, fig.height=5} |
|
44 |
-file <- system.file("extdata/BEAST", "beast_mcc.tree", package="treeio") |
|
45 |
-beast <- read.beast(file) |
|
46 |
-ggtree(beast) + geom_point2(aes(subset=!is.na(posterior) & posterior > 0.75), color='firebrick') |
|
47 |
-``` |
|
48 |
- |
|
49 |
-<!-- |
|
50 |
- |
|
51 |
-# Multiple graphs on one page |
|
52 |
- |
|
53 |
-To support viewing multiple plots, ggtree provides `multiplot` function that similar to `gridExtra::grid.arrange` with extra feature of labeling the plots. |
|
54 |
- |
|
55 |
- |
|
56 |
-#``` {r fig.width=8, fig.height=4, warning=FALSE} |
|
57 |
-multiplot(ggtree(rtree(30)), ggtree(rtree(40)), ncol=2, labels=c('A', 'B')) |
|
58 |
-#``` |
|
59 |
- |
|
60 |
-# subplots in ggplot object |
|
61 |
- |
|
62 |
-`ggtree` implemented a function, `subview`, that can add subplots on a ggplot2 object. |
|
63 |
- |
|
64 |
-#``` {r fig.width=8, fig.height=8, warning=F} |
|
65 |
-set.seed(2016-01-04) |
|
66 |
-tr <- rtree(30) |
|
67 |
-tr <- groupClade(tr, node=45) |
|
68 |
-p <- ggtree(tr, aes(color=group)) + geom_tippoint() |
|
69 |
-p1 <- p + geom_hilight(node=45) |
|
70 |
-p2 <- viewClade(p, node=45) + geom_tiplab() |
|
71 |
-subview(p2, p1+theme_transparent(), x=2.3, y=28.5) |
|
72 |
-#``` |
|
73 |
- |
|
74 |
-This is the backend of the [inset](advanceTreeAnnotation.html) function. |
|
75 |
- |
|
76 |
-This `subview` function works with any `ggplot` objects and it had successful applied to [plot pie graphs on map](http://stackoverflow.com/questions/10368180/plotting-pie-graphs-on-map-in-ggplot/32380396#32380396). |
|
77 |
- |
|
78 |
-#``` {r eval=FALSE} |
|
79 |
-library(ggtree) |
|
80 |
-dd <- data.frame(x=LETTERS[1:3], y=1:3) |
|
81 |
-pie <- ggplot(dd, aes(x=1, y, fill=x)) + geom_bar(stat="identity", width=1) + coord_polar(theta="y") + theme_inset() |
|
82 |
-x <- sample(2:9) |
|
83 |
-y <- sample(2:9) |
|
84 |
-width <- sample(seq(0.05, 0.15, length.out=length(x))) |
|
85 |
-height <- width |
|
86 |
-p <- ggplot(data=data.frame(x=c(0, 10), y=c(0, 10)), aes(x, y))+geom_blank() |
|
87 |
-for (i in seq_along(x)) { |
|
88 |
- p <- subview(p, pie, x[i], y[i], width[i], height[i]) |
|
89 |
- print(p) |
|
90 |
-} |
|
91 |
-#``` |
|
92 |
- |
|
93 |
- |
|
94 |
- |
... | ... |
@@ -48,16 +48,17 @@ beast <- read.beast(file) |
48 | 48 |
ggtree(beast) + geom_point2(aes(subset=!is.na(posterior) & posterior > 0.75), color='firebrick') |
49 | 49 |
``` |
50 | 50 |
|
51 |
+<!-- |
|
52 |
+ |
|
51 | 53 |
# Multiple graphs on one page |
52 | 54 |
|
53 | 55 |
To support viewing multiple plots, ggtree provides `multiplot` function that similar to `gridExtra::grid.arrange` with extra feature of labeling the plots. |
54 | 56 |
|
55 | 57 |
|
56 |
-``` {r fig.width=8, fig.height=4, warning=FALSE} |
|
58 |
+#``` {r fig.width=8, fig.height=4, warning=FALSE} |
|
57 | 59 |
multiplot(ggtree(rtree(30)), ggtree(rtree(40)), ncol=2, labels=c('A', 'B')) |
58 |
-``` |
|
60 |
+#``` |
|
59 | 61 |
|
60 |
-<!-- |
|
61 | 62 |
# subplots in ggplot object |
62 | 63 |
|
63 | 64 |
`ggtree` implemented a function, `subview`, that can add subplots on a ggplot2 object. |
... | ... |
@@ -53,15 +53,16 @@ ggtree(beast) + geom_point2(aes(subset=!is.na(posterior) & posterior > 0.75), co |
53 | 53 |
To support viewing multiple plots, ggtree provides `multiplot` function that similar to `gridExtra::grid.arrange` with extra feature of labeling the plots. |
54 | 54 |
|
55 | 55 |
|
56 |
-```{r fig.width=8, fig.height=4, warning=FALSE} |
|
56 |
+``` {r fig.width=8, fig.height=4, warning=FALSE} |
|
57 | 57 |
multiplot(ggtree(rtree(30)), ggtree(rtree(40)), ncol=2, labels=c('A', 'B')) |
58 | 58 |
``` |
59 | 59 |
|
60 |
+<!-- |
|
60 | 61 |
# subplots in ggplot object |
61 | 62 |
|
62 | 63 |
`ggtree` implemented a function, `subview`, that can add subplots on a ggplot2 object. |
63 | 64 |
|
64 |
-```{r fig.width=8, fig.height=8, warning=F} |
|
65 |
+#``` {r fig.width=8, fig.height=8, warning=F} |
|
65 | 66 |
set.seed(2016-01-04) |
66 | 67 |
tr <- rtree(30) |
67 | 68 |
tr <- groupClade(tr, node=45) |
... | ... |
@@ -69,13 +70,13 @@ p <- ggtree(tr, aes(color=group)) + geom_tippoint() |
69 | 70 |
p1 <- p + geom_hilight(node=45) |
70 | 71 |
p2 <- viewClade(p, node=45) + geom_tiplab() |
71 | 72 |
subview(p2, p1+theme_transparent(), x=2.3, y=28.5) |
72 |
-``` |
|
73 |
+#``` |
|
73 | 74 |
|
74 | 75 |
This is the backend of the [inset](advanceTreeAnnotation.html) function. |
75 | 76 |
|
76 | 77 |
This `subview` function works with any `ggplot` objects and it had successful applied to [plot pie graphs on map](http://stackoverflow.com/questions/10368180/plotting-pie-graphs-on-map-in-ggplot/32380396#32380396). |
77 | 78 |
|
78 |
-```{r eval=FALSE} |
|
79 |
+#``` {r eval=FALSE} |
|
79 | 80 |
library(ggtree) |
80 | 81 |
dd <- data.frame(x=LETTERS[1:3], y=1:3) |
81 | 82 |
pie <- ggplot(dd, aes(x=1, y, fill=x)) + geom_bar(stat="identity", width=1) + coord_polar(theta="y") + theme_inset() |
... | ... |
@@ -88,7 +89,8 @@ for (i in seq_along(x)) { |
88 | 89 |
p <- subview(p, pie, x[i], y[i], width[i], height[i]) |
89 | 90 |
print(p) |
90 | 91 |
} |
91 |
-``` |
|
92 |
+#``` |
|
92 | 93 |
 |
93 | 94 |
|
94 | 95 |
|
96 |
+--> |
... | ... |
@@ -6,7 +6,7 @@ author: "Guangchuang Yu and Tommy Tsan-Yuk Lam\\ |
6 | 6 |
date: "`r Sys.Date()`" |
7 | 7 |
bibliography: ggtree.bib |
8 | 8 |
csl: nature.csl |
9 |
-output: |
|
9 |
+output: |
|
10 | 10 |
prettydoc::html_pretty: |
11 | 11 |
toc: true |
12 | 12 |
theme: cayman |
... | ... |
@@ -33,7 +33,7 @@ library("ggtree") |
33 | 33 |
|
34 | 34 |
# Layers that allows subsetting |
35 | 35 |
|
36 |
-`Subsetting` is not supported in layers defined in `ggplot2`, while it is quite useful in phylogenetic annotation since it allows us to annotate at specific node(s). |
|
36 |
+`Subsetting` is not supported in layers defined in `ggplot2`, while it is quite useful in phylogenetic annotation since it allows us to annotate at specific node(s). |
|
37 | 37 |
|
38 | 38 |
In `ggtree`, we provides modified version of layers defined in `ggplot2` to support `subsetting`, including: |
39 | 39 |
|
... | ... |
@@ -43,7 +43,7 @@ In `ggtree`, we provides modified version of layers defined in `ggplot2` to supp |
43 | 43 |
+ geom_label2 |
44 | 44 |
|
45 | 45 |
```{r fig.width=5, fig.height=5} |
46 |
-file <- system.file("extdata/BEAST", "beast_mcc.tree", package="ggtree") |
|
46 |
+file <- system.file("extdata/BEAST", "beast_mcc.tree", package="treeio") |
|
47 | 47 |
beast <- read.beast(file) |
48 | 48 |
ggtree(beast) + geom_point2(aes(subset=!is.na(posterior) & posterior > 0.75), color='firebrick') |
49 | 49 |
``` |
... | ... |
@@ -59,7 +59,7 @@ multiplot(ggtree(rtree(30)), ggtree(rtree(40)), ncol=2, labels=c('A', 'B')) |
59 | 59 |
|
60 | 60 |
# subplots in ggplot object |
61 | 61 |
|
62 |
-`ggtree` implemented a function, `subview`, that can add subplots on a ggplot2 object. |
|
62 |
+`ggtree` implemented a function, `subview`, that can add subplots on a ggplot2 object. |
|
63 | 63 |
|
64 | 64 |
```{r fig.width=8, fig.height=8, warning=F} |
65 | 65 |
set.seed(2016-01-04) |
... | ... |
@@ -1,16 +1,16 @@ |
1 | 1 |
--- |
2 | 2 |
title: "ggtree utilities" |
3 |
-author: "\\ |
|
4 |
- |
|
5 |
- Guangchuang Yu (<guangchuangyu@gmail.com>) and Tommy Tsan-Yuk Lam (<ttylam@hku.hk>)\\ |
|
3 |
+author: "Guangchuang Yu and Tommy Tsan-Yuk Lam\\ |
|
6 | 4 |
|
7 | 5 |
School of Public Health, The University of Hong Kong" |
8 | 6 |
date: "`r Sys.Date()`" |
9 | 7 |
bibliography: ggtree.bib |
10 | 8 |
csl: nature.csl |
11 | 9 |
output: |
12 |
- html_document: |
|
10 |
+ prettydoc::html_pretty: |
|
13 | 11 |
toc: true |
12 |
+ theme: cayman |
|
13 |
+ highlight: github |
|
14 | 14 |
pdf_document: |
15 | 15 |
toc: true |
16 | 16 |
vignette: > |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@119674 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -57,7 +57,6 @@ To support viewing multiple plots, ggtree provides `multiplot` function that sim |
57 | 57 |
multiplot(ggtree(rtree(30)), ggtree(rtree(40)), ncol=2, labels=c('A', 'B')) |
58 | 58 |
``` |
59 | 59 |
|
60 |
- |
|
61 | 60 |
# subplots in ggplot object |
62 | 61 |
|
63 | 62 |
`ggtree` implemented a function, `subview`, that can add subplots on a ggplot2 object. |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@119673 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -31,7 +31,6 @@ library("ggplot2") |
31 | 31 |
library("ggtree") |
32 | 32 |
``` |
33 | 33 |
|
34 |
- |
|
35 | 34 |
# Layers that allows subsetting |
36 | 35 |
|
37 | 36 |
`Subsetting` is not supported in layers defined in `ggplot2`, while it is quite useful in phylogenetic annotation since it allows us to annotate at specific node(s). |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@117330 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -77,7 +77,7 @@ This is the backend of the [inset](advanceTreeAnnotation.html) function. |
77 | 77 |
|
78 | 78 |
This `subview` function works with any `ggplot` objects and it had successful applied to [plot pie graphs on map](http://stackoverflow.com/questions/10368180/plotting-pie-graphs-on-map-in-ggplot/32380396#32380396). |
79 | 79 |
|
80 |
-```{r fig.show='animate', interval=.1} |
|
80 |
+```{r eval=FALSE} |
|
81 | 81 |
library(ggtree) |
82 | 82 |
dd <- data.frame(x=LETTERS[1:3], y=1:3) |
83 | 83 |
pie <- ggplot(dd, aes(x=1, y, fill=x)) + geom_bar(stat="identity", width=1) + coord_polar(theta="y") + theme_inset() |
... | ... |
@@ -91,5 +91,6 @@ for (i in seq_along(x)) { |
91 | 91 |
print(p) |
92 | 92 |
} |
93 | 93 |
``` |
94 |
+ |
|
94 | 95 |
|
95 | 96 |
|
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@117326 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -14,7 +14,7 @@ output: |
14 | 14 |
pdf_document: |
15 | 15 |
toc: true |
16 | 16 |
vignette: > |
17 |
- %\VignetteIndexEntry{00 ggtree introduction} |
|
17 |
+ %\VignetteIndexEntry{06 ggtree utilities} |
|
18 | 18 |
%\VignetteEngine{knitr::rmarkdown} |
19 | 19 |
%\usepackage[utf8]{inputenc} |
20 | 20 |
--- |
... | ... |
@@ -49,6 +49,16 @@ beast <- read.beast(file) |
49 | 49 |
ggtree(beast) + geom_point2(aes(subset=!is.na(posterior) & posterior > 0.75), color='firebrick') |
50 | 50 |
``` |
51 | 51 |
|
52 |
+# Multiple graphs on one page |
|
53 |
+ |
|
54 |
+To support viewing multiple plots, ggtree provides `multiplot` function that similar to `gridExtra::grid.arrange` with extra feature of labeling the plots. |
|
55 |
+ |
|
56 |
+ |
|
57 |
+```{r fig.width=8, fig.height=4, warning=FALSE} |
|
58 |
+multiplot(ggtree(rtree(30)), ggtree(rtree(40)), ncol=2, labels=c('A', 'B')) |
|
59 |
+``` |
|
60 |
+ |
|
61 |
+ |
|
52 | 62 |
# subplots in ggplot object |
53 | 63 |
|
54 | 64 |
`ggtree` implemented a function, `subview`, that can add subplots on a ggplot2 object. |
git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ggtree@117266 bc3139a8-67e5-0310-9ffc-ced21a209358
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,85 @@ |
1 |
+--- |
|
2 |
+title: "ggtree utilities" |
|
3 |
+author: "\\ |
|
4 |
+ |
|
5 |
+ Guangchuang Yu (<guangchuangyu@gmail.com>) and Tommy Tsan-Yuk Lam (<ttylam@hku.hk>)\\ |
|
6 |
+ |
|
7 |
+ School of Public Health, The University of Hong Kong" |
|
8 |
+date: "`r Sys.Date()`" |
|
9 |
+bibliography: ggtree.bib |
|
10 |
+csl: nature.csl |
|
11 |
+output: |
|
12 |
+ html_document: |
|
13 |
+ toc: true |
|
14 |
+ pdf_document: |
|
15 |
+ toc: true |
|
16 |
+vignette: > |
|
17 |
+ %\VignetteIndexEntry{00 ggtree introduction} |
|
18 |
+ %\VignetteEngine{knitr::rmarkdown} |
|
19 |
+ %\usepackage[utf8]{inputenc} |
|
20 |
+--- |
|
21 |
+ |
|
22 |
+```{r style, echo=FALSE, results="asis", message=FALSE} |
|
23 |
+knitr::opts_chunk$set(tidy = FALSE, |
|
24 |
+ message = FALSE) |
|
25 |
+``` |
|
26 |
+ |
|
27 |
+ |
|
28 |
+```{r echo=FALSE, results="hide", message=FALSE} |
|
29 |
+library("ape") |
|
30 |
+library("ggplot2") |
|
31 |
+library("ggtree") |
|
32 |
+``` |
|
33 |
+ |
|
34 |
+ |
|
35 |
+# Layers that allows subsetting |
|
36 |
+ |
|
37 |
+`Subsetting` is not supported in layers defined in `ggplot2`, while it is quite useful in phylogenetic annotation since it allows us to annotate at specific node(s). |
|
38 |
+ |
|
39 |
+In `ggtree`, we provides modified version of layers defined in `ggplot2` to support `subsetting`, including: |
|
40 |
+ |
|
41 |
++ geom_segment2 |
|
42 |
++ geom_point2 |
|
43 |
++ geom_text2 |
|
44 |
++ geom_label2 |
|
45 |
+ |
|
46 |
+```{r fig.width=5, fig.height=5} |
|
47 |
+file <- system.file("extdata/BEAST", "beast_mcc.tree", package="ggtree") |
|
48 |
+beast <- read.beast(file) |
|
49 |
+ggtree(beast) + geom_point2(aes(subset=!is.na(posterior) & posterior > 0.75), color='firebrick') |
|
50 |
+``` |
|
51 |
+ |
|
52 |
+# subplots in ggplot object |
|
53 |
+ |
|
54 |
+`ggtree` implemented a function, `subview`, that can add subplots on a ggplot2 object. |
|
55 |
+ |
|
56 |
+```{r fig.width=8, fig.height=8, warning=F} |
|
57 |
+set.seed(2016-01-04) |
|
58 |
+tr <- rtree(30) |
|
59 |
+tr <- groupClade(tr, node=45) |
|
60 |
+p <- ggtree(tr, aes(color=group)) + geom_tippoint() |
|
61 |
+p1 <- p + geom_hilight(node=45) |
|
62 |
+p2 <- viewClade(p, node=45) + geom_tiplab() |
|
63 |
+subview(p2, p1+theme_transparent(), x=2.3, y=28.5) |
|
64 |
+``` |
|
65 |
+ |
|
66 |
+This is the backend of the [inset](advanceTreeAnnotation.html) function. |
|
67 |
+ |
|
68 |
+This `subview` function works with any `ggplot` objects and it had successful applied to [plot pie graphs on map](http://stackoverflow.com/questions/10368180/plotting-pie-graphs-on-map-in-ggplot/32380396#32380396). |
|
69 |
+ |
|
70 |
+```{r fig.show='animate', interval=.1} |
|
71 |
+library(ggtree) |
|
72 |
+dd <- data.frame(x=LETTERS[1:3], y=1:3) |
|
73 |
+pie <- ggplot(dd, aes(x=1, y, fill=x)) + geom_bar(stat="identity", width=1) + coord_polar(theta="y") + theme_inset() |
|
74 |
+x <- sample(2:9) |
|
75 |
+y <- sample(2:9) |
|
76 |
+width <- sample(seq(0.05, 0.15, length.out=length(x))) |
|
77 |
+height <- width |
|
78 |
+p <- ggplot(data=data.frame(x=c(0, 10), y=c(0, 10)), aes(x, y))+geom_blank() |
|
79 |
+for (i in seq_along(x)) { |
|
80 |
+ p <- subview(p, pie, x[i], y[i], width[i], height[i]) |
|
81 |
+ print(p) |
|
82 |
+} |
|
83 |
+``` |
|
84 |
+ |
|
85 |
+ |