Skip to content
Merged
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
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: spatialdataR
Title: Representation of Python's spatialdata in R
Depends: R (>= 4.6)
Version: 0.99.40
Version: 0.99.41
Description: R interface to Python/scverse's 'spatialdata' framework for
unified spatial omics data handling. Adheres to OME-NGFF standards,
providing lazy, on-disk representations for multiscale images and
Expand Down Expand Up @@ -64,6 +64,6 @@ biocViews:
License: Artistic-2.0
Encoding: UTF-8
VignetteBuilder: knitr
URL: https://helenalc.github.io/SpatialData/, https://github.com/HelenaLC/SpatialData
BugReports: https://github.com/HelenaLC/SpatialData/issues
BugReports: https://github.com/HelenaLC/spatialdataR/issues
URL: https://helenalc.github.io/spatialdataR, https://github.com/HelenaLC/spatialdataR
Config/roxygen2/version: 8.0.0
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ importFrom(graph,graph.par)
importFrom(graph,graphAM)
importFrom(graph,nodeData)
importFrom(graph,nodes)
importFrom(methods,"slot<-")
importFrom(methods,as)
importFrom(methods,callNextMethod)
importFrom(methods,is)
Expand All @@ -199,6 +200,7 @@ importFrom(methods,setClassUnion)
importFrom(methods,setMethod)
importFrom(methods,setOldClass)
importFrom(methods,setReplaceMethod)
importFrom(methods,slot)
importFrom(rlang,"!!")
importFrom(rlang,.data)
importFrom(rlang,call2)
Expand Down
2 changes: 2 additions & 0 deletions R/SpatialData.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#' @param x,object \code{SpatialData} object.
#' @param i,j character string, scalar or vector of indices
#' specifying the element to extract from a given layer.
#' @param k scalar index specifying which scale to use;
#' \code{Inf} to use lowest available resolution.
#' @param drop ignored.
#' @param name character string for extraction (see \code{?base::`$`}).
#' @param value (list of) element(s) with layer-compliant object(s),
Expand Down
10 changes: 8 additions & 2 deletions R/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#' @exportMethod $
#' @rdname SpatialData
#' @importFrom methods slot
setMethod("$", "SpatialData", \(x, name) slot(x, name))

#' @exportMethod $<-
Expand All @@ -24,8 +25,9 @@ setMethod("[[", c("SpatialData", "numeric"), \(x, i, ...) {
callNextMethod(x, i)
})

#' @rdname SpatialData
#' @export
#' @rdname SpatialData
#' @importFrom methods slot
setMethod("[[", c("SpatialData", "character"), \(x, i, ...) slot(x, i))

# data/meta ----
Expand Down Expand Up @@ -151,8 +153,9 @@ setMethod("layer", c("SpatialData", "ANY"), \(x, i) stop(.invalid_i))

# element ----

#' @rdname SpatialData
#' @export
#' @rdname SpatialData
#' @importFrom methods slot
setMethod("element", c("SpatialData", "character"),
\(x, i) slot(x, layer(x, i))[[i]])

Expand Down Expand Up @@ -260,6 +263,7 @@ for (e in one) eval(.set(e), parent.env(environment()))
#' @exportMethod images<- labels<- points<- shapes<- tables<-
NULL

#' @importFrom methods slot slot<-
f <- \(l) setReplaceMethod(l,
c("SpatialData", getSlots("SpatialData")[[l]]),
\(x, value) {
Expand Down Expand Up @@ -357,6 +361,7 @@ typ <- c(
shape="SpatialDataShape",
table="SingleCellExperiment")

#' @importFrom methods slot
f <- \(e) setReplaceMethod(e,
c("SpatialData", "character", typ[[e]]),
\(x, i, value) {
Expand Down Expand Up @@ -406,6 +411,7 @@ for (e in one) eval(f(e), parent.env(environment()))
#' @exportMethod image<- label<- point<- shape<- table<-
NULL

#' @importFrom methods slot
f <- \(e) setReplaceMethod(e,
c("SpatialData", "ANY", "NULL"),
\(x, i, ..., value) {
Expand Down
2 changes: 2 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
return(x)
}

#' @importFrom methods slot<-
.sync_tables_sdattrs <- \(x, old, new) {
if (!length(ts <- tables(x))) return(x)
for (i in seq_along(ts)) {
Expand Down Expand Up @@ -73,6 +74,7 @@
return(x)
}

#' @importFrom methods slot<-
.sync_tables_on_drop <- \(x) {
if (!length(ts <- tables(x))) return(x)
all_nms <- unlist(colnames(x)[.ls])
Expand Down
1 change: 0 additions & 1 deletion R/validity.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ setValidity2("SpatialData", .validateSpatialData)
return(msg)
}
.validateAttrsLabel <- \(x) {
x <- label(sd)
msg <- c()
za <- meta(x)
msg <- .validateAttrs_multiscales(za, msg)
Expand Down
10 changes: 9 additions & 1 deletion inst/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
changes in version 0.99.41

- fix vignette to call 'spatialdataR::transform()' explicitly
- address R CMD check warnings re: undocumented arguments, undefined functions

changes in version 0.99.40

- validty & setters now assure that each layer is a completely named list
Expand Down Expand Up @@ -27,9 +32,12 @@ changes in version 0.99.36

changes in version 0.99.35

- class renaming
- bug fix: 'centroids,shape' was previously
returning vertex coordinates for polygons
- class renaming:
sdArray/Frame > SpatialDataArray/Frame,
Image/LabelArray > SpatialDataImage/Label,
Shape/PointFrame > SpatialDataShape/Point

changes in version 0.99.34

Expand Down
3 changes: 3 additions & 0 deletions man/SpatialData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 14 additions & 12 deletions vignettes/SpatialData.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ output:
toc_depth: 2
toc_float: true
vignette: |
%\VignetteIndexEntry{Introduction to spatialdataR}
%\VignetteIndexEntry{spatialdataR}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
bibliography: "refs.bib"
Expand All @@ -28,23 +28,25 @@ knitr::opts_chunk$set(cache=FALSE, message=FALSE, warning=FALSE)

## Introduction

The `r BiocStyle::Biocpkg("spatialdataR")` package provides an R interface to the
[SpatialData](https://spatialdata.scverse.org) framework, a unified ecosystem
for handling spatial omics data. Developed as part of the
[scverse](https://scverse.org) project [@Virshup2023-scverse], `SpatialData` aims to solve the
challenges of integrating diverse spatial datasets—including imaging, spatial
transcriptomics, and proteomics—by employing the
The `r BiocStyle::Biocpkg("spatialdataR")` package provides an R interface to
Python's [spatialdata](https://spatialdata.scverse.org) framework for unified
handling of spatial omics data, including tabular annotations, vector- and
raster-based components. Developed as part of the [scverse](https://scverse.org)
project [@Virshup2023-scverse], `spatialdata` aims to solve the challenges of
integrating diverse spatial datasets -- including -- by employing the
[OME-NGFF (Next Generation File Format)](https://ngff.openmicroscopy.org)
standard [@Marconato2025-SpatialData].

The Python implementation and core specifications can be found at the
[official SpatialData website](https://spatialdata.scverse.org).
The Python implementation and core specifications are found at the
[official `spatialdata` website](https://spatialdata.scverse.org).

## Representation

The core data structure is the `SpatialData` class, which organizes data
into 5 coordinated **layers: images, labels, points, shapes, and tables**.
Each layer is stored as a list of layer-specific objects that carry associated `SpatialDataAttr` (`@meta` slot), which encode `spatialdata`-specific zarr attributes (*.zattr* for Zarr v2, and *zarr.json* for Zarr v3)
Each layer is stored as a list of layer-specific objects that carry associated
`SpatialDataAttr` (`@meta` slot), which encode `spatialdata`-specific
Zarr attributes (*.zattr* for Zarr v2, and *zarr.json* for Zarr v3).
Together, these layers provide a unified representation of spatial omics data,
combining raster, vector, and tabular data within a single coherent framework.

Expand Down Expand Up @@ -240,7 +242,7 @@ in the correct order (e.g., `scale()` then `translation()`).
a <- label(sd)

# project into 'global'
b <- transform(a, "scale")
b <- spatialdataR::transform(a, "scale")

# compare XY extents
do.call(rbind, c(a=extent(a), b=extent(b)))
Expand Down Expand Up @@ -338,7 +340,7 @@ across objects via `make.names()`, appending a suffix to the element names of
subsequent objects. Alternatively, names could be customize before combining.

```{r combine}
sp <- combine(sd, sd)
sp <- combine(list(foo=sd, bar=sd))
cbind(
original=lengths(colnames(sd)),
combined=lengths(colnames(sp)))
Expand Down
Loading