0

I'm trying to represent a phylogenetic tree with the following code.

ggtree(tree2, layout="circular", size=0.03)+
  geom_tiplab2(aes(label=), align=T, size=0.5, hjust=0.1)

but I get the following error:

Error in `geom_segment2()`:
! Problem while converting geom to grob.
i Error occurred in the 3rd layer.
Caused by error in `check.length()`:
! 'gpar' element 'lwd' must not be length 0
Run `rlang::last_trace()` to see where the error occurred.

When I Run rlang::last_trace() I get this, which honestly I don't know what it means:

Backtrace:
     x
  1. +-base (local) `<fn>`(x)
  2. +-ggplot2:::print.ggplot(x)
  3. | +-ggplot2::ggplot_gtable(data)
  4. | \-ggplot2:::ggplot_gtable.ggplot_built(data)
  5. |   \-ggplot2:::by_layer(...)
  6. |     +-rlang::try_fetch(...)
  7. |     | +-base::tryCatch(...)
  8. |     | | \-base (local) tryCatchList(expr, classes, parentenv, handlers)
  9. |     | |   \-base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 10. |     | |     \-base (local) doTryCatch(return(expr), name, parentenv, handler)
 11. |     | \-base::withCallingHandlers(...)
 12. |     \-ggplot2 (local) f(l = layers[[i]], d = data[[i]])
 13. |       \-l$draw_geom(d, layout)
 14. |         \-ggplot2 (local) draw_geom(..., self = self)
 15. |           \-self$geom$draw_layer(...)
 16. |             \-ggplot2 (local) draw_layer(..., self = self)
 17. |               \-base::lapply(...)
 18. |                 \-ggplot2 (local) FUN(X[[i]], ...)
 19. |                   +-rlang::inject(self$draw_panel(data, panel_params, coord, !!!params))
 20. |                   \-self$draw_panel(...)
 21. |                     \-ggtree (local) draw_panel(...)
 22. |                       +-grid::segmentsGrob(...)
 23. |                       | \-grid::grob(...)
 24. |                       \-grid::gpar(...)
 25. |                         \-grid:::validGP(list(...))
 26. |                           \-grid (local) numnotnull("lwd")
 27. |                             \-grid (local) check.length(gparname)
 28. |                               \-base::stop(...)
 29. \-base::.handleSimpleError(...)
 30.   \-rlang (local) h(simpleError(msg, call))
 31.     \-handlers[[1L]](cnd)
 32.       \-cli::cli_abort(...)
 33.         \-rlang::abort(...)

I tried putting different values of linetype, linesize and lwd in geom_tiplab2 but I always get the same error. It only worked when I put linetype=NA , but then I have no lines conecting the tips of the tree to their corresponding name, and there are a lot of tips so it is quite hard to see which one is which then (having too many sequences is not the problem, I tried with a reduced tree and got the same error). Does someone know what could be the problem?

user438383
  • 5,716
  • 8
  • 28
  • 43
fuseros
  • 17
  • 5

0 Answers0