Skip to content

Commit

Permalink
check, test and run examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur-man committed Nov 25, 2024
1 parent a07f88c commit 3638fb8
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Imports:
rlang,
sf,
S4Vectors,
SingleCellExperiment
SingleCellExperiment,
Rarr
Suggests:
BiocStyle,
ggnewscale,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ exportMethods(scale)
exportMethods(translation)
import(SpatialData)
importFrom(DelayedArray,realize)
importFrom(Rarr,zarr_overview)
importFrom(S4Vectors,metadata)
importFrom(SingleCellExperiment,int_colData)
importFrom(SingleCellExperiment,int_metadata)
Expand Down
5 changes: 2 additions & 3 deletions R/plotImage.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ plotSpatialData <- \() ggplot() + scale_y_reverse() + .theme
stop("You can only choose at most seven default colors!")
if(!is.null(c) || (is.null(c) && length(ch) > 1)) {
if(is.null(c))
c <- default_colors[1:length(ch)]
c <- .DEFAULT_COLORS[1:length(ch)]
c <- col2rgb(c)/255
a_new <- array(0, dim = c(3,dim(a)[-1]))
for(i in 1:dim(a)[1]){
Expand All @@ -58,6 +58,7 @@ plotSpatialData <- \() ggplot() + scale_y_reverse() + .theme

# check if an image is rgb or not
#' @importFrom SpatialData getZarrArrayPath
#' @importFrom Rarr zarr_overview
#' @noRd
.get_image_dtype <- \(a){
zarray_spec <- Rarr::zarr_overview(getZarrArrayPath(a),
Expand Down Expand Up @@ -91,8 +92,6 @@ plotSpatialData <- \() ggplot() + scale_y_reverse() + .theme
return(FALSE)
}

#' get channel names
#' @export
channelNames <- function(x){
if(!is.null(md <- attr(x, "meta")))
return(md[[2]]$channels$label)
Expand Down
Binary file added tests/testthat/Rplots.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions vignettes/SpatialData.plot.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ pa <- unzip_spd_demo(
Getting channel names for the image

```{r mcmicro-channels}
channelNames(image(x,1))
# TODO: add this to SpatialData as an ImageArray method
# channelNames(image(x,1))
```

Plotting with multiple image channels.
Expand All @@ -278,7 +279,6 @@ Plotting with multiple image channels.

```{r steinbock-plot}
plotSpatialData() + plotImage(x, 1, ch = c(0,1,2), c = c("blue", "cyan", "yellow"))
# plotSpatialData() + plotImage(x, 1, ch = c(0,1,2), c = c("blue", "cyan", "yellow"))
```

# Masking
Expand Down

0 comments on commit 3638fb8

Please sign in to comment.