tests/testthat/test-geom_text_phylo.R

test_that("geom_text_phylo works", {
  skip_if_not_installed("ape")
  skip_if_not_installed("ggtree")
  library(ape)
  library(ggtree)
  set.seed(1234)
  tr <- rtree(10)
  gg <- revts(ggtree(tr)) +
    geom_text_phylo() +
    coord_geo_radial("epochs")
  expect_true(is_ggplot(gg))
  expect_true(is(gg$layers[[3]]$geom, "GeomTextPhylo"))
  expect_true(is(gg$layers[[3]]$stat, "StatIdentity"))
  expect_doppelganger_deeptime("geom_text_phylo", gg)

  expect_error({
    ggtree(tr) +
      geom_text_phylo(node_type = "wrong") +
      coord_geo_radial("epochs")
  })
  expect_error({
    ggtree(tr) +
      geom_text_phylo(auto_adjust = "wrong") +
      coord_geo_radial("epochs")
  })
})

Try the deeptime package in your browser

Any scripts or data that you put into this service are public.

deeptime documentation built on June 20, 2025, 1:10 a.m.