tests/testthat/test_with_large_data.R

## After running exSTRa_score_analysis.R
context("Test with a real dataset")
# 

expected_text <- "SCA1 (coding CAG) norm: 30 (91bp) , exp: 39 (117bp)"

test_that("text info has changed", {
  expect_equal(loci_text_info(exstra_wgs_pcr_2, "SCA1"), expected_text)
  expect_equal(loci_text_info(exstra_known, "SCA1"), expected_text)
})

# Check if stats have changed between runs
signif_t4 <- rep(FALSE, 72L)
signif_t4[c(6L, 8L, 25L, 27L, 47L, 49L, 57L, 58L)] <- TRUE
tsum_4_stat_expected <- structure(
  list(locus = rep(c("FRDA", "HD", "SCA1", "SCA6"), each = 18L), 
       sample = rep(exstra_wgs_pcr_2[c("FRDA", "HD", "SCA1", "SCA6")]$samples$sample, 4), 
       tsum = c(0.224380249148274, 2.37758148162022, -1.07940061758087,
                1.57425576258927, -0.79878550838408, 12.1568724547555, -0.0499542968581384, 
                13.6084534900895, -0.948799603576646, 0.574070399992864, 1.63576022357891, 
                -1.03104591457042, -1.0749926804585, -0.829945459178226, 0.259554736873429, 
                -1.0075599669081, -1.24996212368912, 0.420927049807853, 0.78651664182035, 
                -1.172794941291, 0.723720010512834, -1.69374057764295, 0.39030004093346, 
                0.428491742832126, 3.91108896876089, -0.609890992015034, 4.76740654909031, 
                -1.23399805696571, -0.916004064537924, 0.957603674028105, 0.659459559963802, 
                -2.02905299666637, -0.533057564727455, 1.38595972765822, 0.405403842170185, 
                -2.55875459465449, -1.43821871246606, -0.59558400236096, 0.405922698653106, 
                -1.07521054501906, 1.57536587945521, 0.387789477505711, -1.21780862564991, 
                -1.41822767936832, 0.656563458234706, 1.22467714174917, 7.78112378457949, 
                -0.652290506303183, 5.7615601471422, -0.0290817911882788, 0.397476263167357, 
                -1.77027753218887, -0.816579341867955, 0.952616543907978, -3.79937114162866, 
                -0.0789628643300413, 8.87692557992477, 9.00122725995886, -0.681222999573204, 
                -0.779015147584212, 0.89980173170065, -0.77233141441907, 0.546012681021191, 
                -0.161137617130194, -0.789583335376943, 1.52409422969286, 0.551143835964602, 
                0.884747680441178, -0.776298245817906, -2.32054394165987, 1.57876816389144, 
                -4.16169382240495), 
       p.value = c(0.427070010565534, 0.0209086359339376, 
                   0.825557470944781, 0.088305621976311, 0.756992715342268, 5.56080742923873e-05, 
                   0.519879886559528, 5.56080742923873e-05, 0.794750597786799, 0.314964132792081, 
                   0.0814658288383473, 0.813490518823333, 0.824667741756103, 0.765278318411833, 
                   0.415447923038425, 0.806706333759662, 0.859367180114553, 0.362509036312072, 
                   0.234054384696658, 0.863315353389312, 0.252571873436023, 0.939220374798421, 
                   0.362064171717733, 0.348384585441806, 0.000667296891508647, 0.71278429627982, 
                   0.000166824222877162, 0.874881832842129, 0.802869376633487, 0.186565089250959, 
                   0.270811321803926, 0.967747316910415, 0.687037757882444, 0.103264193960963, 
                   0.356892620808541, 0.989156425512984, 0.95668131012623, 0.758382917199577, 
                   0.315019740866374, 0.901017627759551, 0.0305288327865206, 0.322804871267308, 
                   0.927487071122727, 0.954401379080242, 0.21453595062003, 0.0712339431685481, 
                   5.56080742923873e-05, 0.780514930767948, 5.56080742923873e-05, 
                   0.510815770449869, 0.318523049546794, 0.980259133626203, 0.832897736751376, 
                   0.127231273980982, 0.999666351554246, 0.529388867263527, 5.56080742923873e-05, 
                   5.56080742923873e-05, 0.745593060112328, 0.774008786075738, 0.187232386142468, 
                   0.772396151921259, 0.29700272479564, 0.56114107768448, 0.776900405938942, 
                   0.0703998220541623, 0.295334482566869, 0.191681032085859, 0.773230273035645, 
                   0.986709670244119, 0.0637824612133682, 1), 
       p.value.sd = c(0.00372203545794601, 
                      0.00107657862002547, 0.00285580819754217, 0.0021349663477805, 
                      0.00322748930621084, 5.61083995687615e-05, 0.00375933298528204, 
                      5.61083995687615e-05, 0.00303931001414892, 0.00349513443775407, 
                      0.00205829451712071, 0.00293123973863046, 0.00286153624945665, 
                      0.00318931495481909, 0.00370808485561208, 0.00297158985823891, 
                      0.00261624765645044, 0.00361721607923912, 0.00318590001573445, 
                      0.00258519466625753, 0.00326928207219572, 0.00179855471097718, 
                      0.00361625691299282, 0.00358511210181904, 0.000194305743026293, 
                      0.00340474572513495, 9.71771945024469e-05, 0.00248995700634844, 
                      0.00299378480013761, 0.00293123367304455, 0.00334371274069963, 
                      0.00133046499131135, 0.00348926766315741, 0.00228970524431357, 
                      0.00360485980996714, 0.000781282591479753, 0.00153272282703864, 
                      0.0032212000388956, 0.00349530110036575, 0.00224764885740177, 
                      0.00129447588373497, 0.00351806484336389, 0.00195204510965501, 
                      0.00157061426103936, 0.00308878429879924, 0.0019353906163464, 
                      5.61083995687615e-05, 0.00311463983778438, 5.61083995687615e-05, 
                      0.00376142351649931, 0.00350568420104678, 0.00104817573277148, 
                      0.00280749695668732, 0.00250737531384794, 0.000148614918788342, 
                      0.00375580776221151, 5.61083995687615e-05, 5.61083995687615e-05, 
                      0.0032773472167247, 0.00314725437717636, 0.00293526651829521, 
                      0.003155168729641, 0.00343821680587069, 0.00373409395809844, 
                      0.00313289538165713, 0.00192488965607281, 0.00343261240996224, 
                      0.00296179433049539, 0.00315108341426302, 0.00086346408355925, 
                      0.00183870005332605, 5.66115672688022e-05), 
       B = rep(999, 72L), 
       signif = signif_t4
       ), 
  class = "data.frame", 
  row.names = c(NA, 
                -72L))

test_that("tsum_test()$stats table has changed from previous runs.", {
  expect_equal(as.data.frame(tsum_4$stats), tsum_4_stat_expected)
})
bahlolab/exSTRa documentation built on Sept. 17, 2022, 5:08 p.m.