diff --git a/R/combine.R b/R/combine.R index 49eadcc4..ec7c9af1 100644 --- a/R/combine.R +++ b/R/combine.R @@ -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 diff --git a/R/crop.R b/R/crop.R index 8df0909f..79e7d58c 100644 --- a/R/crop.R +++ b/R/crop.R @@ -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, ...) { @@ -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 diff --git a/R/extent.R b/R/extent.R index 382fc9ec..a9115405 100644 --- a/R/extent.R +++ b/R/extent.R @@ -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 diff --git a/R/mask.R b/R/mask.R index b94545ea..e62d04bf 100644 --- a/R/mask.R +++ b/R/mask.R @@ -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) diff --git a/R/read.R b/R/read.R index 101e5bb2..7044fe91 100644 --- a/R/read.R +++ b/R/read.R @@ -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] diff --git a/R/sdAttrs.R b/R/sdAttrs.R index 7f6ae526..4df79b28 100644 --- a/R/sdAttrs.R +++ b/R/sdAttrs.R @@ -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") return(v) } diff --git a/R/sdFrame.R b/R/sdFrame.R index 6f2a177e..c194d6af 100644 --- a/R/sdFrame.R +++ b/R/sdFrame.R @@ -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 diff --git a/R/validity.R b/R/validity.R index d609fc92..bad6a6ea 100644 --- a/R/validity.R +++ b/R/validity.R @@ -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")) @@ -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")) @@ -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)