Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: remove gap in heatmap annotation of circular tree #204

Closed
Ekie22 opened this issue Oct 16, 2018 · 1 comment
Closed

Suggestion: remove gap in heatmap annotation of circular tree #204

Ekie22 opened this issue Oct 16, 2018 · 1 comment

Comments

@Ekie22
Copy link

Ekie22 commented Oct 16, 2018

When circular trees are annotated with the gheatmap function the colnames of the associated data are plotted by default in a gap of the annotation ring. With colnames = FALSE it is possible to prevent showing the titles but the gap remains (see plot p1). If one wants to generate a closed annotation ring “+ scale_y_continuous(expand = c(0,0))” has to be applied (p2). I assume the gap it is caused by the ggplot::geom_tile behaviour which adds some space at the ends of the plot but (as I can say from experience) it takes some time to find the solution. Would it be possible for you to change your gheatmap function in such way, that “+ scale_y_continuous(expand = c(0,0))” is directly applied if colnames = FALSE.
Thanks

Examples:

library("ggplot2")
library("ggtree") # version 1.13.6
library("dplyr")

## load example tree from package
nwk <- system.file("extdata", "sample.nwk", package="treeio")
tree <- read.tree(nwk)

##  circular tree
circ <- ggtree(tree, layout = "circular") +
  geom_tiplab(size=3, color="black", align=TRUE, offset = 1)

##  external data which should be attached
df <- data.frame(habitat=c("a", "b", "a", "c", "d", "d", "a", "b", "e", "e", "f", "c", "f"))
row.names(df) <- pull(circ$data[circ$data$isTip=="TRUE", "label"])

##  circular tree with heatmap without colname but remaining gap
p1 <- gheatmap(circ, df[,"habitat", drop=FALSE], offset = 0.8, width=0.1,
               colnames = FALSE) 
p1

##  circular tree with heatmap without gap
p2 <- gheatmap(circ, df[,"habitat", drop=FALSE], offset = 0.8, width=0.1,
               colnames = FALSE) +
  ##  close gap 
  scale_y_continuous(expand = c(0,0))
p2
 
@GuangchuangYu
Copy link
Member

GuangchuangYu commented Oct 17, 2018

thanks, this is due to setting ylim for preventing overlapping of branches, see #6.

suggestion accepted, 919f823.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants