Skip to content

Commit 487743c

Browse files
authored
class renaming per HelenaLC/spatialdataR#178
2 parents 76a9c42 + e38093d commit 487743c

11 files changed

Lines changed: 2257 additions & 2239 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: SpatialData.plot
22
Title: SpatialData visualization
33
Depends: R (>= 4.6), SpatialData
4-
Version: 0.99.5
4+
Version: 0.99.6
55
Description: Visualization suit for 'SpatialData' (R). Current functionality
66
includes handling of multiscale 'images', visualizing 'labels', 'points',
77
and 'shapes'. For the latter, POINT, POLYGON, and MULTIPOLYGON geometries

R/plotFrame.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' @param i character string or index; the label element to plot.
77
#' @param assay character string; in case of \code{c} denoting a row name,
88
#' specifies which \code{assay} data to use (see \code{\link{valTable}}).
9-
#' (ignored when \code{x} is a \code{PointFrame}).
9+
#' (ignored when \code{x} is a \code{SpatialDataPoint}).
1010
#'
1111
#' @examples
1212
#' x <- file.path("extdata", "blobs.zarr")
@@ -38,18 +38,19 @@ NULL
3838
#' @importFrom ggplot2 aes theme scale_type geom_sf coord_sf
3939
#' @importFrom SpatialData transform
4040
#' @importFrom ggforce geom_circle
41+
#' @importFrom methods is
4142
#' @importFrom utils tail
4243
.plot <- \(x, y, key=NULL, n=Inf, assay=1, i=1, ...) {
43-
if (is(y, "PointFrame")) {
44+
if (is(y, "SpatialDataPoint")) {
4445
if (!is.null(key)) {
4546
fk <- feature_key(y)
46-
y@data <- dplyr::filter(data(y), .data[[fk]] %in% key)
47+
y<- dplyr::filter(y, .data[[fk]] %in% key)
4748
}
4849
}
4950
if (is.finite(n)) {
5051
n <- min(length(y), n)
5152
y <- y[sample(length(y), n)]
52-
if (is(y, "ShapeFrame")) {
53+
if (is(y, "SpatialDataShape")) {
5354
shape(x, i) <- y
5455
} else {
5556
point(x, i) <- y
@@ -72,11 +73,14 @@ NULL
7273
if (val %in% names(df)) {
7374
if (scale_type(df[[arg]]) == "discrete")
7475
df[[val]] <- factor(df[[arg]])
75-
aes[[arg]] <- aes(.data[[val]])[[1]]
76+
col <- match(arg, c("col", "color", "colour"))
77+
.arg <- ifelse(!is.na(col), "colour", arg)
78+
aes[[.arg]] <- aes(.data[[val]])[[1]]
7679
dot[[arg]] <- NULL
7780
}
7881
}
7982
}
83+
8084
if ("radius" %in% names(df))
8185
df <- st_buffer(df, df$radius)
8286
list(

R/plotImage.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#' 800 x 800px; use Inf to plot the lowest resolution available.
1313
#' @param ch image channel(s) to be used for plotting (defaults to
1414
#' the first channel(s) available); use \code{channels()} to see
15-
#' which channels are available for a given \code{ImageArray}
15+
#' which channels are available for a given \code{SpatialDataImage}
1616
#' @param c character vector; colors to use for each channel.
1717
#' @param cl list of length-2 numeric vectors (non-negative, increasing);
1818
#' specifies channel-wise contrast limits - defaults to [0, 1] for all
@@ -128,7 +128,7 @@ NULL
128128
#' @importFrom methods is
129129
#' @noRd
130130
.is_rgb <- \(x) {
131-
if (is(x, "ImageArray") &&
131+
if (is(x, "SpatialDataImage") &&
132132
!is.null(md <- meta(x)))
133133
x <- channels(x)
134134
if (!is.vector(x)) stop("invalid 'x'")

inst/NEWS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
changes in version 0.99.6
2+
3+
- renaming of 'SpatialData' classes
4+
- improved visualization of labels
5+
- fixed auto-contrasting for HnE images
6+
- fixed channel-merging for multi-plex images
7+
18
changes in version 0.99.5
29

310
- fix visualization of circles

man/plotFrame.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/plotImage.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/_snaps/plotSpatialData/overlays.svg

Lines changed: 2209 additions & 2204 deletions
Loading

tests/testthat/test-plotArray.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test_that("plotSpatialData()", {
1717
}
1818

1919
test_that(".guess_scale", {
20-
img <- ImageArray(
20+
img <- SpatialDataImage(
2121
lys <- lapply(
2222
dim <- lapply(c(6, 3), \(.) c(3, rep(., 2))), \(.)
2323
array(sample(seq_len(255), prod(.), replace=TRUE), dim=.)))

tests/testthat/test-plotImage.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test_that(".is_rgb()", {
1414
expect_false(.is_rgb(c("r", "g", "g")))
1515
expect_true(.is_rgb(. <- c("r", "g", "b")))
1616
expect_true(.is_rgb(rev(.)))
17-
# only works for 'ImageArray'
17+
# only works for 'SpatialDataImage'
1818
expect_true(.is_rgb(image(x, 1)))
1919
expect_error(.is_rgb(label(x, 1)))
2020
})

tests/testthat/test-plotShape.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
require(sf, quietly=TRUE)
12
require(ggplot2, quietly=TRUE)
23
require(SpatialData, quietly=TRUE)
4+
35
x <- file.path("extdata", "blobs.zarr")
46
x <- system.file(x, package="SpatialData")
57
x <- readSpatialData(x, tables=FALSE)
@@ -40,7 +42,7 @@ test_that("plotShape(),polygons", {
4042
geom <- layer_data(q)$geometry
4143
expect_s3_class(q, "ggplot")
4244
df <- centroids(y)
43-
fd <- st_coordinates(geom)
45+
fd <- st_coordinates(st_centroid(geom))
4446
.f <- \(.) as.matrix(.[,c(1,2)])
4547
expect_equivalent(.f(df), .f(fd))
4648
expect_s3_class(geom, "sfc_POLYGON")

0 commit comments

Comments
 (0)