File: show.R

package info (click to toggle)
r-bioc-spatialexperiment 1.16.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,648 kB
  • sloc: makefile: 2
file content (66 lines) | stat: -rw-r--r-- 1,928 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#' @name SpatialExperiment-misc
#' 
#' @title Miscellaneous SpatialExperiment methods
#' 
#' @description
#' Miscellaneous methods for the \code{\link{SpatialExperiment}} class and its
#' descendants that do not fit into any other documentation category such as,
#' for example, show methods.
#' 
#' @param object a \code{\link{SpatialExperiment}} object
#' 
#' @return Returns NULL
#' 
#' @author Dario Righelli and Helena L. Crowell
#' 
#' @examples
#' example(read10xVisium)
#' spe
NULL

# SpatialExperiment show method ------------------------------------------------

#' @importFrom S4Vectors coolcat
#' @importFrom methods callNextMethod
.spe_show <- function(object) {
    callNextMethod()
    coolcat("spatialCoords names(%d) : %s\n", spatialCoordsNames(object))
    coolcat("imgData names(%d): %s\n", names(imgData(object)))
}

#' @rdname SpatialExperiment-misc
setMethod("show", "SpatialExperiment", .spe_show)

# SpatialImage show method -----------------------------------------------------

#' @name SpatialImage-misc
#' @title Miscellaneous \code{SpatialImage} methods
#' 
#' @description
#' Miscellaneous methods for the \code{\link{SpatialImage}} class that do not
#' fit into any other documentation category such as, for example, show methods.
#' 
#' @param object a \code{SpatialImage} object
#' 
#' @return none
#' 
#' @author Helena L. Crowell
NULL

.spi_show <- function(object) {
    dim <- paste(rev(dim(object)), collapse=" x ")
    str <- paste0(dim, " (width x height) ", class(object), "\n")
    cat(str)
    str <- imgSource(object)
    if (!is.na(str)) {
        if (nchar(str) > 80) {
            ss <- strsplit(str, "")[[1]]
            ss <- split(ss, ceiling(seq_along(ss)/80))
            str <- paste(lapply(ss, paste, collapse=""), collapse="\n  ")
        }
        cat("imgSource():\n ", str, "\n")
    }
}

#' @rdname SpatialImage-misc
setMethod("show", "VirtualSpatialImage", .spi_show)