tests/testthat/test-networks.R

test_that("hazard data loads", {
  expect_silent(data(hazard))
})

test_that("inbreeding data loads", {
  expect_silent(data(inbreeding))
})

test_that("ped2fam gets the right families for hazard data", {
  data(hazard)
  ds <- ped2fam(hazard, famID = "newFamID")
  tab <- table(ds$FamID, ds$newFamID)
  expect_equal(ds$FamID, ds$newFamID)
})

test_that("ped2fam gets the right families for inbreeding data", {
  data(inbreeding)
  ds <- ped2fam(inbreeding, famID = "newFamID")
  tab <- table(ds$FamID, ds$newFamID)
  expect_equal(ds$FamID, ds$newFamID)
})

test_that("ped2graph produces a graph for hazard data with mothers", {
  expect_silent(data(hazard))
  g <- ped2graph(hazard, adjacent = "mothers")
  expect_true(inherits(g, "igraph"))
})

test_that("ped2graph produces a graph for hazard data with fathers", {
  expect_silent(data(hazard))
  g <- ped2graph(hazard, adjacent = "fathers")
  expect_true(inherits(g, "igraph"))
})

test_that("ped2graph produces a graph for inbreeding data", {
  expect_silent(data(inbreeding))
  g <- ped2graph(inbreeding)
  expect_true(inherits(g, "igraph"))
})

Try the BGmisc package in your browser

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

BGmisc documentation built on April 12, 2025, 2 a.m.