rootShifter <- function(x, shift) { lab <- round(x + as.numeric(shift), 2)}+ scale_x_continuous(label = function(x) { rootShifter(x, shift) })you need to provide a reproducible example, as I mentioned here, https://guangchuangyu.github.io/2016/07/how-to-bug-author/.
basically, gheatmap is not implemented by grid.arrange which have problem of aligning two ggplot objects like the first figure you showed here.
--
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree+unsubscribe@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/dcc2bb56-d75e-4c0a-b130-65e8dbd257cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
library(ggplot2)
library(ggtree)
library(dplyr)
# data preparationtxt <- "(C: 2, (A: 1, B:1): 1);"df <- matrix(rnorm(9), nrow = 3) %>% as.data.frame()rownames(df) <- c("A", "B", "C")
# an original tree with gheatmap is rooted in zero
((ggtree(read.tree(text = txt)) + geom_tiplab(align = TRUE) + theme_tree2()) %>% gheatmap(df, offset = 0, width = 0.5, colnames = FALSE)) %>% scale_x_ggtree()
rootShifter <- function(x, shift) { lab <- round(x + as.numeric(shift), 2)
}
shift <- 2
(ggtree(read.tree(text = txt)) + geom_tiplab(align = TRUE) + theme_tree2()) %>% gheatmap(df, offset = 0, width = 0.5, colnames = FALSE) +library(ape)shift <- 2breaksAndLabelsCalc <- function(tr, shift, gridLength) { trHeight <- max(node.depth.edgelength(tr)) br <- seq(0, trHeight, trHeight / gridLength) return( list( breaks = br, labels = as.character(round(br + shift), 2) ) )}
tree <- read.tree(text = txt)brLab <- breaksAndLabelsCalc(tree, shift, 6)
((ggtree(tree) + geom_tiplab(align = TRUE) + theme_tree2()) %>% gheatmap(df, offset = 0, width = 0.5, colnames = FALSE)) %>% scale_x_ggtree(breaks = brLab$breaks, labels = brLab$labels)
p = ggtree(read.tree(text = txt)) + geom_tiplab(align = TRUE) + theme_tree2()
p$data$x = p$data$x +2
p %>%
gheatmap(df, offset = 0, width = 0.5, colnames = FALSE) %>%
scale_x_ggtree()
--
You received this message because you are subscribed to the Google Groups "ggtree" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree+unsubscribe@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/8a2300dc-293d-49ed-82ae-ece18cae7ab3%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to bioc-ggtree...@googlegroups.com.
To post to this group, send email to bioc-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bioc-ggtree/8a2300dc-293d-49ed-82ae-ece18cae7ab3%40googlegroups.com.