Skip to content

geom_tiplab(geom = "image") is broken #679

@joelnitta

Description

@joelnitta

Some recent change has broken geom_tiplab when using geom="image".

Here it is working in an older version of ggtree (v3.17.1.001, cdd5401):

library(ggimage)
#> Loading required package: ggplot2
library(ggtree)
#> ggtree v3.17.1.001 Learn more at https://yulab-smu.top/contribution-tree-data/
#> 
#> Please cite:
#> 
#> Guangchuang Yu, Tommy Tsan-Yuk Lam, Huachen Zhu, Yi Guan. Two methods
#> for mapping and visualizing associated data on phylogeny using ggtree.
#> Molecular Biology and Evolution. 2018, 35(12):3041-3043.
#> doi:10.1093/molbev/msy194
library(TDbook)

nwk <- paste0("((((bufonidae, dendrobatidae), ceratophryidae),",
          "(centrolenidae, leptodactylidae)), hylidae);")

imgdir <- system.file("extdata/frogs", package = "TDbook")

x = read.tree(text = nwk)

dat <- tibble::tibble(
  tip = "bufonidae",
  image = paste0(imgdir, "/bufonidae.jpg")
)

ggtree(x)  %<+%
  dat +
  geom_tiplab(aes(image = image), geom = "image")
#> Warning: `aes_()` was deprecated in ggplot2 3.0.0.
#> ℹ Please use tidy evaluation idioms with `aes()`
#> ℹ The deprecated feature was likely used in the ggtree package.
#>   Please report the issue at <https://github.com/YuLab-SMU/ggtree/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning in fortify(data, ...): Arguments in `...` must be used.
#> ✖ Problematic arguments:
#> • as.Date = as.Date
#> • yscale_mapping = yscale_mapping
#> • branch.length = branch.length
#> • hang = hang
#> ℹ Did you misspell an argument name?
#> Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
#> ℹ Please use tidy evaluation idioms with `aes()`.
#> ℹ See also `vignette("ggplot2-in-packages")` for more information.
#> ℹ The deprecated feature was likely used in the ggtree package.
#>   Please report the issue at <https://github.com/YuLab-SMU/ggtree/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: Removed 5 rows containing missing values or values outside the scale range
#> (`geom_image()`).

Created on 2025-10-31 with reprex v2.1.1

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.0 (2025-04-11)
#>  os       macOS Sonoma 14.6.1
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Asia/Tokyo
#>  date     2025-10-31
#>  pandoc   3.1.2 @ /usr/local/bin/ (via rmarkdown)
#>  quarto   1.6.39 @ /Applications/quarto/bin/quarto
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package      * version    date (UTC) lib source
#>  ape            5.8-1      2024-12-16 [1] CRAN (R 4.5.0)
#>  aplot          0.2.8      2025-07-02 [1] CRAN (R 4.5.0)
#>  cli            3.6.5      2025-04-23 [1] CRAN (R 4.5.0)
#>  crayon         1.5.3      2024-06-20 [1] CRAN (R 4.5.0)
#>  curl           7.0.0      2025-08-19 [1] CRAN (R 4.5.0)
#>  digest         0.6.37     2024-08-19 [1] CRAN (R 4.5.0)
#>  dplyr          1.1.4      2023-11-17 [1] CRAN (R 4.5.0)
#>  evaluate       1.0.3      2025-01-10 [1] CRAN (R 4.5.0)
#>  farver         2.1.2      2024-05-13 [1] CRAN (R 4.5.0)
#>  fastmap        1.2.0      2024-05-15 [1] CRAN (R 4.5.0)
#>  fs             1.6.6      2025-04-12 [1] CRAN (R 4.5.0)
#>  generics       0.1.4      2025-05-09 [1] CRAN (R 4.5.0)
#>  ggfun          0.2.0      2025-07-15 [1] CRAN (R 4.5.0)
#>  ggimage      * 0.3.3      2023-06-19 [1] CRAN (R 4.5.0)
#>  ggplot2      * 4.0.0      2025-09-11 [1] CRAN (R 4.5.0)
#>  ggplotify      0.1.2      2023-08-09 [1] CRAN (R 4.5.0)
#>  ggtree       * 3.17.1.001 2025-10-31 [1] Github (YuLab-SMU/ggtree@cdd5401)
#>  glue           1.8.0      2024-09-30 [1] CRAN (R 4.5.0)
#>  gridGraphics   0.5-1      2020-12-13 [1] CRAN (R 4.5.0)
#>  gtable         0.3.6      2024-10-25 [1] CRAN (R 4.5.0)
#>  htmltools      0.5.8.1    2024-04-04 [1] CRAN (R 4.5.0)
#>  jsonlite       2.0.0      2025-03-27 [1] CRAN (R 4.5.0)
#>  knitr          1.50       2025-03-16 [1] CRAN (R 4.5.0)
#>  labeling       0.4.3      2023-08-29 [1] CRAN (R 4.5.0)
#>  lattice        0.22-6     2024-03-20 [1] CRAN (R 4.5.0)
#>  lazyeval       0.2.2      2019-03-15 [1] CRAN (R 4.5.0)
#>  lifecycle      1.0.4      2023-11-07 [1] CRAN (R 4.5.0)
#>  magick         2.8.7      2025-06-06 [1] CRAN (R 4.5.0)
#>  magrittr       2.0.3      2022-03-30 [1] CRAN (R 4.5.0)
#>  nlme           3.1-168    2025-03-31 [1] CRAN (R 4.5.0)
#>  patchwork      1.3.1      2025-06-21 [1] CRAN (R 4.5.0)
#>  pillar         1.11.0     2025-07-04 [1] CRAN (R 4.5.0)
#>  pkgconfig      2.0.3      2019-09-22 [1] CRAN (R 4.5.0)
#>  purrr          1.1.0      2025-07-10 [1] CRAN (R 4.5.0)
#>  R6             2.6.1      2025-02-15 [1] CRAN (R 4.5.0)
#>  RColorBrewer   1.1-3      2022-04-03 [1] CRAN (R 4.5.0)
#>  Rcpp           1.1.0      2025-07-02 [1] CRAN (R 4.5.0)
#>  reprex         2.1.1      2024-07-06 [1] CRAN (R 4.5.0)
#>  rlang          1.1.6      2025-04-11 [1] CRAN (R 4.5.0)
#>  rmarkdown      2.29       2024-11-04 [1] CRAN (R 4.5.0)
#>  S7             0.2.0      2024-11-07 [1] CRAN (R 4.5.0)
#>  scales         1.4.0      2025-04-24 [1] CRAN (R 4.5.0)
#>  sessioninfo    1.2.3      2025-02-05 [1] CRAN (R 4.5.0)
#>  TDbook       * 0.0.6      2022-08-13 [1] CRAN (R 4.5.0)
#>  tibble         3.3.0      2025-06-08 [1] CRAN (R 4.5.0)
#>  tidyr          1.3.1      2024-01-24 [1] CRAN (R 4.5.0)
#>  tidyselect     1.2.1      2024-03-11 [1] CRAN (R 4.5.0)
#>  tidytree       0.4.6      2023-12-12 [1] CRAN (R 4.5.0)
#>  treeio         1.32.0     2025-04-15 [1] Bioconduc~
#>  vctrs          0.6.5      2023-12-01 [1] CRAN (R 4.5.0)
#>  withr          3.0.2      2024-10-28 [1] CRAN (R 4.5.0)
#>  xfun           0.52       2025-04-02 [1] CRAN (R 4.5.0)
#>  xml2           1.3.8      2025-03-14 [1] CRAN (R 4.5.0)
#>  yaml           2.3.10     2024-07-26 [1] CRAN (R 4.5.0)
#>  yulab.utils    0.2.0      2025-01-29 [1] CRAN (R 4.5.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
#>  * ── Packages attached to the search path.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

But in the most recent commit (v4.1.1, 57a3e6b), the same code fails:

library(ggimage)
#> Loading required package: ggplot2
library(ggtree)
#> ggtree v4.1.1 Learn more at https://yulab-smu.top/contribution-tree-data/
#> 
#> Please cite:
#> 
#> Guangchuang Yu, David Smith, Huachen Zhu, Yi Guan, Tommy Tsan-Yuk Lam.
#> ggtree: an R package for visualization and annotation of phylogenetic
#> trees with their covariates and other associated data. Methods in
#> Ecology and Evolution. 2017, 8(1):28-36. doi:10.1111/2041-210X.12628
library(TDbook)

nwk <- paste0("((((bufonidae, dendrobatidae), ceratophryidae),",
          "(centrolenidae, leptodactylidae)), hylidae);")

imgdir <- system.file("extdata/frogs", package = "TDbook")

x = read.tree(text = nwk)

dat <- tibble::tibble(
  tip = "bufonidae",
  image = paste0(imgdir, "/bufonidae.jpg")
)

ggtree(x)  %<+%
  dat +
  geom_tiplab(aes(image = image), geom = "image")
#> Error in get(x, envir = ns, inherits = FALSE): object 'geom_image_interactive' not found

Created on 2025-10-31 with reprex v2.1.1

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.5.0 (2025-04-11)
#>  os       macOS Sonoma 14.6.1
#>  system   aarch64, darwin20
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Asia/Tokyo
#>  date     2025-10-31
#>  pandoc   3.1.2 @ /usr/local/bin/ (via rmarkdown)
#>  quarto   1.6.39 @ /Applications/quarto/bin/quarto
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package           * version date (UTC) lib source
#>  ape                 5.8-1   2024-12-16 [1] CRAN (R 4.5.0)
#>  aplot               0.2.8   2025-07-02 [1] CRAN (R 4.5.0)
#>  cli                 3.6.5   2025-04-23 [1] CRAN (R 4.5.0)
#>  digest              0.6.37  2024-08-19 [1] CRAN (R 4.5.0)
#>  dplyr               1.1.4   2023-11-17 [1] CRAN (R 4.5.0)
#>  evaluate            1.0.3   2025-01-10 [1] CRAN (R 4.5.0)
#>  farver              2.1.2   2024-05-13 [1] CRAN (R 4.5.0)
#>  fastmap             1.2.0   2024-05-15 [1] CRAN (R 4.5.0)
#>  fontBitstreamVera   0.1.1   2017-02-01 [1] CRAN (R 4.5.0)
#>  fontLiberation      0.1.0   2016-10-15 [1] CRAN (R 4.5.0)
#>  fontquiver          0.2.1   2017-02-01 [1] CRAN (R 4.5.0)
#>  fs                  1.6.6   2025-04-12 [1] CRAN (R 4.5.0)
#>  gdtools             0.4.4   2025-10-06 [1] CRAN (R 4.5.0)
#>  generics            0.1.4   2025-05-09 [1] CRAN (R 4.5.0)
#>  ggfun               0.2.0   2025-07-15 [1] CRAN (R 4.5.0)
#>  ggimage           * 0.3.3   2023-06-19 [1] CRAN (R 4.5.0)
#>  ggiraph             0.9.2   2025-10-07 [1] CRAN (R 4.5.0)
#>  ggplot2           * 4.0.0   2025-09-11 [1] CRAN (R 4.5.0)
#>  ggplotify           0.1.2   2023-08-09 [1] CRAN (R 4.5.0)
#>  ggtree            * 4.1.1   2025-10-31 [1] Github (YuLab-SMU/ggtree@57a3e6b)
#>  glue                1.8.0   2024-09-30 [1] CRAN (R 4.5.0)
#>  gridGraphics        0.5-1   2020-12-13 [1] CRAN (R 4.5.0)
#>  gtable              0.3.6   2024-10-25 [1] CRAN (R 4.5.0)
#>  htmltools           0.5.8.1 2024-04-04 [1] CRAN (R 4.5.0)
#>  htmlwidgets         1.6.4   2023-12-06 [1] CRAN (R 4.5.0)
#>  jsonlite            2.0.0   2025-03-27 [1] CRAN (R 4.5.0)
#>  knitr               1.50    2025-03-16 [1] CRAN (R 4.5.0)
#>  lattice             0.22-6  2024-03-20 [1] CRAN (R 4.5.0)
#>  lazyeval            0.2.2   2019-03-15 [1] CRAN (R 4.5.0)
#>  lifecycle           1.0.4   2023-11-07 [1] CRAN (R 4.5.0)
#>  magick              2.8.7   2025-06-06 [1] CRAN (R 4.5.0)
#>  magrittr            2.0.3   2022-03-30 [1] CRAN (R 4.5.0)
#>  nlme                3.1-168 2025-03-31 [1] CRAN (R 4.5.0)
#>  patchwork           1.3.1   2025-06-21 [1] CRAN (R 4.5.0)
#>  pillar              1.11.0  2025-07-04 [1] CRAN (R 4.5.0)
#>  pkgconfig           2.0.3   2019-09-22 [1] CRAN (R 4.5.0)
#>  purrr               1.1.0   2025-07-10 [1] CRAN (R 4.5.0)
#>  R6                  2.6.1   2025-02-15 [1] CRAN (R 4.5.0)
#>  RColorBrewer        1.1-3   2022-04-03 [1] CRAN (R 4.5.0)
#>  Rcpp                1.1.0   2025-07-02 [1] CRAN (R 4.5.0)
#>  reprex              2.1.1   2024-07-06 [1] CRAN (R 4.5.0)
#>  rlang               1.1.6   2025-04-11 [1] CRAN (R 4.5.0)
#>  rmarkdown           2.29    2024-11-04 [1] CRAN (R 4.5.0)
#>  S7                  0.2.0   2024-11-07 [1] CRAN (R 4.5.0)
#>  scales              1.4.0   2025-04-24 [1] CRAN (R 4.5.0)
#>  sessioninfo         1.2.3   2025-02-05 [1] CRAN (R 4.5.0)
#>  systemfonts         1.3.1   2025-10-01 [1] CRAN (R 4.5.0)
#>  TDbook            * 0.0.6   2022-08-13 [1] CRAN (R 4.5.0)
#>  tibble              3.3.0   2025-06-08 [1] CRAN (R 4.5.0)
#>  tidyr               1.3.1   2024-01-24 [1] CRAN (R 4.5.0)
#>  tidyselect          1.2.1   2024-03-11 [1] CRAN (R 4.5.0)
#>  tidytree            0.4.6   2023-12-12 [1] CRAN (R 4.5.0)
#>  treeio              1.32.0  2025-04-15 [1] Bioconduc~
#>  vctrs               0.6.5   2023-12-01 [1] CRAN (R 4.5.0)
#>  withr               3.0.2   2024-10-28 [1] CRAN (R 4.5.0)
#>  xfun                0.52    2025-04-02 [1] CRAN (R 4.5.0)
#>  yaml                2.3.10  2024-07-26 [1] CRAN (R 4.5.0)
#>  yulab.utils         0.2.0   2025-01-29 [1] CRAN (R 4.5.0)
#> 
#>  [1] /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
#>  * ── Packages attached to the search path.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions