From add21d5379beeb4d35daea0d0e0476a414843e51 Mon Sep 17 00:00:00 2001 From: ryanchrist Date: Mon, 23 Sep 2024 12:14:11 -0500 Subject: [PATCH] Introducing tests for CladeMat --- tests/testthat/test-CladeMat.R | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/testthat/test-CladeMat.R diff --git a/tests/testthat/test-CladeMat.R b/tests/testthat/test-CladeMat.R new file mode 100644 index 0000000..842bd2e --- /dev/null +++ b/tests/testthat/test-CladeMat.R @@ -0,0 +1,22 @@ +test_that("CladeMat Matches GoldMaster CladeMat", { + + CacheHaplotypes(SmallHaps) + map <- SmallMap + + target.idx <- floor(L()/2) + pars <- Parameters(CalcRho(diff(map),s = 0.01),mu = 0.0001) # specify HMM parameters + fwd <- MakeForwardTable(pars) + bck <- MakeBackwardTable(pars) + Forward(fwd, pars, target.idx) + Backward(bck, pars, target.idx) + + unit.dist <- -log(pars$pars$mu) + thresh <- 0.2 + + M <- matrix(0,N()/2,N()/2) + neigh <- CladeMat(fwd,bck,M,unit.dist = unit.dist, thresh = thresh ,max1var = TRUE) + + M2 <- kalis:::CladeMat.GM(fwd,bck,unit.dist = unit.dist, thresh = thresh) + + expect_equal(M, M2) +})