- Small tweak to default @trans function in BSseq() and combine().
- Add unit test
... | ... |
@@ -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() |
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 |
+}) |