diff --git a/DESCRIPTION b/DESCRIPTION
index e2afed9..2194d94 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: SpatialData.plot
Title: SpatialData visualization
Depends: R (>= 4.6), SpatialData
-Version: 0.99.5
+Version: 0.99.6
Description: Visualization suit for 'SpatialData' (R). Current functionality
includes handling of multiscale 'images', visualizing 'labels', 'points',
and 'shapes'. For the latter, POINT, POLYGON, and MULTIPOLYGON geometries
diff --git a/R/plotFrame.R b/R/plotFrame.R
index c45709e..4dc5940 100644
--- a/R/plotFrame.R
+++ b/R/plotFrame.R
@@ -6,7 +6,7 @@
#' @param i character string or index; the label element to plot.
#' @param assay character string; in case of \code{c} denoting a row name,
#' specifies which \code{assay} data to use (see \code{\link{valTable}}).
-#' (ignored when \code{x} is a \code{PointFrame}).
+#' (ignored when \code{x} is a \code{SpatialDataPoint}).
#'
#' @examples
#' x <- file.path("extdata", "blobs.zarr")
@@ -38,18 +38,19 @@ NULL
#' @importFrom ggplot2 aes theme scale_type geom_sf coord_sf
#' @importFrom SpatialData transform
#' @importFrom ggforce geom_circle
+#' @importFrom methods is
#' @importFrom utils tail
.plot <- \(x, y, key=NULL, n=Inf, assay=1, i=1, ...) {
- if (is(y, "PointFrame")) {
+ if (is(y, "SpatialDataPoint")) {
if (!is.null(key)) {
fk <- feature_key(y)
- y@data <- dplyr::filter(data(y), .data[[fk]] %in% key)
+ y<- dplyr::filter(y, .data[[fk]] %in% key)
}
}
if (is.finite(n)) {
n <- min(length(y), n)
y <- y[sample(length(y), n)]
- if (is(y, "ShapeFrame")) {
+ if (is(y, "SpatialDataShape")) {
shape(x, i) <- y
} else {
point(x, i) <- y
@@ -72,11 +73,14 @@ NULL
if (val %in% names(df)) {
if (scale_type(df[[arg]]) == "discrete")
df[[val]] <- factor(df[[arg]])
- aes[[arg]] <- aes(.data[[val]])[[1]]
+ col <- match(arg, c("col", "color", "colour"))
+ .arg <- ifelse(!is.na(col), "colour", arg)
+ aes[[.arg]] <- aes(.data[[val]])[[1]]
dot[[arg]] <- NULL
}
}
}
+
if ("radius" %in% names(df))
df <- st_buffer(df, df$radius)
list(
diff --git a/R/plotImage.R b/R/plotImage.R
index 8ba581d..7b1fb65 100644
--- a/R/plotImage.R
+++ b/R/plotImage.R
@@ -12,7 +12,7 @@
#' 800 x 800px; use Inf to plot the lowest resolution available.
#' @param ch image channel(s) to be used for plotting (defaults to
#' the first channel(s) available); use \code{channels()} to see
-#' which channels are available for a given \code{ImageArray}
+#' which channels are available for a given \code{SpatialDataImage}
#' @param c character vector; colors to use for each channel.
#' @param cl list of length-2 numeric vectors (non-negative, increasing);
#' specifies channel-wise contrast limits - defaults to [0, 1] for all
@@ -128,7 +128,7 @@ NULL
#' @importFrom methods is
#' @noRd
.is_rgb <- \(x) {
- if (is(x, "ImageArray") &&
+ if (is(x, "SpatialDataImage") &&
!is.null(md <- meta(x)))
x <- channels(x)
if (!is.vector(x)) stop("invalid 'x'")
diff --git a/inst/NEWS b/inst/NEWS
index 6626510..80598d1 100644
--- a/inst/NEWS
+++ b/inst/NEWS
@@ -1,3 +1,10 @@
+changes in version 0.99.6
+
+- renaming of 'SpatialData' classes
+- improved visualization of labels
+- fixed auto-contrasting for HnE images
+- fixed channel-merging for multi-plex images
+
changes in version 0.99.5
- fix visualization of circles
diff --git a/man/plotFrame.Rd b/man/plotFrame.Rd
index 5d1835a..e424c18 100644
--- a/man/plotFrame.Rd
+++ b/man/plotFrame.Rd
@@ -19,7 +19,7 @@
\item{assay}{character string; in case of \code{c} denoting a row name,
specifies which \code{assay} data to use (see \code{\link{valTable}}).
-(ignored when \code{x} is a \code{PointFrame}).}
+(ignored when \code{x} is a \code{SpatialDataPoint}).}
}
\description{
\code{SpatialData} point/shape viz.
diff --git a/man/plotImage.Rd b/man/plotImage.Rd
index 7657221..27786ff 100644
--- a/man/plotImage.Rd
+++ b/man/plotImage.Rd
@@ -23,7 +23,7 @@ scale in order to minimize memory-usage and blurring for a target size of
\item{ch}{image channel(s) to be used for plotting (defaults to
the first channel(s) available); use \code{channels()} to see
-which channels are available for a given \code{ImageArray}}
+which channels are available for a given \code{SpatialDataImage}}
\item{c}{character vector; colors to use for each channel.}
diff --git a/tests/testthat/_snaps/plotSpatialData/overlays.svg b/tests/testthat/_snaps/plotSpatialData/overlays.svg
index 3e84c58..7679270 100644
--- a/tests/testthat/_snaps/plotSpatialData/overlays.svg
+++ b/tests/testthat/_snaps/plotSpatialData/overlays.svg
@@ -20,2291 +20,2296 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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points
-overlays
+10
+20
+30
+40
+50
+60
+
+
+
+
+
+
+
+
+
+
+
+
+10
+20
+30
+40
+50
+60
+genes
+
+
+gene_a
+gene_b
+points
+overlays
diff --git a/tests/testthat/test-plotArray.R b/tests/testthat/test-plotArray.R
index f39a5cc..9505f7c 100644
--- a/tests/testthat/test-plotArray.R
+++ b/tests/testthat/test-plotArray.R
@@ -17,7 +17,7 @@ test_that("plotSpatialData()", {
}
test_that(".guess_scale", {
- img <- ImageArray(
+ img <- SpatialDataImage(
lys <- lapply(
dim <- lapply(c(6, 3), \(.) c(3, rep(., 2))), \(.)
array(sample(seq_len(255), prod(.), replace=TRUE), dim=.)))
diff --git a/tests/testthat/test-plotImage.R b/tests/testthat/test-plotImage.R
index 60fdbaa..a642488 100644
--- a/tests/testthat/test-plotImage.R
+++ b/tests/testthat/test-plotImage.R
@@ -14,7 +14,7 @@ test_that(".is_rgb()", {
expect_false(.is_rgb(c("r", "g", "g")))
expect_true(.is_rgb(. <- c("r", "g", "b")))
expect_true(.is_rgb(rev(.)))
- # only works for 'ImageArray'
+ # only works for 'SpatialDataImage'
expect_true(.is_rgb(image(x, 1)))
expect_error(.is_rgb(label(x, 1)))
})
diff --git a/tests/testthat/test-plotShape.R b/tests/testthat/test-plotShape.R
index d392227..bcc76f8 100644
--- a/tests/testthat/test-plotShape.R
+++ b/tests/testthat/test-plotShape.R
@@ -1,5 +1,7 @@
+require(sf, quietly=TRUE)
require(ggplot2, quietly=TRUE)
require(SpatialData, quietly=TRUE)
+
x <- file.path("extdata", "blobs.zarr")
x <- system.file(x, package="SpatialData")
x <- readSpatialData(x, tables=FALSE)
@@ -40,7 +42,7 @@ test_that("plotShape(),polygons", {
geom <- layer_data(q)$geometry
expect_s3_class(q, "ggplot")
df <- centroids(y)
- fd <- st_coordinates(geom)
+ fd <- st_coordinates(st_centroid(geom))
.f <- \(.) as.matrix(.[,c(1,2)])
expect_equivalent(.f(df), .f(fd))
expect_s3_class(geom, "sfc_POLYGON")
diff --git a/tests/testthat/test-plotSpatialData.R b/tests/testthat/test-plotSpatialData.R
index f38a308..59f5977 100644
--- a/tests/testthat/test-plotSpatialData.R
+++ b/tests/testthat/test-plotSpatialData.R
@@ -1,24 +1,24 @@
test_that("regression test of overlays", {
- x <- system.file("extdata", "blobs.zarr", package="SpatialData") |>
- readSpatialData()
-
- p <- plotSpatialData()
- # joint
- all <- p +
- plotImage(x) +
- plotLabel(x, a=1/3) +
- plotShape(x, 1) +
- plotShape(x, 3) +
- plotPoint(x, c="genes") +
- ggplot2::ggtitle("layered")
- # split
- one <- list(
- p + plotImage(x) + ggplot2::ggtitle("image"),
- p + plotLabel(x) + ggplot2::ggtitle("labels"),
- p + plotShape(x, 1) + ggplot2::ggtitle("circles"),
- p + plotShape(x, 3) + ggplot2::ggtitle("polygons"),
- p + plotPoint(x, c="genes") + ggplot2::ggtitle("points"))
- fig <- patchwork::wrap_plots(c(list(all), one), nrow=2)
-
- vdiffr::expect_doppelganger("overlays", fig)
+ zs <- system.file("extdata", "blobs.zarr", package="SpatialData")
+ x <- readSpatialData(zs)
+
+ p <- plotSpatialData()
+ # joint
+ all <- p +
+ plotImage(x) +
+ plotLabel(x, a=1/3) +
+ plotShape(x, 1) +
+ plotShape(x, 3) +
+ plotPoint(x, col="genes") +
+ ggplot2::ggtitle("layered")
+ # split
+ one <- list(
+ p + plotImage(x) + ggplot2::ggtitle("image"),
+ p + plotLabel(x) + ggplot2::ggtitle("labels"),
+ p + plotShape(x, 1) + ggplot2::ggtitle("circles"),
+ p + plotShape(x, 3) + ggplot2::ggtitle("polygons"),
+ p + plotPoint(x, col="genes") + ggplot2::ggtitle("points"))
+ fig <- patchwork::wrap_plots(c(list(all), one), nrow=2)
+
+ vdiffr::expect_doppelganger("overlays", fig)
})