2022-02-08 11:17:23 +01:00
|
|
|
context("greedyPopMix functions")
|
|
|
|
|
|
|
|
|
|
test_that("Auxiliary functions work properly", {
|
2022-04-12 15:50:16 +02:00
|
|
|
# Testing findOutRowsFromInd -------------------------------------------------
|
2022-02-08 11:17:23 +01:00
|
|
|
x <- matrix(11:16, 3)
|
|
|
|
|
y <- matrix(2:7, 3)
|
|
|
|
|
z <- list(
|
|
|
|
|
popnames2 = matrix(c(11:13, seq(1.5, 2.5, 0.5)), 3),
|
|
|
|
|
rowsFromInd = 2
|
|
|
|
|
)
|
|
|
|
|
expect_equal(findOutRowsFromInd(x, y, "Diploid"), z)
|
2022-04-12 15:50:16 +02:00
|
|
|
|
|
|
|
|
# Testing getPopDistancesByKL ------------------------------------------------
|
|
|
|
|
x2 <- matrix(seq(4, 14, 2), 3)
|
2022-02-08 14:01:02 +01:00
|
|
|
expect_equal(
|
|
|
|
|
getPopDistancesByKL(x2),
|
|
|
|
|
list(
|
2022-07-28 15:47:36 +02:00
|
|
|
Z = matrix(c(c(1, 101:198), 2:100, rep(0, 99)), nrow = 99, ncol = 3),
|
2022-02-08 14:01:02 +01:00
|
|
|
distances = as.matrix(rep(0, 4950))
|
|
|
|
|
)
|
|
|
|
|
)
|
2022-04-12 15:50:16 +02:00
|
|
|
|
|
|
|
|
# Testing handlePopData ------------------------------------------------------
|
2022-04-12 15:47:22 +02:00
|
|
|
x3 <- matrix(c(9, 4, 1, 8, 5, 2, 1, 2, 3), 3)
|
|
|
|
|
y3 <- list(
|
2022-04-12 15:50:16 +02:00
|
|
|
newData = matrix(c(3: 1, 3: 1, 1: 3), 3),
|
|
|
|
|
rows = matrix(c(1: 3, 1: 3), 3),
|
2022-04-12 15:47:22 +02:00
|
|
|
alleleCodes = matrix(c(1, 4, 9, 2, 5, 8), 3),
|
2022-04-13 08:59:07 +02:00
|
|
|
noalle = matrix(c(3, 3), 1),
|
2022-07-28 15:47:36 +02:00
|
|
|
adjprior = matrix(rep(3 / 9, 6), 3),
|
2022-04-12 15:50:16 +02:00
|
|
|
priorTerm = 5.9125
|
2022-04-12 15:47:22 +02:00
|
|
|
)
|
2022-04-13 08:59:07 +02:00
|
|
|
expect_equal(handlePopData(x3), y3, tol = 1e-4)
|
2022-02-08 11:17:23 +01:00
|
|
|
})
|