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_strip has issues with label and angle="auto" #629

Open
Thomas-Hagan opened this issue Sep 12, 2024 · 0 comments
Open

geom_strip has issues with label and angle="auto" #629

Thomas-Hagan opened this issue Sep 12, 2024 · 0 comments

Comments

@Thomas-Hagan
Copy link

Thomas-Hagan commented Sep 12, 2024

I am having issues labeling a paraphyletic clade using geom_strip. I want to have the label of the clade rotate with the position of the strip, as is possible in geom_cladelab by using angle = "auto". This is supposed to be possible in geom_strip also, but currently produces an error message.

Reproducible Example

library(ggplot2)
library(ggtree)

tree = rtree(10, rooted = TRUE, tip.label = C(1:10))
test = ggtree(tree, layout = "circular", branch.length = "none",
             ladderize = TRUE, size = .8) + 
  theme(legend.position = c(0, .82),
        legend.text = element_text(size = 8),
        legend.title = element_text(size = 8)) +
  theme(plot.margin=unit(c(.1,1.5,.1,0),"cm")) +
  geom_strip(1, 2, label = "Test Label", color = "red", angle = "auto",
             horizontal = FALSE, barsize = 2, offset.text = 1.75, hjust = .5, offset = 2, fontsize = 5)
test

test2 = ggtree(tree, layout = "circular", branch.length = "none",
              ladderize = TRUE, size = .8) + 
  theme(legend.position = c(0, .82),
        legend.text = element_text(size = 8),
        legend.title = element_text(size = 8)) +
  theme(plot.margin=unit(c(.1,1.5,.1,0),"cm")) +
  geom_strip(1, 2, label = "Test Label", color = "red",
             horizontal = FALSE, barsize = 2, offset.text = 1.75, hjust = .5, offset = 2, fontsize = 5)
test2

The object test2 produces a normal phylogeny with a labeled clade (paraphyletic or otherwise), however the object test produces the following error message:

Error in `geom_text()`:
! Problem while converting geom to grob.
ℹ Error occurred in the 4th layer.
Caused by error in `validDetails.text()`:
! invalid 'rot' value
Run `rlang::last_trace()` to see where the error occurred.
Warning message:
In validDetails.text(x) : NAs introduced by coercion

This can be fixed in post if necessary, but ideally I would like this to be fixed during the initial object production.

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

1 participant