Created
January 3, 2019 06:32
-
-
Save kopperud/ae8cca0c29927d1d51fe08fd74cdb90a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ape) | |
library(ggtree) ## Ggtree is on github, devtools::install_github("GuangchuangYu/ggtree") | |
library(ggplot2) | |
library(gridExtra) | |
## Random tree | |
set.seed(5) | |
phy <- rtree(15) | |
## No transformation | |
p1 <- ggtree(phy, ladderize = TRUE) + theme_tree2() + geom_tiplab() + ggtitle("No transform") | |
## Manipulate the plotting coordinates, square transform | |
p2 <- ggtree(phy, ladderize = TRUE) + | |
theme_tree2() + | |
geom_tiplab() + scale_x_continuous(labels = function(x) sqrt(x), breaks = seq(0, 4)^2) + ## Backtransform the axis labels, and add appropriate breaks | |
ggtitle("Square transform") | |
p2$data$x <- p2$data$x ^2 | |
## Exponential instead | |
p3 <- ggtree(phy, ladderize = TRUE) + | |
theme_tree2() + | |
geom_tiplab() + | |
scale_x_continuous(labels = function(x) log(x), breaks = exp(seq(0, 4))) + | |
ggtitle("Exponential transform") | |
p3$data$x <- exp(p3$data$x) | |
grid.arrange(p1, p2, p3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how about something like: