Browse code

Close issue #74

- Small tweak to default @trans function in BSseq() and combine().
- Add unit test

Peter Hickey authored on 15/10/2018 05:04:53
Showing 4 changed files

... ...
@@ -1,5 +1,5 @@
1 1
 Package: bsseq
2
-Version: 1.17.5
2
+Version: 1.17.6
3 3
 Encoding: UTF-8
4 4
 Title: Analyze, manage and store bisulfite sequencing data
5 5
 Description: A collection of tools for analyzing and visualizing bisulfite
... ...
@@ -83,7 +83,7 @@ BSseq <- function(M = NULL, Cov = NULL, coef = NULL, se.coef = NULL,
83 83
     }
84 84
     # Process 'trans' and 'parameters'.
85 85
     if (is.null(trans)) {
86
-        trans <- function(x) NULL
86
+        trans <- function() NULL
87 87
     }
88 88
     if (is.null(parameters)) {
89 89
         parameters <- list()
... ...
@@ -152,7 +152,7 @@ combineList <- function(x, ..., BACKEND = NULL) {
152 152
         combine_smooths <- FALSE
153 153
         ans_coef <- NULL
154 154
         ans_se.coef <- NULL
155
-        ans_trans <- function(x) NULL
155
+        ans_trans <- function() NULL
156 156
         ans_parameters <- list()
157 157
     }
158 158
 
159 159
new file mode 100644
... ...
@@ -0,0 +1,27 @@
1
+context("GitHub issues")
2
+
3
+test_that("Issue 74 is fixed", {
4
+
5
+    # Can combine two BSseq objects with same loci but different names.
6
+    # (https://github.com/hansenlab/bsseq/issues/74#issue-341014110)
7
+    nloci <- 68164
8
+    nsamples <- 12
9
+    M <- matrix(rpois(nloci * nsamples, 10), ncol = nsamples)
10
+    Cov <- M + rpois(nloci * nsamples, 2)
11
+    gr <- sort(GRanges(
12
+        seqnames = sample(1:10, nloci, replace = TRUE),
13
+        ranges = IRanges(sample(1:10^7, nloci, replace = FALSE), width = 1)))
14
+    BS <- BSseq(M = M, Cov = Cov, gr = gr, sampleNames = paste0("V", 1:nsamples))
15
+    BS.avg <- collapseBSseq(BS, group = paste0("W", c(rep(1, 5), 2:8)))
16
+    BS.all <- combine(BS, BS.avg)
17
+    colnames(BS.all)
18
+
19
+    # As above, but when one of the BSseq objects contains additional colData.
20
+    # https://github.com/hansenlab/bsseq/issues/74#issue-341014110
21
+    BS2 <- BS
22
+    BS2$rep <- paste0("A", c(rep(1, 5), 2:8))
23
+    BS2.avg <- collapseBSseq(BS, group = paste0("W", c(rep(1, 5), 2:8)))
24
+    BS2.all <- combine(BS2,BS2.avg)
25
+    colnames(BS2.all)
26
+    colData(BS2.all)
27
+})