### Unit tests for normalComparison.R functions
library(CNprep)
### Tests normalComparison () results
context("normalComparison() results")
test_that("normalComparison() must return expected results 01", {
normalmedian <- c(0.0230326977, 0.0069878681, 0.0013329618, 0.0110395179,
0.0007606011, 0.0023178528, -0.0076653454, -0.0044130592,
-0.0044268312, -0.0362319897)
normalength <- c(11906049, 231977105, 86185990, 2411050, 151410255,
199269234, 34587196, 60357381, 96145497, 620234)
tumormad <- c(0.08502516, 0.13829131, 0.09701612, 0.12886650, 0.09179211,
0.12066915, 0.09360264, 0.09505375, 0.12648441, 0.07690704)
tumormedian <- c(0.046492091, -0.216771966, 0.041802329, -0.227213792,
0.035899255, 0.243933069, -0.032015273, -0.004500177,
-0.284767695, -0.010467050)
tumorerror <- c(0.006267755, 0.009346934, 0.003025827, 0.006431545,
0.003926070, 0.003544793, 0.002222607, 0.003353667,
0.008923441, 0.012611398)
tumorlength <- c(14912327, 21970269, 40526202, 24664080, 38759675,
103077343, 102923669, 40349469, 8897435, 2210770)
RNGkind("default")
set.seed(222)
results <- CNprep:::normalComparison(normalmedian = normalmedian, normalength = normalength,
tumormedian = tumormedian,
tumorlength = tumorlength, normalmad = NULL,
normalerror = NULL, tumormad = tumormad,
tumorerror = tumorerror)
expected <- as.matrix(data.frame(samplesize=c(58, 39, 21, 35, 22, 8, 8, 21, 98, 395),
negtail=c(1.0000000000, 0.0000000000, 1.0000000000,
0.0000000000, 1.0000000000, 1.0000000000,
0.0007089442, 0.0402430422, 0.0000000000,
0.0007089442)))
expect_equal(results, expected)
})
test_that("normalComparison() must return expected results 02", {
normalmedian <- c(0.0230326977, 0.0069878681, 0.0013329618, 0.0110395179,
0.0007606011, 0.0023178528, -0.0076653454, -0.0044130592,
-0.0044268312, -0.0362319897)
normalmad <- c(0.05502516, 0.03829131, 0.05701612, 0.10886650, 0.06179211,
0.02066915, 0.00360264, 0.03505375, 0.11648441, 0.07600704)
normalength <- c(11906049, 231977105, 86185990, 2411050, 151410255,
199269234, 34587196, 60357381, 96145497, 620234)
tumormad <- c(0.08502516, 0.13829131, 0.09701612, 0.12886650, 0.09179211,
0.12066915, 0.09360264, 0.09505375, 0.12648441, 0.07690704)
tumormedian <- c(0.046492091, -0.216771966, 0.041802329, -0.227213792,
0.035899255, 0.243933069, -0.032015273, -0.004500177,
-0.284767695, -0.010467050)
tumorerror <- c(0.006267755, 0.009346934, 0.003025827, 0.006431545,
0.003926070, 0.003544793, 0.002222607, 0.003353667,
0.008923441, 0.012611398)
tumorlength <- c(14912327, 21970269, 40526202, 24664080, 38759675,
103077343, 102923669, 40349469, 8897435, 2210770)
RNGkind("default")
set.seed(222)
results <- CNprep:::normalComparison(normalmedian = normalmedian, normalength = normalength,
tumormedian = tumormedian,
tumorlength = tumorlength, normalmad = normalmad,
normalerror = NULL, tumormad = tumormad,
tumorerror = tumorerror)
expected <- as.matrix(data.frame(samplesize=c(58, 39, 21, 35, 22, 8, 8, 21, 98, 395),
negtail=c(1.0000000000, 0.0000000000, 1.0000000000,
0.0000000000, 1.0000000000, 1.0000000000,
0.0007089442, 0.0402430422, 0.0000000000,
0.0007089442),
negtailnormad=c(1.0000000000, 0.03953410, 1.0000000000,
0.03953410, 0.98639106, 1.00000000,
0.04024304, 0.10923316, 0.00000000,
0.04024304)))
expect_equal(results, expected)
})
test_that("normalComparison() must return expected results 03", {
normalmedian <- c(0.0230326977, 0.0069878681, 0.0013329618, 0.0110395179,
0.0007606011, 0.0021178528, -0.0076653454)
normalmad <- c(0.05202516, 0.03829131, 0.05701612, 0.10886650, 0.06179211,
0.02066915, 0.00320264)
normalerror <- c(0.000007755, 0.000346934, 0.000025827, 0.000431545,
0.003026070, 0.000544793, 0.002200607)
normalength <- c(11906049, 231577105, 86185990, 2111050, 151410255,
199269234, 34587196)
tumormad <- c(0.08602516, 0.13829131, 0.09701612, 0.12886650, 0.09179211,
0.15066915, 0.09360264, 0.09505375, 0.12648441, 0.07690704)
tumormedian <- c(0.049492091, -0.216771966, 0.041902329, -0.227213792,
0.035899255, 0.243993069, -0.032015273, -0.004500177,
-0.284767695, -0.010467050)
tumorerror <- c(0.006267755, 0.009346934, 0.003025827, 0.006431545,
0.003999070, 0.003544793, 0.092222607, 0.093353667,
0.008923441, 0.012611398)
tumorlength <- c(14912327, 2197069, 40526202, 24664080, 38759675,
103077343, 102923669, 4034469, 8897435, 2210770)
RNGkind("default")
set.seed(212)
results <- CNprep:::normalComparison(normalmedian = normalmedian, normalength = normalength,
tumormedian = tumormedian,
tumorlength = tumorlength, normalmad = normalmad,
normalerror = normalerror, tumormad = tumormad,
tumorerror = tumorerror)
expected <- as.matrix(data.frame(samplesize=c(48, 326, 17, 29, 18, 6, 6, 177, 80, 324),
negtail=c(1.0000000000, 0.0000000000, 1.0000000000,
0.0000000000, 1.0000000000, 1.0000000000,
0.00000000, 0.04823561, 0.0000000000,
0.0000000000),
negtailnormad=c(1.0000000000, 0.04823561, 0.98339572,
0.04823561, 0.98339572, 1.00000000,
0.04823561, 0.04823561, 0.04823561,
0.04823561),
negtailnormerror=c(0.53729637, 0.00000000, 0.53729637,
0.00000000, 0.53729637, 0.98339572,
0.04823561, 0.04823561, 0.00000000,
0.04823561)))
expect_equal(results, expected)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.