-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathSpatialDataArray.Rd
More file actions
113 lines (91 loc) · 2.79 KB
/
Copy pathSpatialDataArray.Rd
File metadata and controls
113 lines (91 loc) · 2.79 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sdArray.R
\name{SpatialDataArray}
\alias{SpatialDataArray}
\alias{data_type}
\alias{channels}
\alias{SpatialDataImage}
\alias{SpatialDataLabel}
\alias{dim,SpatialDataArray-method}
\alias{length,SpatialDataArray-method}
\alias{data_type,SpatialDataArray-method}
\alias{data_type,DelayedArray-method}
\alias{channels,SpatialDataAttrs-method}
\alias{channels,SpatialDataImage-method}
\alias{channels,SpatialDataElement-method}
\alias{.sub_sda}
\title{\code{SpatialDataArray}}
\usage{
SpatialDataImage(
data = list(),
meta = SpatialDataAttrs(),
metadata = list(),
...
)
SpatialDataLabel(
data = list(),
meta = SpatialDataAttrs(),
metadata = list(),
...
)
\S4method{dim}{SpatialDataArray}(x)
\S4method{length}{SpatialDataArray}(x)
\S4method{data_type}{SpatialDataArray}(x)
\S4method{data_type}{DelayedArray}(x)
\S4method{channels}{SpatialDataAttrs}(x, ...)
\S4method{channels}{SpatialDataImage}(x, ...)
\S4method{channels}{SpatialDataElement}(x, ...)
.sub_sda(x, yx, z = list())
}
\arguments{
\item{data}{list of \code{ZarrArray}s}
\item{meta}{\code{\link{SpatialDataAttrs}}}
\item{metadata}{optional list of arbitrary additional content.}
\item{...}{option arguments passed to and from other methods.}
\item{x}{\code{SpatialDataArray}}
\item{i, j, k}{indices specifying elements/slices to extract.}
\item{drop}{ignored.}
}
\value{
\code{SpatialDataArray}
}
\description{
The \code{SpatialDataImage} and \code{-Label} classes represent
elements from a \code{SpatialData}'s \code{images/} and \code{labels/}
layers, respectively. In both cases, these are represented as a
\code{ZarrArray} (\code{data} slot), and associated with .zattrs
represented as \code{\link{SpatialDataAttrs}} (\code{meta} slot);
a list of \code{metadata} stores other arbitrary info.
Currently defined methods (here, \code{x} is a \code{SpatialDataArray}):
\itemize{
\item \code{data/meta(x)} access underlying data/.zattrs
\item \code{data_type(x)} gets the underlying data type (e.g., float64)
\item \code{channels(x)} gets channel names (applies to images only)
\item \code{dim(x)} returns the dimensions of \code{data(x)}
\item \code{length(x)} returns the length of \code{data(x)}
}
}
\examples{
zs <- file.path("extdata", "blobs.zarr")
zs <- system.file(zs, package="spatialdataR")
# get path to 'i'th element in layer 'l'
fn <- \(l, i=1) list.dirs(file.path(zs, l), recursive=FALSE)[i]
# label
(x <- readLabel(fn("labels")))
x[1:10, 1:10]
meta(x)
# image
readImage(fn("images"))
# multi-scale
(x <- readImage(fn("images", 2)))
channels(x)
dim(data(x, 1)) # highest res.
dim(data(x, Inf)) # lowest res.
# RGB visual
rgb <- apply(
data(x, 1), c(2, 3),
\(.) rgb(.[1], .[2], .[3]))
plot(
row(rgb), col(rgb), col=rgb,
pch=15, asp=1, ylim=c(ncol(rgb), 0))
}