Browse code

further bug fixes with tests. (test_inference_methods)

bhuvad authored on 25/03/2019 04:19:39
Showing 2 changed files

... ...
@@ -1,6 +1,6 @@
1 1
 Package: dcanr
2 2
 Title: Differential co-expression/association network analysis
3
-Version: 0.99.2
3
+Version: 0.99.3
4 4
 Authors@R: person("Dharmesh", "Bhuva", email = "bhuva.d@wehi.edu.au", role = c("aut", "cre"), comment = c(ORCID = '0000-0002-6398-9157'))
5 5
 Description: Methods and an evaluation framework for the inference of differential co-expression/association networks.
6 6
 biocViews: NetworkInference, GraphAndNetwork, DifferentialExpression, Network
... ...
@@ -13,19 +13,29 @@ colnames(x) = 1:ncol(x)
13 13
 rownames(x) = 1:nrow(x)
14 14
 cond <- rep(1:2, each = 30)
15 15
 
16
+#define methods
17
+infmethods = dcMethods()
18
+if (!require('EBcoexpress')) {
19
+  infmethods = setdiff(infmethods, 'ebcoexpress')
20
+}
21
+if (!require('COSINE')) {
22
+  infmethods = setdiff(infmethods, 'ecf')
23
+}
24
+
16 25
 test_that('Inference method calls work', {
17 26
   expect_is(dcScore(x, cond), 'matrix')
18 27
   expect_is(dcScore(x, cond, dc.method = 'zscore'), 'matrix')
19
-  for (m in setdiff(dcMethods(), 'ebcoexpress')) {
28
+  for (m in infmethods) {
20 29
     expect_is(dcScore(x, cond, !!m), 'matrix')
21 30
   }
22 31
 
23 32
   try(detach('package:EBcoexpress', unload = T), silent = TRUE)
24 33
   try(detach('package:mclust', unload = T), silent = TRUE)
25 34
   try(detach('package:minqa', unload = T), silent = TRUE)
26
-  expect_error(dcScore(x, cond, 'ebcoexpress'), 'loading the EBcoexpress library')
27
-  library(EBcoexpress)
28
-  expect_is(dcScore(x, cond, 'ebcoexpress'), 'matrix')
35
+  if(require(EBcoexpress))
36
+    expect_is(dcScore(x, cond, 'ebcoexpress'), 'matrix')
37
+  else
38
+    expect_error(dcScore(x, cond, 'ebcoexpress'), '\'EBcoexpress\' needed for this function to work')
29 39
 
30 40
   expect_error(dcScore(x, cond, 'fakemethod'), 'not TRUE')
31 41
   expect_error(dcScore(x, cond, cor.method = 'kendall'), 'not TRUE')
... ...
@@ -34,25 +44,25 @@ test_that('Inference method calls work', {
34 44
 })
35 45
 
36 46
 test_that('Correct dimensions of results', {
37
-  for (m in dcMethods()) {
47
+  for (m in infmethods) {
38 48
     expect_equal(dim(dcScore(x, cond, !!m)), c(4, 4))
39 49
   }
40 50
 })
41 51
 
42 52
 test_that('Attributes attached to results', {
43
-  for (m in dcMethods()) {
53
+  for (m in infmethods) {
44 54
     expect_equal(attr(dcScore(x, cond, !!m), 'dc.method'), m)
45 55
   }
46 56
 })
47 57
 
48 58
 test_that('Diagonals are NAs', {
49
-  for (m in dcMethods()) {
59
+  for (m in infmethods) {
50 60
     expect_equal(sum(is.na(diag(dcScore(x, cond, !!m)))), nrow(x))
51 61
   }
52 62
 })
53 63
 
54 64
 test_that('Row and column names are the same', {
55
-  for (m in dcMethods()) {
65
+  for (m in infmethods) {
56 66
     expect_equal(rownames(dcScore(x, cond, !!m)), colnames(dcScore(x, cond, !!m)))
57 67
   }
58 68
 })