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

geom_hilight #621

Open
8 tasks
drdna opened this issue Jul 9, 2024 · 3 comments
Open
8 tasks

geom_hilight #621

drdna opened this issue Jul 9, 2024 · 3 comments

Comments

@drdna
Copy link

drdna commented Jul 9, 2024

Prerequisites

  • Have you read Feedback and follow the guide?
    • make sure your are using the latest release version
    • read the documents
    • google your question/issue

Describe you issue

  • Make a reproducible example (e.g. 1)
  • your code should contain comments to describe the problem (e.g. what expected and actually happened?)

Ask in right place

  • for bugs or feature requests, post here (github issue)
  • for questions, please post to google group
@drdna
Copy link
Author

drdna commented Jul 9, 2024

Ideally geom-hilights should automatically be placed behind all tree features by default.

@brj1
Copy link
Contributor

brj1 commented Jul 9, 2024

You can put the hilight geoms behind the tree by adding the hilight geom first and then the tree geom.

# example tree and data
nwk <- system.file("extdata", "sample.nwk", package="treeio")
tree <- read.tree(nwk)
d <- data.frame(17, 21), type=c("A", "B"))

# geom_hilight last
ggtree(tree) + geom_hilight(data=d, aes(node=node, fill=type),
                            type = "roundrect", alpha = 1)

# geom_hilight first
ggplot(tree) + geom_hilight(data=d, aes(node=node, fill=type),
                            type = "roundrect", alpha = 1) + geom_tree() + theme_tree()

@drdna
Copy link
Author

drdna commented Jul 9, 2024

Thanks Brad, that’s what I did to solve the issue. However, it seems to me that a geom_hilight call (if possible) ought to put the feature in the background by default. In my experience, calling ggtree with no arguments is problematic because many of its arguments don’t work in geom_tree. For example, layout doesn't appear to work in geom_tree, so I am unable to generate anything but a rectangular tree using this workaround.

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