Skip to content

Commit

Permalink
Add basic tests for pedigree graph theory and path tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
mhunter1 committed Sep 8, 2023
1 parent e062d21 commit 5670e79
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/testthat/test-network.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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("ped2graph produces a graph", {
expect_silent(data(inbreeding))
g <- ped2graph(inbreeding)
expect_true(inherits(g, 'igraph'))
})

test_that("ped2add produces correct matrix dims, values, and dimnames", {
data(hazard)
add <- ped2add(hazard)
# Check dimension
expect_equal(dim(add), c(43, 43))
# Check several values
expect_true(all(diag(add) == 1))
expect_equal(add, t(add))
expect_equal(add[2, 1], 0)
expect_equal(add[10, 1], .25)
expect_equal(add[9, 1], 0)
expect_equal(add['5', '6'], .5)
# Check that dimnames are correct
dn <- dimnames(add)
expect_equal(dn[[1]], dn[[2]])
expect_equal(dn[[1]], as.character(hazard$ID))
})

#test_that("ped2mit produces correct matrix dims, values, and dimnames", {
# # Check dimension
# # Check several values
# # Check that dimnames are correct
# expect_silent(data(inbreeding))
#})

#test_that("ped2cn produces correct matrix dims, values, and dimnames", {
# # Check dimension
# # Check several values
# # Check that dimnames are correct
# expect_silent(data(inbreeding))
#})

#test_that("ped2ce produces correct matrix dims, values, and dimnames", {
# # Check dimension
# # Check several values
# # Check that dimnames are correct
# expect_silent(data(inbreeding))
#})

0 comments on commit 5670e79

Please sign in to comment.