Skip to content

Commit d202be2

Browse files
committed
r cmd check cleaning
1 parent 6920770 commit d202be2

File tree

8 files changed

+64
-53
lines changed

8 files changed

+64
-53
lines changed

.Rbuildignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
^\.github$
12
^.*\.Rproj$
23
^\.Rproj\.user$
3-
^\.github$
44
vignettes/*html
55
vignettes/*cache
66
vignettes/*files

DESCRIPTION

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Version: 0.99.24
55
Description: Interface to Python's 'SpatialData', currently including:
66
reticulate-based use of 'spatialdata-io' for reading of manufracturer
77
data and writing to .zarr, on-disk representation of images/labels as
8-
'ZarrArray's ('Rarr') and shapes/points as 'arrow' objects, and method
9-
drafts for visualization and coordinate system handling.
8+
'ZarrArray's ('Rarr') and shapes/points as 'arrow' objects, as well
9+
as method drafts for visualization and coordinate system handling.
1010
Authors@R: c(
1111
person("Helena L.", "Crowell",
1212
role=c("aut", "cre"),
@@ -33,22 +33,19 @@ Authors@R: c(
3333
email="louise.deconinck@gmail.com",
3434
comment=c(ORCID="0000-0001-8100-6823")))
3535
Imports:
36+
anndataR,
3637
arrow,
3738
basilisk,
38-
BiocGenerics,
39+
BiocFileCache,
3940
DelayedArray,
40-
dplyr,
4141
geoarrow,
42-
graph,
43-
jsonlite,
42+
ggplot2,
4443
Matrix,
4544
methods,
4645
Rarr,
47-
RBGL,
46+
rlang,
4847
reticulate,
49-
sf,
5048
sfarrow,
51-
S4Arrays,
5249
S4Vectors,
5350
SingleCellExperiment,
5451
SummarizedExperiment
@@ -62,8 +59,6 @@ Suggests:
6259
Rgraphviz,
6360
testthat,
6461
DT
65-
Enhances:
66-
anndataR
6762
Remotes:
6863
keller-mark/anndataR@keller-mark/zarr
6964
biocViews:

NAMESPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ export(sdio_list)
2525
export(zattrs)
2626
import(geoarrow)
2727
import(ggplot2)
28+
importFrom(BiocFileCache,BiocFileCache)
29+
importFrom(BiocFileCache,bfcadd)
30+
importFrom(BiocFileCache,bfcneedsupdate)
31+
importFrom(BiocFileCache,bfcquery)
32+
importFrom(BiocFileCache,bfcupdate)
2833
importFrom(DelayedArray,realize)
2934
importFrom(Rarr,ZarrArray)
3035
importFrom(Rarr,read_zarr_attributes)
@@ -62,3 +67,4 @@ importFrom(methods,is)
6267
importFrom(rlang,.data)
6368
importFrom(sfarrow,read_sf_dataset)
6469
importFrom(utils,.DollarNames)
70+
importFrom(utils,unzip)

R/data.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ sd_osn_list <- \() {
4747
}
4848

4949
#' @rdname sd_data
50+
#' @importFrom utils unzip
51+
#' @importFrom BiocFileCache BiocFileCache
52+
#' bfcquery bfcadd bfcupdate bfcneedsupdate
5053
#' @export
5154
sd_osn_load <- \(patt,
5255
target=tempfile(),

R/misc.R

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
S4_register(SpatialData)
33

44
#' @export
5-
method(print, SpatialData) <- \(object) {
5+
method(print, SpatialData) <- \(x, ...) {
66
cat("class: SpatialData\n")
77
l <- list()
88
# images
9-
i <- names(x <- object@images)
10-
d <- lapply(x, \(.) paste(dim(.), collapse=","))
9+
i <- names(y <- x@images)
10+
d <- lapply(y, \(.) paste(dim(.), collapse=","))
1111
l <- c(l, list(images=list(i, d)))
1212
# labels
13-
i <- names(x <- object@labels)
14-
d <- lapply(x, \(.) paste(dim(.), collapse=","))
13+
i <- names(y <- x@labels)
14+
d <- lapply(y, \(.) paste(dim(.), collapse=","))
1515
l <- c(l, list(labels=list(i, d)))
1616
# points
17-
i <- names(x <- object@points)
18-
d <- vapply(x, length, integer(1))
17+
i <- names(y <- x@points)
18+
d <- vapply(y, length, integer(1))
1919
l <- c(l, list(points=list(i, d)))
2020
# shapes
21-
i <- names(x <- object@shapes)
22-
d <- vapply(x, length, integer(1))
23-
n <- vapply(x, ncol, integer(1))
21+
i <- names(y <- x@shapes)
22+
d <- vapply(y, length, integer(1))
23+
n <- vapply(y, ncol, integer(1))
2424
geom <- ifelse(n == 1, "polygon", "circle")
2525
d <- paste(d, geom, sep=",")
2626
l <- c(l, list(shapes=list(i, d)))
2727
# tables
28-
i <- names(x <- object@tables)
29-
d <- lapply(x, \(.) paste(dim(.), collapse=","))
28+
i <- names(y <- x@tables)
29+
d <- lapply(y, \(.) paste(dim(.), collapse=","))
3030
l <- c(l, list(tables=list(i, d)))
3131
# render
3232
for (. in names(l)) {
@@ -46,24 +46,23 @@ method(print, SpatialData) <- \(object) {
4646
}
4747

4848
#' @export
49-
method(print, ImageArray) <- \(object) .show_ms_array(object)
49+
method(print, ImageArray) <- \(x, ...) .show_ms_array(x)
5050

5151
#' @export
52-
method(print, LabelArray) <- \(object) .show_ms_array(object)
52+
method(print, LabelArray) <- \(x, ...) .show_ms_array(x)
5353

54-
#' @export
55-
method(print, ShapeFrame) <- \(object) {
56-
cat("class: ShapeFrame\n")
57-
cat("count:", length(object), "\n")
58-
coolcat("data(%d): %s\n", names(object))
54+
.show_sd_frame <- \(x) {
55+
. <- attr(x, "S7_class")@name
56+
cat(sprintf("class: %s\n", .))
57+
cat("count:", length(x), "\n")
58+
coolcat("data(%d): %s\n", names(x))
5959
}
6060

6161
#' @export
62-
method(print, PointFrame) <- \(object) {
63-
cat("class: PointFrame\n")
64-
cat("count:", length(object), "\n")
65-
coolcat("data(%d): %s\n", names(object))
66-
}
62+
method(print, ShapeFrame) <- \(x, ...) .show_sd_frame(x)
63+
64+
#' @export
65+
method(print, PointFrame) <- \(x, ...) .show_sd_frame(x)
6766

6867
#' @export
69-
method(print, Zattrs) <- \(object) cat(class(object))
68+
method(print, Zattrs) <- \(x, ...) cat(class(x))

R/plot-image.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ sd_plot_image <- \(x, i=1, c=NULL, ch=NULL, cl=NULL, k=NULL, w=800, h=800) {
5252
pal <- if (!.is_rgb(ia) && dim(ia)[1] > 1) {
5353
nms <- channels(ia)[ch]
5454
pal <- if (is.null(c)) .DEFAULT_COLORS else c
55-
setNames(pal[seq_along(ch)], nms)
55+
`names<-`(pal[seq_along(ch)], nms)
5656
}
5757
lgd <- if (!is.null(pal)) list(
5858
guides(col=guide_legend(override.aes=list(alpha=1, size=2))),

R/read.R

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#' path to a \code{SpatialData}.zarr store.
99
#' For \code{readImage/Label/Point/Shape/Table},
1010
#' path to a \code{SpatialData} element.
11+
#' @param images,labels,points,shapes,tables
12+
#' control which layers and elements to read;
13+
#' FALSE to skip a layer, integer or character
14+
#' vector to read some element(s).
1115
#'
1216
#' @return \code{\link{SpatialData}} object, or one of its elements.
1317
#'
@@ -25,7 +29,7 @@
2529
NULL
2630

2731
#' @importFrom S4Vectors isSequence
28-
.get_multiscales_datasets_path <- function(md) {
32+
.get_multiscales_datasets_path <- \(md) {
2933
.validate_multiscales_datasets_path(md)
3034
ps <- md$multiscales[[1]]$datasets[[1]]$path
3135
ps <- suppressWarnings(as.numeric(ps))
@@ -38,7 +42,7 @@ NULL
3842
}
3943

4044
#' @noRd
41-
.validate_multiscales_datasets_path <- function(md) {
45+
.validate_multiscales_datasets_path <- \(md) {
4246
ms <- md$multiscales
4347
if (!is.null(ms)) {
4448
ds <- ms[[1]]$datasets
@@ -60,7 +64,7 @@ NULL
6064
}
6165

6266
#' @importFrom Rarr read_zarr_attributes
63-
.read_za <- function(x, ...) {
67+
.read_za <- \(x) {
6468
md <- read_zarr_attributes(x)
6569
ps <- .get_multiscales_datasets_path(md)
6670
as <- lapply(ps, \(.) ZarrArray(file.path(x, .)))
@@ -70,24 +74,24 @@ NULL
7074
#' @rdname readSpatialData
7175
#' @importFrom Rarr ZarrArray
7276
#' @export
73-
readImage <- function(x, ...) {
74-
za <- .read_za(x, ...)
75-
ImageArray(data=za$array, zattrs=Zattrs(za$md), ...)
77+
readImage <- \(x) {
78+
za <- .read_za(x)
79+
ImageArray(data=za$array, zattrs=Zattrs(za$md))
7680
}
7781

7882
#' @rdname readSpatialData
7983
#' @importFrom Rarr ZarrArray
8084
#' @export
81-
readLabel <- function(x, ...) {
82-
za <- .read_za(x, ...)
83-
LabelArray(data=za$array, zattrs=Zattrs(za$md), ...)
85+
readLabel <- \(x) {
86+
za <- .read_za(x)
87+
LabelArray(data=za$array, zattrs=Zattrs(za$md))
8488
}
8589

8690
#' @rdname readSpatialData
8791
#' @importFrom arrow open_dataset
8892
#' @importFrom Rarr read_zarr_attributes
8993
#' @export
90-
readPoint <- function(x, ...) {
94+
readPoint <- \(x) {
9195
md <- read_zarr_attributes(x)
9296
pq <- list.files(x, "\\.parquet$", full.names=TRUE)
9397
PointFrame(data=open_dataset(pq), zattrs=Zattrs(md))
@@ -98,7 +102,7 @@ readPoint <- function(x, ...) {
98102
#' @importFrom Rarr read_zarr_attributes
99103
#' @import geoarrow
100104
#' @export
101-
readShape <- function(x, ...) {
105+
readShape <- \(x) {
102106
requireNamespace("geoarrow", quietly=TRUE)
103107
md <- read_zarr_attributes(x)
104108
# TODO: previously had read_parquet(),

man/readSpatialData.Rd

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)