-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic tests for pedigree graph theory and path tracing
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
#}) |