Browse code

Other issue

Emanuel Soda authored on 24/04/2022 17:14:38
Showing1 changed files
... ...
@@ -4,119 +4,119 @@ data <- count_table
4 4
 annotaion <- annotation_table
5 5
 
6 6
 groups <- factor(c(
7
-  "T1/T2", "T1/T2", "Treated", "Treated", "Treated",
8
-  "Control", "Control", "Control", "Treated", "Treated", "Treated",
9
-  "Control", "Control", "Control"
7
+    "T1/T2", "T1/T2", "Treated", "Treated", "Treated",
8
+    "Control", "Control", "Control", "Treated", "Treated", "Treated",
9
+    "Control", "Control", "Control"
10 10
 ))
11 11
 
12 12
 
13 13
 palette <- c(
14
-  "#1B9E75", "#1B9E75", "#D95F02", "#D95F02", "#D95F02",
15
-  "#7570B3", "#7570B3", "#7570B3", "#E7298A", "#E7298A", "#E7298A",
16
-  "#66A61E", "#66A61E", "#66A61E"
14
+    "#1B9E75", "#1B9E75", "#D95F02", "#D95F02", "#D95F02",
15
+    "#7570B3", "#7570B3", "#7570B3", "#E7298A", "#E7298A", "#E7298A",
16
+    "#66A61E", "#66A61E", "#66A61E"
17 17
 )
18 18
 
19 19
 create_test_object <- function() {
20
-  data <- data %>%
21
-    dplyr::filter(Barcode != "*")
22
-
23
-  colnames(data) <- c(
24
-    "Barcode", "T1", "T2", "Time3_TRT_A", "Time3_TRT_B", "Time3_TRT_C",
25
-    "Time3_A", "Time3_B", "Time3_C", "Time4_TRT_A", "Time4_TRT_B",
26
-    "Time4_TRT_C", "Time4_A", "Time4_B", "Time4_c"
27
-  )
28
-  obj <- create_screenr_object(
29
-    table = data,
30
-    annotation = annotaion, groups = groups, replicates = c("")
31
-  )
32
-  obj <- normalize_data(obj)
33
-  obj <- compute_data_table(obj)
34
-
35
-  obj@data_table <- obj@data_table  %>%
36
-    dplyr::filter(Gene %in% paste0("Gene_", seq(1, 10)))
37
-
38
-  obj@normalized_count_table <- obj@normalized_count_table   %>%
39
-    dplyr::filter(Barcode %in% obj@data_table$Barcode)
40
-
41
-  obj@count_table <- obj@count_table   %>%
42
-    dplyr::filter(Barcode %in% obj@data_table$Barcode)
43
-
44
-  obj@annotation_table <- obj@annotation_table   %>%
45
-    dplyr::filter(Barcode %in% obj@data_table$Barcode)
46
-
47
-  return(obj)
20
+    data <- data %>%
21
+        dplyr::filter(Barcode != "*")
22
+
23
+    colnames(data) <- c(
24
+        "Barcode", "T1", "T2", "Time3_TRT_A", "Time3_TRT_B", "Time3_TRT_C",
25
+        "Time3_A", "Time3_B", "Time3_C", "Time4_TRT_A", "Time4_TRT_B",
26
+        "Time4_TRT_C", "Time4_A", "Time4_B", "Time4_c"
27
+    )
28
+    obj <- create_screenr_object(
29
+        table = data,
30
+        annotation = annotaion, groups = groups, replicates = c("")
31
+    )
32
+    obj <- normalize_data(obj)
33
+    obj <- compute_data_table(obj)
34
+
35
+    obj@data_table <- obj@data_table %>%
36
+        dplyr::filter(Gene %in% paste0("Gene_", seq(1, 10)))
37
+
38
+    obj@normalized_count_table <- obj@normalized_count_table %>%
39
+        dplyr::filter(Barcode %in% obj@data_table$Barcode)
40
+
41
+    obj@count_table <- obj@count_table %>%
42
+        dplyr::filter(Barcode %in% obj@data_table$Barcode)
43
+
44
+    obj@annotation_table <- obj@annotation_table %>%
45
+        dplyr::filter(Barcode %in% obj@data_table$Barcode)
46
+
47
+    return(obj)
48 48
 }
49 49
 
50 50
 test_that("Compute Metrics ", {
51
-  object <- create_test_object()
52
-
53
-  # In order to speed up the test we will compute the metrics only for a
54
-  # subset of the genes
55
-  genes <- c("Gene_1", "Gene_5")
56
-  object@data_table <- object@data_table[object@data_table$Gene %in% genes, ]
57
-  table <- compute_metrics(object,
58
-                           treatment = "TRT", control = "Time3",
59
-                           day = "Time3"
60
-  )
61
-  expect_equal(class(table)[1], "tbl_df")
51
+    object <- create_test_object()
52
+
53
+    # In order to speed up the test we will compute the metrics only for a
54
+    # subset of the genes
55
+    genes <- c("Gene_1", "Gene_5")
56
+    object@data_table <- object@data_table[object@data_table$Gene %in% genes, ]
57
+    table <- compute_metrics(object,
58
+        treatment = "TRT", control = "Time3",
59
+        day = "Time3"
60
+    )
61
+    expect_equal(class(table)[1], "tbl_df")
62 62
 })
63 63
 
64 64
 test_that("Camera", {
65
-  object <- create_test_object()
66
-
67
-  matrix <- model.matrix(~ object@groups)
68
-  colnames(matrix) <- c("Control", "T1/T2", "Treated")
69
-  camera_hit <- suppressWarnings(find_camera_hit(
70
-    screenR_Object = object,
71
-    matrix_model = matrix, contrast = "Treated"
72
-  ))
73
-  expect_equal(class(camera_hit)[1], "tbl_df")
65
+    object <- create_test_object()
66
+
67
+    matrix <- model.matrix(~ object@groups)
68
+    colnames(matrix) <- c("Control", "T1/T2", "Treated")
69
+    camera_hit <- suppressWarnings(find_camera_hit(
70
+        screenR_Object = object,
71
+        matrix_model = matrix, contrast = "Treated"
72
+    ))
73
+    expect_equal(class(camera_hit)[1], "tbl_df")
74 74
 })
75 75
 
76 76
 
77 77
 
78 78
 test_that("Number of Barcode Lost", {
79
-  library(tibble)
80
-
81
-  object <- create_screenr_object(
82
-    table = data,
83
-    annotation = annotaion, groups = groups, replicates = c("")
84
-  )
85
-  barcode_lost <- barcode_lost(object)
86
-  expect_equal(is_tibble(barcode_lost), TRUE)
79
+    library(tibble)
80
+
81
+    object <- create_screenr_object(
82
+        table = data,
83
+        annotation = annotaion, groups = groups, replicates = c("")
84
+    )
85
+    barcode_lost <- barcode_lost(object)
86
+    expect_equal(is_tibble(barcode_lost), TRUE)
87 87
 })
88 88
 
89 89
 
90 90
 test_that("Create data_table", {
91
-  object <- create_screenr_object(
92
-    table = data,
93
-    annotation = annotaion, groups = groups, replicates = c("")
94
-  )
95
-  object <- normalize_data(object)
91
+    object <- create_screenr_object(
92
+        table = data,
93
+        annotation = annotaion, groups = groups, replicates = c("")
94
+    )
95
+    object <- normalize_data(object)
96 96
 
97 97
 
98
-  object <- compute_data_table(object)
99
-  expect_equal(class(object@data_table)[1], "tbl_df")
98
+    object <- compute_data_table(object)
99
+    expect_equal(class(object@data_table)[1], "tbl_df")
100 100
 })
101 101
 
102 102
 
103 103
 test_that("Normalize Data", {
104
-  object <- create_screenr_object(
105
-    table = data,
106
-    annotation = annotaion, groups = groups, replicates = c("")
107
-  )
104
+    object <- create_screenr_object(
105
+        table = data,
106
+        annotation = annotaion, groups = groups, replicates = c("")
107
+    )
108 108
 
109
-  object <- normalize_data(object)
110
-  expect_equal(dim(object@count_table), dim(object@normalized_count_table))
109
+    object <- normalize_data(object)
110
+    expect_equal(dim(object@count_table), dim(object@normalized_count_table))
111 111
 })
112 112
 
113 113
 test_that("Number mapped reads", {
114
-  library(tibble)
115
-  object <- create_screenr_object(
116
-    table = data,
117
-    annotation = annotaion, groups = groups, replicates = c("")
118
-  )
119
-  mapped <- mapped_reads(object)
120
-
121
-  expect_equal(is_tibble(mapped), TRUE)
114
+    library(tibble)
115
+    object <- create_screenr_object(
116
+        table = data,
117
+        annotation = annotaion, groups = groups, replicates = c("")
118
+    )
119
+    mapped <- mapped_reads(object)
120
+
121
+    expect_equal(is_tibble(mapped), TRUE)
122 122
 })
Browse code

addressing other issue

Emanuel Soda authored on 24/04/2022 16:12:04
Showing1 changed files
... ...
@@ -25,7 +25,7 @@ create_test_object <- function() {
25 25
     "Time3_A", "Time3_B", "Time3_C", "Time4_TRT_A", "Time4_TRT_B",
26 26
     "Time4_TRT_C", "Time4_A", "Time4_B", "Time4_c"
27 27
   )
28
-  obj <- create_screenR_object(
28
+  obj <- create_screenr_object(
29 29
     table = data,
30 30
     annotation = annotaion, groups = groups, replicates = c("")
31 31
   )
... ...
@@ -78,7 +78,7 @@ test_that("Camera", {
78 78
 test_that("Number of Barcode Lost", {
79 79
   library(tibble)
80 80
 
81
-  object <- create_screenR_object(
81
+  object <- create_screenr_object(
82 82
     table = data,
83 83
     annotation = annotaion, groups = groups, replicates = c("")
84 84
   )
... ...
@@ -88,7 +88,7 @@ test_that("Number of Barcode Lost", {
88 88
 
89 89
 
90 90
 test_that("Create data_table", {
91
-  object <- create_screenR_object(
91
+  object <- create_screenr_object(
92 92
     table = data,
93 93
     annotation = annotaion, groups = groups, replicates = c("")
94 94
   )
... ...
@@ -101,7 +101,7 @@ test_that("Create data_table", {
101 101
 
102 102
 
103 103
 test_that("Normalize Data", {
104
-  object <- create_screenR_object(
104
+  object <- create_screenr_object(
105 105
     table = data,
106 106
     annotation = annotaion, groups = groups, replicates = c("")
107 107
   )
... ...
@@ -112,7 +112,7 @@ test_that("Normalize Data", {
112 112
 
113 113
 test_that("Number mapped reads", {
114 114
   library(tibble)
115
-  object <- create_screenR_object(
115
+  object <- create_screenr_object(
116 116
     table = data,
117 117
     annotation = annotaion, groups = groups, replicates = c("")
118 118
   )
Browse code

addressed reviews issue

Emanuel Soda authored on 23/04/2022 18:12:48
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,122 @@
1
+data("count_table", package = "ScreenR")
2
+data("annotation_table", package = "ScreenR")
3
+data <- count_table
4
+annotaion <- annotation_table
5
+
6
+groups <- factor(c(
7
+  "T1/T2", "T1/T2", "Treated", "Treated", "Treated",
8
+  "Control", "Control", "Control", "Treated", "Treated", "Treated",
9
+  "Control", "Control", "Control"
10
+))
11
+
12
+
13
+palette <- c(
14
+  "#1B9E75", "#1B9E75", "#D95F02", "#D95F02", "#D95F02",
15
+  "#7570B3", "#7570B3", "#7570B3", "#E7298A", "#E7298A", "#E7298A",
16
+  "#66A61E", "#66A61E", "#66A61E"
17
+)
18
+
19
+create_test_object <- function() {
20
+  data <- data %>%
21
+    dplyr::filter(Barcode != "*")
22
+
23
+  colnames(data) <- c(
24
+    "Barcode", "T1", "T2", "Time3_TRT_A", "Time3_TRT_B", "Time3_TRT_C",
25
+    "Time3_A", "Time3_B", "Time3_C", "Time4_TRT_A", "Time4_TRT_B",
26
+    "Time4_TRT_C", "Time4_A", "Time4_B", "Time4_c"
27
+  )
28
+  obj <- create_screenR_object(
29
+    table = data,
30
+    annotation = annotaion, groups = groups, replicates = c("")
31
+  )
32
+  obj <- normalize_data(obj)
33
+  obj <- compute_data_table(obj)
34
+
35
+  obj@data_table <- obj@data_table  %>%
36
+    dplyr::filter(Gene %in% paste0("Gene_", seq(1, 10)))
37
+
38
+  obj@normalized_count_table <- obj@normalized_count_table   %>%
39
+    dplyr::filter(Barcode %in% obj@data_table$Barcode)
40
+
41
+  obj@count_table <- obj@count_table   %>%
42
+    dplyr::filter(Barcode %in% obj@data_table$Barcode)
43
+
44
+  obj@annotation_table <- obj@annotation_table   %>%
45
+    dplyr::filter(Barcode %in% obj@data_table$Barcode)
46
+
47
+  return(obj)
48
+}
49
+
50
+test_that("Compute Metrics ", {
51
+  object <- create_test_object()
52
+
53
+  # In order to speed up the test we will compute the metrics only for a
54
+  # subset of the genes
55
+  genes <- c("Gene_1", "Gene_5")
56
+  object@data_table <- object@data_table[object@data_table$Gene %in% genes, ]
57
+  table <- compute_metrics(object,
58
+                           treatment = "TRT", control = "Time3",
59
+                           day = "Time3"
60
+  )
61
+  expect_equal(class(table)[1], "tbl_df")
62
+})
63
+
64
+test_that("Camera", {
65
+  object <- create_test_object()
66
+
67
+  matrix <- model.matrix(~ object@groups)
68
+  colnames(matrix) <- c("Control", "T1/T2", "Treated")
69
+  camera_hit <- suppressWarnings(find_camera_hit(
70
+    screenR_Object = object,
71
+    matrix_model = matrix, contrast = "Treated"
72
+  ))
73
+  expect_equal(class(camera_hit)[1], "tbl_df")
74
+})
75
+
76
+
77
+
78
+test_that("Number of Barcode Lost", {
79
+  library(tibble)
80
+
81
+  object <- create_screenR_object(
82
+    table = data,
83
+    annotation = annotaion, groups = groups, replicates = c("")
84
+  )
85
+  barcode_lost <- barcode_lost(object)
86
+  expect_equal(is_tibble(barcode_lost), TRUE)
87
+})
88
+
89
+
90
+test_that("Create data_table", {
91
+  object <- create_screenR_object(
92
+    table = data,
93
+    annotation = annotaion, groups = groups, replicates = c("")
94
+  )
95
+  object <- normalize_data(object)
96
+
97
+
98
+  object <- compute_data_table(object)
99
+  expect_equal(class(object@data_table)[1], "tbl_df")
100
+})
101
+
102
+
103
+test_that("Normalize Data", {
104
+  object <- create_screenR_object(
105
+    table = data,
106
+    annotation = annotaion, groups = groups, replicates = c("")
107
+  )
108
+
109
+  object <- normalize_data(object)
110
+  expect_equal(dim(object@count_table), dim(object@normalized_count_table))
111
+})
112
+
113
+test_that("Number mapped reads", {
114
+  library(tibble)
115
+  object <- create_screenR_object(
116
+    table = data,
117
+    annotation = annotaion, groups = groups, replicates = c("")
118
+  )
119
+  mapped <- mapped_reads(object)
120
+
121
+  expect_equal(is_tibble(mapped), TRUE)
122
+})