tests/testthat/test-any_outgroup.R

test_that("any_outgroup correctly identifies multi-species outgroup", {
  set.seed(
    1,
    kind = "Mersenne-Twister",
    normal.kind = "Inversion",
    sample.kind = "Rejection"
  )
  phylo <- ape::rcoal(10)
  phylo$tip.label <- c("bird_a", "bird_b", "bird_c", "bird_d", "bird_e",
                       "bird_f", "bird_g", "bird_h", "bird_i", "bird_j")
  phylo <- phylobase::phylo4(phylo)
  endemicity_status <- c("endemic", "nonendemic", "not_present", "not_present",
                         "not_present", "not_present", "not_present",
                         "not_present", "not_present", "not_present")
  phylod <- phylobase::phylo4d(phylo, as.data.frame(endemicity_status))
  expect_true(any_outgroup(phylod))
})

test_that("any_outgroup correctly identifies single species outgroup", {
  set.seed(
    1,
    kind = "Mersenne-Twister",
    normal.kind = "Inversion",
    sample.kind = "Rejection"
  )
  phylo <- ape::rcoal(10)
  phylo$tip.label <- c("bird_a", "bird_b", "bird_c", "bird_d", "bird_e",
                       "bird_f", "bird_g", "bird_h", "bird_i", "bird_j")
  phylo <- phylobase::phylo4(phylo)
  endemicity_status <- c("endemic", "nonendemic", "nonendemic", "nonendemic",
                         "nonendemic", "nonendemic", "nonendemic",
                         "nonendemic", "nonendemic", "not_present")
  phylod <- phylobase::phylo4d(phylo, as.data.frame(endemicity_status))
  expect_true(any_outgroup(phylod))
})

test_that("any_outgroup correctly finds no outgroup", {
  set.seed(
    1,
    kind = "Mersenne-Twister",
    normal.kind = "Inversion",
    sample.kind = "Rejection"
  )
  phylo <- ape::rcoal(10)
  phylo$tip.label <- c("bird_a", "bird_b", "bird_c", "bird_d", "bird_e",
                       "bird_f", "bird_g", "bird_h", "bird_i", "bird_j")
  phylo <- phylobase::phylo4(phylo)
  endemicity_status <- c("endemic", "not_present", "nonendemic", "nonendemic",
                         "nonendemic", "not_present", "nonendemic",
                         "nonendemic", "nonendemic", "endemic")
  phylod <- phylobase::phylo4d(phylo, as.data.frame(endemicity_status))
  expect_false(any_outgroup(phylod))
})

Try the DAISIEprep package in your browser

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

DAISIEprep documentation built on April 3, 2025, 9:26 p.m.