|
| 1 | +#' @importFrom S4Vectors SimpleList |
1 | 2 | #' @importFrom methods setClass setClassUnion setOldClass |
2 | 3 |
|
| 4 | +.sdLayerList <- setClass( |
| 5 | + Class="sdLayerList", |
| 6 | + contains="SimpleList", |
| 7 | + slots=c(metadata="list"), |
| 8 | + prototype=prototype(metadata=list())) |
| 9 | + |
| 10 | +.sdImageList <- setClass( |
| 11 | + Class="sdImageList", |
| 12 | + contains="sdLayerList", |
| 13 | + prototype=prototype(elementType="SpatialDataImage")) |
| 14 | + |
| 15 | +.sdLabelList <- setClass( |
| 16 | + Class="sdLabelList", |
| 17 | + contains="sdLayerList", |
| 18 | + prototype=prototype(elementType="SpatialDataLabel")) |
| 19 | + |
| 20 | +.sdPointList <- setClass( |
| 21 | + Class="sdPointList", |
| 22 | + contains="sdLayerList", |
| 23 | + prototype=prototype(elementType="SpatialDataPoint")) |
| 24 | + |
| 25 | +.sdShapeList <- setClass( |
| 26 | + Class="sdShapeList", |
| 27 | + contains="sdLayerList", |
| 28 | + prototype=prototype(elementType="SpatialDataShape")) |
| 29 | + |
| 30 | +.sdTableList <- setClass( |
| 31 | + Class="sdTableList", |
| 32 | + contains="sdLayerList", |
| 33 | + prototype=prototype(elementType="SingleCellExperiment")) |
| 34 | + |
| 35 | +.sl <- S4Vectors:::new_SimpleList_from_list |
| 36 | +.ok <- \(x) length(x) == 1L && (is.list(x[[1L]]) || is(x[[1L]], "SimpleList")) |
| 37 | + |
| 38 | +sdImageList <- \(...) { |
| 39 | + x <- list(...) |
| 40 | + if (.ok(x)) x <- x[[1L]] |
| 41 | + .sl("sdImageList", as.list(x)) |
| 42 | +} |
| 43 | + |
| 44 | +sdLabelList <- \(...) { |
| 45 | + x <- list(...) |
| 46 | + if (.ok(x)) x <- x[[1L]] |
| 47 | + .sl("sdLabelList", as.list(x)) |
| 48 | +} |
| 49 | + |
| 50 | +sdPointList <- \(...) { |
| 51 | + x <- list(...) |
| 52 | + if (.ok(x)) x <- x[[1L]] |
| 53 | + .sl("sdPointList", as.list(x)) |
| 54 | +} |
| 55 | + |
| 56 | +sdShapeList <- \(...) { |
| 57 | + x <- list(...) |
| 58 | + if (.ok(x)) x <- x[[1L]] |
| 59 | + .sl("sdShapeList", as.list(x)) |
| 60 | +} |
| 61 | + |
| 62 | +sdTableList <- \(...) { |
| 63 | + x <- list(...) |
| 64 | + if (.ok(x)) x <- x[[1L]] |
| 65 | + .sl("sdTableList", as.list(x)) |
| 66 | +} |
| 67 | + |
3 | 68 | #' @export |
4 | 69 | #' @rdname SpatialData |
5 | 70 | .SpatialData <- setClass( |
6 | 71 | Class="SpatialData", |
7 | 72 | contains=c("list", "Annotated"), |
8 | 73 | representation( |
9 | | - images="list", # 'SpatialDataImage's |
10 | | - labels="list", # 'SpatialDataLabel's |
11 | | - points="list", # 'SpatialDataPoint's |
12 | | - shapes="list", # 'SpatialDataShape's |
13 | | - tables="list")) # 'SingleCellExperiment's |
| 74 | + images="sdImageList", |
| 75 | + labels="sdLabelList", |
| 76 | + points="sdPointList", |
| 77 | + shapes="sdShapeList", |
| 78 | + tables="sdTableList")) |
14 | 79 |
|
15 | 80 | .LAYERS <- `names<-`(. <- c("images","labels","points","shapes","tables"), .) |
16 | 81 | .SpatialDataAttrs <- setClass("SpatialDataAttrs", contains="list") |
|
0 commit comments