Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/combine.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ NULL
setMethod("combine", c("SpatialData", "SpatialData"), \(x, y, ...) {
# ensure element names are unique across objects
old <- list(unlist(colnames(x)), unlist(colnames(y)))
idx <- rep.int(c(1, 2), vapply(old, length, integer(1)))
idx <- rep.int(c(1, 2), lengths(old))
new <- split(make.unique(unlist(old)), idx)
for (i in c(1, 2)) {
# get input element names
Expand Down
5 changes: 2 additions & 3 deletions R/crop.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ setMethod("crop", "SpatialDataArray", \(x, y, j=1, ...) {

#' @export
#' @rdname crop
#' @importFrom dplyr pull
#' @importFrom dplyr pull .data
#' @importFrom duckspatial ddbs_intersects
#' @importFrom sf st_sf st_sfc st_as_sfc st_bbox st_polygon st_geometry<-
setMethod("crop", "SpatialDataFrame", \(x, y, j=1, ...) {
Expand All @@ -225,8 +225,7 @@ setMethod("crop", "SpatialDataFrame", \(x, y, j=1, ...) {
df <- data(transform(x, j))
fd <- data(SpatialDataShape(fd))
ok <- ddbs_intersects(df, fd, sparse=TRUE)
id_x <- NULL # R CMD check
x[pull(ok, id_x), ]
x[pull(ok, .data$id_x), ]
})

#' @export
Expand Down
4 changes: 2 additions & 2 deletions R/extent.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ NULL
setMethod("extent", "SpatialData", \(x, i=1) {
ex <- .lapplyLayer(x, extent, i=i)
ex <- unlist(ex, recursive=FALSE)
xy <- do.call(rbind, lapply(ex, do.call, what=cbind))
list(x=range(xy[, 1]), y=range(xy[, 2]))
xy <- dplyr::bind_rows(ex)
list(x=range(xy$x), y=range(xy$y))
})

#' @export
Expand Down
5 changes: 2 additions & 3 deletions R/mask.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ setMethod("mask_i_by_j",
if (nrow(collect(head(ij, 1))) == 0)
stop("found no intersections",
" between shapes 'i' and 'j'")
id_x <- id_y <- NULL # R CMD check
is <- pull(ij, id_y) # elements in i
js <- pull(ij, id_x) # masks in j
is <- pull(ij, .data$id_y) # elements in i
js <- pull(ij, .data$id_x) # masks in j
na <- setdiff(seq_along(i), is)
# aggregation
mx <- assay(table, assay)
Expand Down
4 changes: 2 additions & 2 deletions R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ readSpatialData <- function(x,
stop("couldn't find ", l, " of name", .)
j <- j[opt]
}
f <- get(paste0("read", toupper(substr(l, 1, 1)), substr(l, 2, nchar(l)-1)))
lapply(j, \(.) do.call(f, list(.)))
f <- paste0("read", toupper(substr(l, 1, 1)), substr(l, 2, nchar(l)-1))
lapply(j, f)
}

names(ls) <- ls <- .LAYERS[!skip]
Expand Down
2 changes: 1 addition & 1 deletion R/sdAttrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ setMethod("$", "SpatialDataAttrs", \(x, name) x[[name]])
x$ome$version
if (!length(v)) stop("couldn't find 'version' in 'spatialdata_attrs'")
ok <- length(v) == 1 && is.character(v) && (v <- gsub("-.*", "", v)) %in% sprintf("0.%d", seq_len(6))
if (!ok) stop("invalid OME 'version'; expected '0.x' where x is 1-5")
if (!ok) stop("invalid OME 'version'; expected '0.x' where x is 1-6")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the release schedule for OME-NGFF 0.6 btw ?

return(v)
}

Expand Down
3 changes: 1 addition & 2 deletions R/sdFrame.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ SpatialDataShape <- \(data=NULL, meta=SpatialDataAttrs(type="frame"), metadata=l
#' @rdname SpatialDataFrame
#' @importFrom dplyr tally pull
setMethod("length", "SpatialDataFrame", \(x) {
n <- NULL # R CMD check
suppressWarnings(dplyr::pull(dplyr::tally(data(x)), n))
suppressWarnings(dplyr::pull(dplyr::tally(data(x)), .data$n))
})

#' @export
Expand Down
18 changes: 7 additions & 11 deletions R/validity.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@

.validateImage <- \(object) {
msg <- c()
res <- length(object)
axs <- axes(object)
typ <- vapply(axs, \(.) .$type, character(1))
d <- sum(typ != "time")
for (k in seq_len(res)) {
for (k in seq_along(object)) {
x <- data(object, k)
if (length(dim(x)) != d) msg <- c(msg, paste(
"'SpatialDataImage' resolution", k, "is not ", d, "D"))
Expand All @@ -67,11 +66,10 @@ setValidity2("SpatialDataImage", .validateImage)
#' @importFrom ZarrArray type
.validateLabel <- \(object) {
msg <- c()
res <- length(object)
axs <- axes(object)
typ <- vapply(axs, \(.) .$type, character(1))
d <- sum(typ == "space")
for (k in seq_len(res)) {
for (k in seq_along(object)) {
x <- data(object, k)
if (length(dim(x)) != d) msg <- c(msg, paste(
"'SpatialDataLabel' resolution", k, "is not ", d, "D"))
Expand All @@ -85,22 +83,20 @@ setValidity2("SpatialDataLabel", .validateLabel)

#' @importFrom dplyr count pull
.validatePoint <- \(object) {
msg <- c()
cnt <- tryCatch(error=\(.) 0, as.integer(
pull(count(spatialdataR::data(object)), "n")))
if (!cnt) return(msg)
if (!cnt) return(NULL)
if (!"geometry" %in% names(object))
msg <- c(msg, "'SpatialDataPoint' missing 'geometry'.")
return(msg)
return("'SpatialDataPoint' missing 'geometry'.")
return(NULL)
}
#' @importFrom S4Vectors setValidity2
setValidity2("SpatialDataPoint", .validatePoint)

.validateShape <- \(object) {
msg <- c()
if (!"geometry" %in% names(object))
msg <- c(msg, "'SpatialDataShape' missing 'geometry'.")
return(msg)
return("'SpatialDataShape' missing 'geometry'.")
return(NULL)
}
#' @importFrom S4Vectors setValidity2
setValidity2("SpatialDataShape", .validateShape)
Expand Down
Loading