git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/SummarizedExperiment@118150 bc3139a8-67e5-0310-9ffc-ced21a209358
... | ... |
@@ -4,7 +4,7 @@ Description: The SummarizedExperiment container contains one or more assays, |
4 | 4 |
each represented by a matrix-like object of numeric or other mode. |
5 | 5 |
The rows typically represent genomic ranges of interest and the columns |
6 | 6 |
represent samples. |
7 |
-Version: 1.3.2 |
|
7 |
+Version: 1.3.3 |
|
8 | 8 |
Encoding: UTF-8 |
9 | 9 |
Author: Martin Morgan, Valerie Obenchain, Jim Hester, Hervé Pagès |
10 | 10 |
Maintainer: Bioconductor Package Maintainer <[email protected]> |
... | ... |
@@ -12,14 +12,13 @@ biocViews: Genetics, Infrastructure, Sequencing, Annotation, Coverage, |
12 | 12 |
GenomeAnnotation |
13 | 13 |
Depends: R (>= 3.2), methods, GenomicRanges (>= 1.23.15), Biobase |
14 | 14 |
Imports: utils, stats, BiocGenerics (>= 0.15.3), S4Vectors (>= 0.9.36), |
15 |
- IRanges (>= 2.5.26), GenomeInfoDb |
|
15 |
+ IRanges (>= 2.7.2), GenomeInfoDb |
|
16 | 16 |
Suggests: annotate, AnnotationDbi, hgu95av2.db, GenomicFeatures, |
17 | 17 |
TxDb.Hsapiens.UCSC.hg19.knownGene, BiocStyle, knitr, rmarkdown, |
18 | 18 |
digest, jsonlite, rhdf5, airway |
19 | 19 |
VignetteBuilder: knitr |
20 | 20 |
License: Artistic-2.0 |
21 |
-Collate: utils.R |
|
22 |
- Assays-class.R |
|
21 |
+Collate: Assays-class.R |
|
23 | 22 |
SummarizedExperiment-class.R |
24 | 23 |
RangedSummarizedExperiment-class.R |
25 | 24 |
intra-range-methods.R |
... | ... |
@@ -84,7 +84,6 @@ export( |
84 | 84 |
### |
85 | 85 |
|
86 | 86 |
export( |
87 |
- arbind, acbind, |
|
88 | 87 |
SummarizedExperiment, |
89 | 88 |
exptData, "exptData<-", |
90 | 89 |
rowRanges, "rowRanges<-", |
... | ... |
@@ -97,7 +96,6 @@ export( |
97 | 96 |
|
98 | 97 |
### Exactly the same list as above. |
99 | 98 |
exportMethods( |
100 |
- arbind, acbind, |
|
101 | 99 |
SummarizedExperiment, |
102 | 100 |
exptData, "exptData<-", |
103 | 101 |
rowRanges, "rowRanges<-", |
... | ... |
@@ -227,12 +227,6 @@ setReplaceMethod("[", "Assays", |
227 | 227 |
|
228 | 228 |
### rbind/cbind |
229 | 229 |
|
230 |
-setGeneric("arbind", function(...) standardGeneric("arbind")) |
|
231 |
-setGeneric("acbind", function(...) standardGeneric("acbind")) |
|
232 |
- |
|
233 |
-setMethod("arbind", "array", arbind_default) |
|
234 |
-setMethod("acbind", "array", acbind_default) |
|
235 |
- |
|
236 | 230 |
.bind_Assays <- function(lst, bind) |
237 | 231 |
{ |
238 | 232 |
if (length(lst) == 0L) |
239 | 233 |
deleted file mode 100644 |
... | ... |
@@ -1,128 +0,0 @@ |
1 |
-### ========================================================================= |
|
2 |
-### Some low-level utils |
|
3 |
-### ------------------------------------------------------------------------- |
|
4 |
-### |
|
5 |
-### Unless stated otherwise, nothing in this file is exported. |
|
6 |
-### |
|
7 |
- |
|
8 |
- |
|
9 |
-### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
10 |
-### Bind arrays with an arbitrary number of dimensions along the 1st or 2nd |
|
11 |
-### dimension |
|
12 |
-### |
|
13 |
- |
|
14 |
-### Return a matrix with one row per dim and one column per object. |
|
15 |
-.get_and_check_objects_dims <- function(objects, no.check.along) |
|
16 |
-{ |
|
17 |
- dims <- lapply(objects, dim) |
|
18 |
- ndims <- lengths(dims) |
|
19 |
- ndim <- ndims[[1L]] |
|
20 |
- if (!all(ndims == ndim)) |
|
21 |
- stop("all the objects to bind must have the same nb of dimensions") |
|
22 |
- tmp <- unlist(dims, use.names=FALSE) |
|
23 |
- if (is.null(tmp)) |
|
24 |
- stop("the objects to bind have no dimensions") |
|
25 |
- dims <- matrix(tmp, nrow=ndim) |
|
26 |
- tmp <- dims[-no.check.along, , drop=FALSE] |
|
27 |
- if (!all(tmp == tmp[ , 1L])) |
|
28 |
- stop("objects to bind have incompatible dimensions") |
|
29 |
- dims |
|
30 |
-} |
|
31 |
- |
|
32 |
-### 'objects' is assumed to be a list of vector-like objects. |
|
33 |
-### 'block_lens' is assumed to be an integer vector parallel to 'objects' |
|
34 |
-### specifying the block length for each object in 'objects'. In addition the |
|
35 |
-### length of 'object[[i]]' must be 'k * block_lens[[i]]' (k is the same for |
|
36 |
-### all the objects). |
|
37 |
-.intertwine_blocks <- function(objects, block_lens) |
|
38 |
-{ |
|
39 |
- data <- unlist(objects, recursive=FALSE, use.names=FALSE) |
|
40 |
- objects_lens <- lengths(objects) |
|
41 |
- if (all(objects_lens == 0L)) |
|
42 |
- return(data) |
|
43 |
- |
|
44 |
- k <- objects_lens %/% block_lens |
|
45 |
- k <- unique(k[!is.na(k)]) |
|
46 |
- stopifnot(length(k) == 1L) # sanity check |
|
47 |
- |
|
48 |
- nobject <- length(objects) |
|
49 |
- objects_cumlens <- cumsum(objects_lens) |
|
50 |
- ranges <- lapply(seq_len(nobject), |
|
51 |
- function(i) { |
|
52 |
- width <- block_lens[[i]] |
|
53 |
- offset <- if (i == 1L) 0L else objects_cumlens[[i - 1L]] |
|
54 |
- successiveIRanges(rep.int(width, k), from=offset + 1L) |
|
55 |
- }) |
|
56 |
- ranges <- do.call(c, ranges) |
|
57 |
- i <- as.vector(matrix(seq_len(nobject * k), nrow=nobject, byrow=TRUE)) |
|
58 |
- extractROWS(data, ranges[i]) |
|
59 |
-} |
|
60 |
- |
|
61 |
-.combine_dimnames <- function(objects, dims, along) |
|
62 |
-{ |
|
63 |
- ndim <- nrow(dims) |
|
64 |
- dimnames <- lapply(seq_len(ndim), |
|
65 |
- function(n) { |
|
66 |
- for (x in objects) { |
|
67 |
- dn <- dimnames(x)[[n]] |
|
68 |
- if (!is.null(dn)) |
|
69 |
- return(dn) |
|
70 |
- } |
|
71 |
- NULL |
|
72 |
- }) |
|
73 |
- along_names <- lapply(objects, function(x) dimnames(x)[[along]]) |
|
74 |
- along_names_lens <- lengths(along_names) |
|
75 |
- if (any(along_names_lens != 0L)) { |
|
76 |
- fix_idx <- which(along_names_lens != dims[along, ]) |
|
77 |
- along_names[fix_idx] <- lapply(dims[along, fix_idx], character) |
|
78 |
- } |
|
79 |
- along_names <- unlist(along_names, use.names=FALSE) |
|
80 |
- if (!is.null(along_names)) |
|
81 |
- dimnames[[along]] <- along_names |
|
82 |
- if (all(S4Vectors:::sapply_isNULL(dimnames))) |
|
83 |
- dimnames <- NULL |
|
84 |
- dimnames |
|
85 |
-} |
|
86 |
- |
|
87 |
-### A stripped-down version of abind::abind(). |
|
88 |
-### Some differences: |
|
89 |
-### (a) Treatment of dimnames: .simple_abind() treatment of dimnames is |
|
90 |
-### consistent with base::rbind() and base::cbind(). This is not the |
|
91 |
-### case for abind::abind() which does some strange things with the |
|
92 |
-### dimnames. |
|
93 |
-### (b) Performance: .simple_abind() has a little bit more overhead than |
|
94 |
-### abind::abind(). This makes it slower on small objects. However it |
|
95 |
-### tends to be slightly faster on big objects. |
|
96 |
-.simple_abind <- function(..., along) |
|
97 |
-{ |
|
98 |
- objects <- list(...) |
|
99 |
- object_is_NULL <- S4Vectors:::sapply_isNULL(objects) |
|
100 |
- if (any(object_is_NULL)) |
|
101 |
- objects <- objects[!object_is_NULL] |
|
102 |
- if (length(objects) == 0L) |
|
103 |
- return(NULL) |
|
104 |
- if (length(objects) == 1L) |
|
105 |
- return(objects[[1L]]) |
|
106 |
- |
|
107 |
- ## Check dim compatibility. |
|
108 |
- dims <- .get_and_check_objects_dims(objects, no.check.along=along) |
|
109 |
- |
|
110 |
- ## Perform the binding. |
|
111 |
- block_lens <- dims[along, ] |
|
112 |
- for (n in seq_len(along - 1L)) |
|
113 |
- block_lens <- block_lens * dims[n, ] |
|
114 |
- ans <- .intertwine_blocks(objects, block_lens) |
|
115 |
- |
|
116 |
- ## Set the dim. |
|
117 |
- ans_dim <- dims[ , 1L] |
|
118 |
- ans_dim[[along]] <- sum(dims[along, ]) |
|
119 |
- dim(ans) <- ans_dim |
|
120 |
- |
|
121 |
- ## Combine and set the dimnames. |
|
122 |
- dimnames(ans) <- .combine_dimnames(objects, dims, along=along) |
|
123 |
- ans |
|
124 |
-} |
|
125 |
- |
|
126 |
-arbind_default <- function(...) .simple_abind(..., along=1L) |
|
127 |
-acbind_default <- function(...) .simple_abind(..., along=2L) |
|
128 |
- |
129 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,96 +0,0 @@ |
1 |
-.TEST_matrices <- list( |
|
2 |
- matrix(1:15, nrow=3, ncol=5, |
|
3 |
- dimnames=list(NULL, paste0("M1y", 1:5))), |
|
4 |
- matrix(101:135, nrow=7, ncol=5, |
|
5 |
- dimnames=list(paste0("M2x", 1:7), paste0("M2y", 1:5))), |
|
6 |
- matrix(1001:1025, nrow=5, ncol=5, |
|
7 |
- dimnames=list(paste0("M3x", 1:5), NULL)) |
|
8 |
-) |
|
9 |
- |
|
10 |
-.TEST_arrays <- list( |
|
11 |
- array(1:60, c(3, 5, 4), |
|
12 |
- dimnames=list(NULL, paste0("M1y", 1:5), NULL)), |
|
13 |
- array(101:240, c(7, 5, 4), |
|
14 |
- dimnames=list(paste0("M2x", 1:7), paste0("M2y", 1:5), NULL)), |
|
15 |
- array(10001:10100, c(5, 5, 4), |
|
16 |
- dimnames=list(paste0("M3x", 1:5), NULL, paste0("M3z", 1:4))) |
|
17 |
-) |
|
18 |
- |
|
19 |
- |
|
20 |
-test_arbind_default <- function() |
|
21 |
-{ |
|
22 |
- arbind_default <- SummarizedExperiment:::arbind_default |
|
23 |
- |
|
24 |
- ## on matrices |
|
25 |
- target <- do.call(rbind, .TEST_matrices) |
|
26 |
- current <- do.call(arbind_default, .TEST_matrices) |
|
27 |
- checkIdentical(target, current) |
|
28 |
- |
|
29 |
- ## on empty matrices |
|
30 |
- m1 <- matrix(nrow=0, ncol=3, dimnames=list(NULL, letters[1:3])) |
|
31 |
- m2 <- matrix(1:15, ncol=3, dimnames=list(NULL, LETTERS[1:3])) |
|
32 |
- |
|
33 |
- target <- do.call(rbind, list(m1, m2)) |
|
34 |
- current <- do.call(arbind_default, list(m1, m2)) |
|
35 |
- checkIdentical(target, current) |
|
36 |
- |
|
37 |
- target <- do.call(rbind, list(m2, m1)) |
|
38 |
- current <- do.call(arbind_default, list(m2, m1)) |
|
39 |
- checkIdentical(target, current) |
|
40 |
- |
|
41 |
- target <- do.call(rbind, list(m1, m1)) |
|
42 |
- current <- do.call(arbind_default, list(m1, m1)) |
|
43 |
- checkIdentical(target, current) |
|
44 |
- |
|
45 |
- ## on arrays |
|
46 |
- current <- do.call(arbind_default, .TEST_arrays) |
|
47 |
- for (k in 1:4) { |
|
48 |
- target <- do.call(rbind, lapply(.TEST_arrays, `[`, , , k)) |
|
49 |
- checkIdentical(target, current[ , , k]) |
|
50 |
- } |
|
51 |
-} |
|
52 |
- |
|
53 |
-test_acbind_default <- function() |
|
54 |
-{ |
|
55 |
- acbind_default <- SummarizedExperiment:::acbind_default |
|
56 |
- |
|
57 |
- ## on matrices |
|
58 |
- matrices <- lapply(.TEST_matrices, t) |
|
59 |
- target <- do.call(cbind, matrices) |
|
60 |
- current <- do.call(acbind_default, matrices) |
|
61 |
- checkIdentical(target, current) |
|
62 |
- |
|
63 |
- ## on empty matrices |
|
64 |
- m1 <- matrix(nrow=3, ncol=0, dimnames=list(letters[1:3], NULL)) |
|
65 |
- m2 <- matrix(1:15, nrow=3, dimnames=list(LETTERS[1:3], NULL)) |
|
66 |
- |
|
67 |
- target <- do.call(cbind, list(m1, m2)) |
|
68 |
- current <- do.call(acbind_default, list(m1, m2)) |
|
69 |
- checkIdentical(target, current) |
|
70 |
- |
|
71 |
- target <- do.call(cbind, list(m2, m1)) |
|
72 |
- current <- do.call(acbind_default, list(m2, m1)) |
|
73 |
- checkIdentical(target, current) |
|
74 |
- |
|
75 |
- target <- do.call(cbind, list(m1, m1)) |
|
76 |
- current <- do.call(acbind_default, list(m1, m1)) |
|
77 |
- checkIdentical(target, current) |
|
78 |
- |
|
79 |
- ## on arrays |
|
80 |
- |
|
81 |
- ## transpose the 1st 2 dimensions |
|
82 |
- arrays <- lapply(.TEST_arrays, |
|
83 |
- function(a) { |
|
84 |
- a_dimnames <- dimnames(a) |
|
85 |
- dim(a)[1:2] <- dim(a)[2:1] |
|
86 |
- a_dimnames[1:2] <- a_dimnames[2:1] |
|
87 |
- dimnames(a) <- a_dimnames |
|
88 |
- a |
|
89 |
- }) |
|
90 |
- current <- do.call(acbind_default, arrays) |
|
91 |
- for (k in 1:4) { |
|
92 |
- target <- do.call(cbind, lapply(arrays, `[`, , , k)) |
|
93 |
- checkIdentical(target, current[ , , k]) |
|
94 |
- } |
|
95 |
-} |
|
96 |
- |
... | ... |
@@ -12,10 +12,6 @@ |
12 | 12 |
\alias{dim,Assays-method} |
13 | 13 |
\alias{[,Assays,ANY-method} |
14 | 14 |
\alias{[<-,Assays,ANY,ANY,ANY-method} |
15 |
-\alias{arbind} |
|
16 |
-\alias{acbind} |
|
17 |
-\alias{arbind,array-method} |
|
18 |
-\alias{acbind,array-method} |
|
19 | 15 |
\alias{rbind,Assays-method} |
20 | 16 |
\alias{cbind,Assays-method} |
21 | 17 |
|