Skip to content
Snippets Groups Projects
Commit eddb955b authored by Clare's avatar Clare
Browse files

Added test for when a pair of SNPs in a window have a genetic distance greater...

Added test for when a pair of SNPs in a window have a genetic distance greater than the maximum bin in the LD profile
parent ddefe8ab
Branches
No related tags found
No related merge requests found
...@@ -332,3 +332,24 @@ test_that("Zalpha_BetaCDF calculates Zalpha_BetaCDF statistic correctly with mis ...@@ -332,3 +332,24 @@ test_that("Zalpha_BetaCDF calculates Zalpha_BetaCDF statistic correctly with mis
NA,NA,NA,NA) NA,NA,NA,NA)
),tolerance=0.0001) ),tolerance=0.0001)
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zalpha_BetaCDF calculates Zalpha_BetaCDF statistic correctly when biggest bin is bigger than LDprofile", {
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.528754272440162,
0.554657151730784,
0.490365350771199,
0.429958093556324,
0.388665184297966,
0.396797658473664,
0.40379809759356,
NA,NA,NA,NA)
),tolerance=0.0001)
})
...@@ -351,3 +351,25 @@ test_that("Zalpha_Zscore calculates Zalpha_Zscore statistic correctly with missi ...@@ -351,3 +351,25 @@ test_that("Zalpha_Zscore calculates Zalpha_Zscore statistic correctly with missi
NA,NA,NA,NA) NA,NA,NA,NA)
),tolerance=0.0001) ),tolerance=0.0001)
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zalpha_Zscore calculates Zalpha_Zscore statistic correctly when biggest bin is bigger than LDprofile", {
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.171551248775495,
0.250751380960093,
0.0418726269555867,
-0.192722802223301,
-0.316679396412605,
-0.285401890619276,
-0.244931914193891,
NA,NA,NA,NA)
),tolerance=0.0001)
})
...@@ -568,3 +568,29 @@ test_that("Zalpha_all calculates statistics correctly with missing value", { ...@@ -568,3 +568,29 @@ test_that("Zalpha_all calculates statistics correctly with missing value", {
Zbeta=c(NA,NA,NA,NA,0.248611111111111,0.235185185185185,0.233651620370370,0.257794784580499,0.250144675925926,0.259413580246914,0.271354166666667,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)
),tolerance=0.0001) ),tolerance=0.0001)
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zalpha_all calculates statistics correctly when biggest bin is bigger than LDprofile", {
expect_equal(Zalpha_all(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, 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),
LR=c(0,13,24,33,40,45,48,49,48,45,40,33,24,13,0),
L_plus_R=c(91,78,67,58,51,46,43,42,43,46,51,58,67,78,91),
Zalpha_expected=c(NA, NA, NA, NA, 0.35775270849344, 0.360194100145564, 0.36882454832507, 0.379040922949242, 0.400715520018796, 0.401718327864356, 0.388093039845692, NA, NA, NA, NA),
Zbeta_expected=c(NA, NA, NA, NA, 0.309796639287645, 0.306356600239621, 0.299229117644403, 0.287619092597206, 0.271195118636169, 0.271195118636169, 0.285239698673566, NA, NA, NA, NA),
Zalpha=c(NA, NA, NA, NA, 0.417052469135803, 0.449363425925926, 0.377521494708995, 0.298941798941799, 0.270709325396825, 0.281925154320988, 0.287615740740741, NA, NA, NA, NA),
Zbeta=c(NA, NA, NA, NA, 0.256944444444444, 0.243827160493827, 0.244068287037037, 0.255243764172336, 0.241174768518518, 0.252314814814815, 0.261284722222222, NA, NA, NA, NA),
Zalpha_rsq_over_expected=c(NA, NA, NA, NA, 1.19167472080619, 1.27358283231798, 1.05911709750039, 0.813967663774974, 0.691051112331195, 0.728230393808371, 0.76047497606951, NA, NA, NA, NA),
Zalpha_log_rsq_over_expected=c(NA, NA, NA, NA, -0.0866699301333792, -0.0450984996562888, -0.170082829057599, -0.292011096473854, -0.355497049708911, -0.345346264723395, -0.325460796768333, NA, NA, NA, NA),
Zbeta_rsq_over_expected=c(NA, NA, NA, NA, 0.829165822709247, 0.794411354588777, 0.811051641594364, 0.879635831191311, 0.8893035012259, 0.93038110746129, 0.936927121826222, NA, NA, NA, NA),
Zbeta_log_rsq_over_expected=c(NA, NA, NA, NA, -0.253507645357523, -0.252472151393989, -0.264919235707824, -0.237790197768511, -0.231067956739982, -0.186686780456914, -0.194302291843375, NA, NA, NA, NA),
Zalpha_Zscore=c(NA, NA, NA, NA, 0.171551248775495, 0.250751380960093, 0.0418726269555867, -0.192722802223301, -0.316679396412605, -0.285401890619276, -0.244931914193891, NA, NA, NA, NA),
Zbeta_Zscore=c(NA, NA, NA, NA, -0.155023529432353, -0.185399969976716, -0.168250652582989, -0.104627764295373, -0.0955723675990356, -0.0601070717071691, -0.0618178441622676, NA, NA, NA, NA),
Zalpha_BetaCDF=c(NA, NA, NA, NA, 0.528754272440162, 0.554657151730784, 0.490365350771199, 0.429958093556324, 0.388665184297966, 0.396797658473664, 0.40379809759356, NA, NA, NA, NA),
Zbeta_BetaCDF=c(NA, NA, NA, NA, 0.459559291673423, 0.456100842212321, 0.459910029690557, 0.479549830626744, 0.482519290259401, 0.49506531210108, 0.488097958454476, NA, NA, NA, NA)
),tolerance=0.0001)
})
...@@ -247,3 +247,24 @@ test_that("Zalpha_expected fails when LDprofile_bins and LDprofile_rsq are diffe ...@@ -247,3 +247,24 @@ test_that("Zalpha_expected fails when LDprofile_bins and LDprofile_rsq are diffe
expect_error(Zalpha_expected(pos = df$POS, ws = 3000, dist = df$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = c(LDprofile$rsq,1), minRandL = 4, minRL = 25, X = NULL), expect_error(Zalpha_expected(pos = df$POS, ws = 3000, dist = df$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = c(LDprofile$rsq,1), minRandL = 4, minRL = 25, X = NULL),
"LDprofile_rsq must contain the same number of values as there are bins given in LDprofile_bins") "LDprofile_rsq must contain the same number of values as there are bins given in LDprofile_bins")
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zalpha_expected calculates Zalpha_expected statistic correctly when biggest bin is bigger than LDprofile", {
expect_equal(Zalpha_expected(pos = df1$POS, ws = 3000, 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_expected=c(NA,NA,NA,NA,
0.35775270849344,
0.360194100145564,
0.36882454832507,
0.379040922949242,
0.400715520018796,
0.401718327864356,
0.388093039845692,
NA,NA,NA,NA)
),tolerance=0.0001)
})
...@@ -325,3 +325,24 @@ test_that("Zalpha_log_rsq_over_expected calculates Zalpha_log_rsq_over_expected ...@@ -325,3 +325,24 @@ test_that("Zalpha_log_rsq_over_expected calculates Zalpha_log_rsq_over_expected
NA,NA,NA,NA) NA,NA,NA,NA)
),tolerance=0.0001) ),tolerance=0.0001)
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zalpha_log_rsq_over_expected calculates Zalpha_log_rsq_over_expected statistic correctly when biggest bin is bigger than LDprofile", {
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.0866699301333792,
-0.0450984996562888,
-0.170082829057599,
-0.292011096473854,
-0.355497049708911,
-0.345346264723395,
-0.325460796768333,
NA,NA,NA,NA)
),tolerance=0.0001)
})
...@@ -325,3 +325,24 @@ test_that("Zalpha_rsq_over_expected calculates Zalpha_rsq_over_expected statisti ...@@ -325,3 +325,24 @@ test_that("Zalpha_rsq_over_expected calculates Zalpha_rsq_over_expected statisti
NA,NA,NA,NA) NA,NA,NA,NA)
),tolerance=0.0001) ),tolerance=0.0001)
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zalpha_rsq_over_expected calculates Zalpha_rsq_over_expected statistic correctly when biggest bin is bigger than LDprofile", {
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.19167472080619,
1.27358283231798,
1.05911709750039,
0.813967663774974,
0.691051112331195,
0.728230393808371,
0.76047497606951,
NA,NA,NA,NA)
),tolerance=0.0001)
})
...@@ -332,3 +332,24 @@ test_that("Zbeta_BetaCDF calculates Zbeta_BetaCDF statistic correctly with missi ...@@ -332,3 +332,24 @@ test_that("Zbeta_BetaCDF calculates Zbeta_BetaCDF statistic correctly with missi
NA,NA,NA,NA) NA,NA,NA,NA)
),tolerance=0.0001) ),tolerance=0.0001)
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zbeta_BetaCDF calculates Zbeta_BetaCDF statistic correctly when biggest bin is bigger than LDprofile", {
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.459559291673423,
0.456100842212321,
0.459910029690557,
0.479549830626744,
0.482519290259401,
0.49506531210108,
0.488097958454476,
NA,NA,NA,NA)
),tolerance=0.0001)
})
...@@ -351,3 +351,24 @@ test_that("Zbeta_Zscore calculates Zbeta_Zscore statistic correctly with missing ...@@ -351,3 +351,24 @@ test_that("Zbeta_Zscore calculates Zbeta_Zscore statistic correctly with missing
NA,NA,NA,NA) NA,NA,NA,NA)
),tolerance=0.0001) ),tolerance=0.0001)
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zbeta_Zscore calculates Zbeta_Zscore statistic correctly when biggest bin is bigger than LDprofile", {
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.155023529432353,
-0.185399969976716,
-0.168250652582989,
-0.104627764295373,
-0.0955723675990356,
-0.0601070717071691,
-0.0618178441622676,
NA,NA,NA,NA)
),tolerance=0.0001)
})
...@@ -247,3 +247,25 @@ test_that("Zbeta_expected fails when LDprofile_bins and LDprofile_rsq are differ ...@@ -247,3 +247,25 @@ test_that("Zbeta_expected fails when LDprofile_bins and LDprofile_rsq are differ
expect_error(Zbeta_expected(pos = df$POS, ws = 3000, dist = df$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = c(LDprofile$rsq,1), minRandL = 4, minRL = 25, X = NULL), expect_error(Zbeta_expected(pos = df$POS, ws = 3000, dist = df$dist, LDprofile_bins = LDprofile$bin, LDprofile_rsq = c(LDprofile$rsq,1), minRandL = 4, minRL = 25, X = NULL),
"LDprofile_rsq must contain the same number of values as there are bins given in LDprofile_bins") "LDprofile_rsq must contain the same number of values as there are bins given in LDprofile_bins")
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zbeta_expected calculates Zbeta_expected statistic correctly when biggest bin is bigger than LDprofile", {
expect_equal(Zbeta_expected(pos = df1$POS, ws = 3000, 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_expected=c(NA,NA,NA,NA,
0.309796639287645,
0.306356600239621,
0.299229117644403,
0.287619092597206,
0.271195118636169,
0.271195118636169,
0.285239698673566,
NA,NA,NA,NA)
),tolerance=0.0001)
})
...@@ -325,3 +325,24 @@ test_that("Zbeta_log_rsq_over_expected calculates Zbeta_log_rsq_over_expected st ...@@ -325,3 +325,24 @@ test_that("Zbeta_log_rsq_over_expected calculates Zbeta_log_rsq_over_expected st
NA,NA,NA,NA) NA,NA,NA,NA)
),tolerance=0.0001) ),tolerance=0.0001)
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zbeta_log_rsq_over_expected calculates Zbeta_log_rsq_over_expected statistic correctly when biggest bin is bigger than LDprofile", {
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.253507645357523,
-0.252472151393989,
-0.264919235707824,
-0.237790197768511,
-0.231067956739982,
-0.186686780456914,
-0.194302291843375,
NA,NA,NA,NA)
),tolerance=0.0001)
})
...@@ -325,3 +325,24 @@ test_that("Zbeta_rsq_over_expected calculates Zbeta_rsq_over_expected statistic ...@@ -325,3 +325,24 @@ test_that("Zbeta_rsq_over_expected calculates Zbeta_rsq_over_expected statistic
NA,NA,NA,NA) NA,NA,NA,NA)
),tolerance=0.0001) ),tolerance=0.0001)
}) })
## test what happens when the biggest bin is bigger than the max_dist in the LDprofile
df1<-df
df1$dist[10:15]<-df1$dist[10:15]+0.1
test_that("Zbeta_rsq_over_expected calculates Zbeta_rsq_over_expected statistic correctly when biggest bin is bigger than LDprofile", {
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.829165822709247,
0.794411354588777,
0.811051641594364,
0.879635831191311,
0.8893035012259,
0.93038110746129,
0.936927121826222,
NA,NA,NA,NA)
),tolerance=0.0001)
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment