diff --git a/tests/testthat/test-Zalpha.R b/tests/testthat/test-Zalpha.R index 64936c9733ba4d98c9c4b7920116650f4adf6da1..e9f72c656392839e7f498194206f0d3fb7d9a20a 100644 --- a/tests/testthat/test-Zalpha.R +++ b/tests/testthat/test-Zalpha.R @@ -216,3 +216,24 @@ test_that("Zalpha warns about all NAs", { expect_warning(Zalpha(pos = df$POS, ws = 3000, x = as.matrix(df[,3:7]), minRandL = 4, minRL = 50, X = NULL), "No Zalpha values were calculated, try reducing minRandL and minRL or increasing the window size") }) + +## test that zalpha works with a missing value + +df1<-df +df1$C1[15]<-NA +test_that("Zalpha calculates Zalpha statistic correctly with missing value", { + + expect_equal(Zalpha(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7]), minRandL = 4, minRL = 25, X = NULL), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + Zalpha=c(NA,NA,NA,NA, + 0.434953703703704, + 0.473283179012346, + 0.397114748677249, + 0.317791005291005, + 0.300801917989418, + 0.322897376543210, + 0.360532407407407, + NA,NA,NA,NA) + )) +}) diff --git a/tests/testthat/test-Zalpha_BetaCDF.R b/tests/testthat/test-Zalpha_BetaCDF.R index 2377ccf89ddd734f8395725e51b3cca3d3cec582..a97c42e8082d5771f1f5582552b483512af9c370 100644 --- a/tests/testthat/test-Zalpha_BetaCDF.R +++ b/tests/testthat/test-Zalpha_BetaCDF.R @@ -313,4 +313,22 @@ test_that("Zalpha_BetaCDF fails when LDprofile_bins and LDprofile_Beta_b are dif "LDprofile_Beta_b must contain the same number of values as there are bins given in LDprofile_bins") }) +## test that Zalpha_BetaCDF works with missing value +df1<-df +df1$C1[15]<-NA +test_that("Zalpha_BetaCDF calculates Zalpha_BetaCDF statistic correctly with missing value", { + expect_equal(Zalpha_BetaCDF(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_Beta_a = LDprofile$Beta_a, LDprofile_Beta_b = LDprofile$Beta_b, minRandL = 4, minRL = 25, X = NULL), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + Zalpha_BetaCDF=c(NA,NA,NA,NA, + 0.514624827235342, + 0.545771193444576, + 0.479196303216273, + 0.426601106081793, + 0.414611369025125, + 0.431252209159130, + 0.453835332399716, + NA,NA,NA,NA) + )) +}) diff --git a/tests/testthat/test-Zalpha_Zscore.R b/tests/testthat/test-Zalpha_Zscore.R index 53087b3f3d9b805877e6f4f2f2c2fd5335e2e8a4..22cddb01881a9a027581da769de5bd23db6091fb 100644 --- a/tests/testthat/test-Zalpha_Zscore.R +++ b/tests/testthat/test-Zalpha_Zscore.R @@ -332,4 +332,22 @@ test_that("Zalpha_Zscore fails when LDprofile_bins and LDprofile_sd are differen "LDprofile_sd must contain the same number of values as there are bins given in LDprofile_bins") }) +## test that Zalpha_Zscore works with a missing value +df1<-df +df1$C1[15]<-NA +test_that("Zalpha_Zscore calculates Zalpha_Zscore statistic correctly with missing value", { + expect_equal(Zalpha_Zscore(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, LDprofile_sd = LDprofile$sd, minRandL = 4, minRL = 25, X = NULL), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + Zalpha_Zscore=c(NA,NA,NA,NA, + 0.1293462762460600, + 0.2214307128814780, + 0.0107400139438311, + -0.1948882077777450, + -0.2427674321057070, + -0.1850465883763240, + -0.0912782685815102, + NA,NA,NA,NA) + )) +}) diff --git a/tests/testthat/test-Zalpha_all.R b/tests/testthat/test-Zalpha_all.R index 66dea9861f47399783bf0a6fe786960403f55a05..90f6ab3ac8f060b6636a5925dcc6cd9a83c33698 100644 --- a/tests/testthat/test-Zalpha_all.R +++ b/tests/testthat/test-Zalpha_all.R @@ -553,3 +553,18 @@ test_that("Zalpha_all calculates statistics correctly with LDprofile_bins not su Zbeta=c(NA,NA,NA,NA,(10+5/18)/40,(10+35/36)/45,(11+103/144)/48,(12+73/144)/49,(11+83/144)/48,(11+17/48)/45,(10+65/144)/40,NA,NA,NA,NA) )) }) + +## test that Zalpha_all works with a missing value +df1<-df +df1$C1[15]<-NA +test_that("Zalpha_all calculates statistics correctly with missing value", { + + expect_equal(Zalpha_all(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7])), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + LR=c(NA,NA,NA,NA,40,45,48,49,48,45,40,NA,NA,NA,NA), + L_plus_R=c(NA,NA,NA,NA,51,46,43,42,43,46,51,NA,NA,NA,NA), + Zalpha=c(NA,NA,NA,NA,0.434953703703704,0.473283179012346,0.397114748677249,0.317791005291005,0.300801917989418,0.322897376543210,0.360532407407407,NA,NA,NA,NA), + Zbeta=c(NA,NA,NA,NA,0.248611111111111,0.235185185185185,0.233651620370370,0.257794784580499,0.250144675925926,0.259413580246914,0.271354166666667,NA,NA,NA,NA) + )) +}) diff --git a/tests/testthat/test-Zalpha_log_rsq_over_expected.R b/tests/testthat/test-Zalpha_log_rsq_over_expected.R index a612ce5b445322d6a4d098ef7d891147440018bc..5f6cb0d7bd30e79f075c72f9a9ea10df3f047ba8 100644 --- a/tests/testthat/test-Zalpha_log_rsq_over_expected.R +++ b/tests/testthat/test-Zalpha_log_rsq_over_expected.R @@ -306,4 +306,22 @@ test_that("Zalpha_log_rsq_over_expected fails when LDprofile_bins and LDprofile_ "LDprofile_rsq must contain the same number of values as there are bins given in LDprofile_bins") }) +## test that Zalpha_log_rsq_over_expected works with missing value +df1<-df +df1$C1[15]<-NA +test_that("Zalpha_log_rsq_over_expected calculates Zalpha_log_rsq_over_expected statistic correctly with missing value", { + expect_equal(Zalpha_log_rsq_over_expected(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, minRandL = 4, minRL = 25, X = NULL), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + Zalpha_log_rsq_over_expected=c(NA,NA,NA,NA, + -0.0962381774322340, + -0.0431319886441381, + -0.1586794755944650, + -0.2787494259051810, + -0.2969961346576940, + -0.2876978917129680, + -0.2297613495634870, + NA,NA,NA,NA) + )) +}) diff --git a/tests/testthat/test-Zalpha_rsq_over_expected.R b/tests/testthat/test-Zalpha_rsq_over_expected.R index b2e6d6a5517f304e9d5fb2765928da1a7cdc7fcd..162cc286782c208a994bef20cd054c7eda4e5064 100644 --- a/tests/testthat/test-Zalpha_rsq_over_expected.R +++ b/tests/testthat/test-Zalpha_rsq_over_expected.R @@ -306,4 +306,22 @@ test_that("Zalpha_rsq_over_expected fails when LDprofile_bins and LDprofile_rsq "LDprofile_rsq must contain the same number of values as there are bins given in LDprofile_bins") }) +## test that Zalpha_rsq_over_expected works with a missing value +df1<-df +df1$C1[15]<-NA +test_that("Zalpha_rsq_over_expected calculates Zalpha_rsq_over_expected statistic correctly with missing value", { + expect_equal(Zalpha_rsq_over_expected(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, minRandL = 4, minRL = 25, X = NULL), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + Zalpha_rsq_over_expected=c(NA,NA,NA,NA, + 1.144893254873100, + 1.236446352382830, + 1.020556368226920, + 0.810519367025429, + 0.761404523358315, + 0.823237169574888, + 0.907695973532459, + NA,NA,NA,NA) + )) +}) diff --git a/tests/testthat/test-Zbeta.R b/tests/testthat/test-Zbeta.R index 657308f736162a224aeae9f69d8b2caadc8fc605..e71bcaf2356f628551274fbb6a324a3e57c4319a 100644 --- a/tests/testthat/test-Zbeta.R +++ b/tests/testthat/test-Zbeta.R @@ -216,3 +216,23 @@ test_that("Zbeta warns about all NAs", { expect_warning(Zbeta(pos = df$POS, ws = 3000, x = as.matrix(df[,3:7]), minRandL = 4, minRL = 50, X = NULL), "No Zbeta values were calculated, try reducing minRandL and minRL or increasing the window size") }) + +## test that Zbeta works with a missing value +df1<-df +df1$C1[15]<-NA +test_that("Zbeta calculates Zbeta statistic correctly with missing value", { + + expect_equal(Zbeta(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7]), minRandL = 4, minRL = 25, X = NULL), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + Zbeta=c(NA,NA,NA,NA, + 0.248611111111111, + 0.235185185185185, + 0.233651620370370, + 0.257794784580499, + 0.250144675925926, + 0.259413580246914, + 0.271354166666667, + NA,NA,NA,NA) + )) +}) diff --git a/tests/testthat/test-Zbeta_BetaCDF.R b/tests/testthat/test-Zbeta_BetaCDF.R index acf23ebe6969a92c0de0ca3ae926292ffa0ffc64..56de2d30e1a9d14889f44f28811b3e1e72910963 100644 --- a/tests/testthat/test-Zbeta_BetaCDF.R +++ b/tests/testthat/test-Zbeta_BetaCDF.R @@ -313,4 +313,22 @@ test_that("Zbeta_BetaCDF fails when LDprofile_bins and LDprofile_Beta_b are diff "LDprofile_Beta_b must contain the same number of values as there are bins given in LDprofile_bins") }) +## test that Zbeta_BetaCDF works with a missing value +df1<-df +df1$C1[15]<-NA +test_that("Zbeta_BetaCDF calculates Zbeta_BetaCDF statistic correctly with missing value", { + expect_equal(Zbeta_BetaCDF(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_Beta_a = LDprofile$Beta_a, LDprofile_Beta_b = LDprofile$Beta_b, minRandL = 4, minRL = 25, X = NULL), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + Zbeta_BetaCDF=c(NA,NA,NA,NA, + 0.412985057460831, + 0.400927939537124, + 0.395021661102834, + 0.415693421938135, + 0.407239348282580, + 0.414765530721706, + 0.422608554537899, + NA,NA,NA,NA) + )) +}) diff --git a/tests/testthat/test-Zbeta_Zscore.R b/tests/testthat/test-Zbeta_Zscore.R index ab3c6a2fac6ebdc02f7cf2fefdab21b93549db9b..9b79635e23be0255b1b54d19e4244d4c3b112a51 100644 --- a/tests/testthat/test-Zbeta_Zscore.R +++ b/tests/testthat/test-Zbeta_Zscore.R @@ -332,4 +332,22 @@ test_that("Zbeta_Zscore fails when LDprofile_bins and LDprofile_sd are different "LDprofile_sd must contain the same number of values as there are bins given in LDprofile_bins") }) +## test that Zbeta_Zscore works with a missing value +df1<-df +df1$C1[15]<-NA +test_that("Zbeta_Zscore calculates Zbeta_Zscore statistic correctly with missing value", { + expect_equal(Zbeta_Zscore(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, LDprofile_sd = LDprofile$sd, minRandL = 4, minRL = 25, X = NULL), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + Zbeta_Zscore=c(NA,NA,NA,NA, + -0.273427430734028, + -0.322886149060994, + -0.332297266849268, + -0.272829789964421, + -0.301705254123099, + -0.280921980725937, + -0.253883231792888, + NA,NA,NA,NA) + )) +}) diff --git a/tests/testthat/test-Zbeta_log_rsq_over_expected.R b/tests/testthat/test-Zbeta_log_rsq_over_expected.R index 39ffbc442de63cde6fef1207395e55f77959a516..98f67fdbad8e5a78d40cfd025febd7e85013987f 100644 --- a/tests/testthat/test-Zbeta_log_rsq_over_expected.R +++ b/tests/testthat/test-Zbeta_log_rsq_over_expected.R @@ -306,4 +306,22 @@ test_that("Zbeta_log_rsq_over_expected fails when LDprofile_bins and LDprofile_r "LDprofile_rsq must contain the same number of values as there are bins given in LDprofile_bins") }) +## test that Zbeta_log_rsq_over_expected works with a missing value +df1<-df +df1$C1[15]<-NA +test_that("Zbeta_log_rsq_over_expected calculates Zbeta_log_rsq_over_expected statistic correctly with missing value", { + expect_equal(Zbeta_log_rsq_over_expected(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, minRandL = 4, minRL = 25, X = NULL), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + Zbeta_log_rsq_over_expected=c(NA,NA,NA,NA, + -0.325807550270004, + -0.340625852732766, + -0.368453560916506, + -0.349354414321111, + -0.343256477178026, + -0.302866694293198, + -0.277938534964028, + NA,NA,NA,NA) + )) +}) diff --git a/tests/testthat/test-Zbeta_rsq_over_expected.R b/tests/testthat/test-Zbeta_rsq_over_expected.R index 44998453a99d036c12d9c1fc1c7a6210a6698fd9..d2c6ec06d228e14f23be88ae2abbb3da2b352e71 100644 --- a/tests/testthat/test-Zbeta_rsq_over_expected.R +++ b/tests/testthat/test-Zbeta_rsq_over_expected.R @@ -306,4 +306,22 @@ test_that("Zbeta_rsq_over_expected fails when LDprofile_bins and LDprofile_rsq a "LDprofile_rsq must contain the same number of values as there are bins given in LDprofile_bins") }) +## test that Zbeta_rsq_over_expected works with a missing value +df1<-df +df1$C1[15]<-NA +test_that("Zbeta_rsq_over_expected calculates Zbeta_rsq_over_expected statistic correctly with missing value", { + expect_equal(Zbeta_rsq_over_expected(pos = df1$POS, ws = 3000, x = as.matrix(df1[,3:7]), dist = df1$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = LDprofile$rsq, minRandL = 4, minRL = 25, X = NULL), + list( + position=c(100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500), + Zbeta_rsq_over_expected=c(NA,NA,NA,NA, + 0.715016946655391, + 0.667572495841203, + 0.660129682796687, + 0.721295428368775, + 0.685694082181357, + 0.708332106873554, + 0.735944021838047, + NA,NA,NA,NA) + )) +})