File: test_setget.R

package info (click to toggle)
r-bioc-edaseq 2.32.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 404 kB
  • sloc: makefile: 2
file content (81 lines) | stat: -rw-r--r-- 2,001 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
context("Test plot functions.")

set.seed(42)

mat <- matrix(data=rpois(1000, lambda=10), ncol=10)
rownames(mat) <- paste("gene", 1:nrow(mat), sep="")
colnames(mat) <- paste("sample", 1:ncol(mat), sep="")

es <- newSeqExpressionSet(mat)

test_that("setters and getters works", {

  counts(es) <- mat
  expect_equal(counts(es), mat)

  normCounts(es) <- mat
  expect_equal(normCounts(es), mat)
})

test_that("between-lane normalization works", {

  es <- newSeqExpressionSet(mat)
  es2 <- newSeqExpressionSet(mat)

  # full
  norm_mat <- betweenLaneNormalization(mat, which="full")
  normCounts(es2) <- norm_mat
  es3 <- betweenLaneNormalization(es, which="full")

  expect_equal(es2, es3)

  # median
  norm_mat <- betweenLaneNormalization(mat, which="median")
  normCounts(es2) <- norm_mat
  es3 <- betweenLaneNormalization(es, which="median")

  expect_equivalent(es2, es3)

  # upper
  norm_mat <- betweenLaneNormalization(mat, which="upper")
  normCounts(es2) <- norm_mat
  es3 <- betweenLaneNormalization(es, which="upper")

  expect_equivalent(es2, es3)

})

test_that("within-lane normalization works", {

  gc <- rnorm(100)
  es <- newSeqExpressionSet(mat, featureData = data.frame(gc=gc, row.names=rownames(mat)))
  es2 <- es

  # full
  norm_mat <- withinLaneNormalization(mat, gc, which="full")
  normCounts(es2) <- norm_mat
  es3 <- withinLaneNormalization(es, "gc", which="full")

  expect_equal(es2, es3)

  # median
  norm_mat <- withinLaneNormalization(mat, gc, which="median")
  normCounts(es2) <- norm_mat
  es3 <- withinLaneNormalization(es, "gc", which="median")

  expect_equivalent(es2, es3)

  # upper
  norm_mat <- withinLaneNormalization(mat, gc, which="upper")
  normCounts(es2) <- norm_mat
  es3 <- withinLaneNormalization(es, "gc", which="upper")

  expect_equivalent(es2, es3)

  # loess
  norm_mat <- withinLaneNormalization(mat, gc, which="loess")
  normCounts(es2) <- norm_mat
  es3 <- withinLaneNormalization(es, "gc", which="loess")

  expect_equivalent(es2, es3)
})