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

geoms with their own data don't work with ggtree #4

Closed
markscherz opened this issue Jan 21, 2019 · 4 comments
Closed

geoms with their own data don't work with ggtree #4

markscherz opened this issue Jan 21, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@markscherz
Copy link

Had everything working beautifully a few days ago, now I go to try to run the script and something is not working.

>tree<-pbtree(n=16,tip.label=LETTERS[1:16],scale=20)
>p <- ggtree(tree, size = 0.3) + 
  coord_cartesian(xlim = c(15,-30), ylim = c(-40,Ntip(tree)), expand = FALSE) +
  scale_x_continuous(breaks=seq(-30,0,10), labels=abs(seq(-30,0,10))) +
  geom_tiplab(cex = 0.7) +
  theme_tree2()
>p <- revts(p)
>p <- gggeo_scale(p, height = .03, abbrv = FALSE, neg = TRUE)
Ignoring unknown aesthetics: fill_geo_scale
>p
Error in FUN(X[[i]], ...) : object 'y' not found

Traceback yields

10. FUN(X[[i]], ...) 
9. lapply(aesthetics, rlang::eval_tidy, data = data) 
8. f(..., self = self) 
7. l$compute_aesthetics(d, plot) 
6. f(l = layers[[i]], d = data[[i]]) 
5. by_layer(function(l, d) l$compute_aesthetics(d, plot)) 
4. ggplot_build.ggplot(x) 
3. ggplot_build(x) 
2. print.ggplot(x) 
1. function (x, ...) UseMethod("print")(x)

So my guess is that it is failing because it is not able to find fill_geo_scale.
Curiously, in a second script, the error is "object 'x' not found", but I presume it is caused by the same problem.

@willgearty
Copy link
Owner

willgearty commented Jan 21, 2019

Hmm...when I run your code line for line, I get Error in FUN(X[[i]], ...) : object 'x' not found, as you do for your other script.
I've tried the code without the new "fill_geo_scale", and I'm still getting the same error:

> tree<-pbtree(n=16,tip.label=LETTERS[1:16],scale=20)
> p <- ggtree(tree, size = 0.3) + 
  coord_cartesian(xlim = c(15,-30), ylim = c(-40,Ntip(tree)), expand = FALSE) +
  scale_x_continuous(breaks=seq(-30,0,10), labels=abs(seq(-30,0,10))) +
  geom_tiplab(cex = 0.7) +
  theme_tree2()
> p <- revts(p)
> p + geom_rect(data = periods, aes(xmin = min_age, xmax = max_age), ymin = 0, ymax = 5, show.legend = FALSE)
Error in FUN(X[[i]], ...) : object 'x' not found

I'm gonna loop @GuangchuangYu in here, since this only appears to be a problem when adding the scale to ggtree objects.
Before the most recent update, the rectangles and labels were added as annotations, but now they are added as geoms, so that is the only change that could have caused the new issue. My best guess is that there's a conflict between the data used by ggtree and the data supplied by my package? Especially since the following works:

> p + geom_rect(xmin = -5, xmax = 0, ymin = -5, ymax = 0, show.legend = FALSE)

@markscherz
Copy link
Author

That sounds possible. ggtree was having some really bad problems interacting with phytools over the last few days as well. I have repeatedly had to clear my environment and clean-sheet to get my other scripts working.

@willgearty
Copy link
Owner

willgearty commented Jan 21, 2019

@markscherz, until this is resolved you should be able to use the old version of deeptime (before the most recent changes) using the following:
install_github("willgearty/deeptime", ref = "37a00cd")
(I just checked and this works for your example)

@willgearty willgearty changed the title Aesthetic fill_geo_scale missing geoms with their own data don't work with ggtree Jan 21, 2019
@willgearty willgearty added the bug Something isn't working label Jan 21, 2019
@markscherz
Copy link
Author

@willgearty excellent, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants