Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6ab4bed
+combine
HelenaLC Apr 14, 2026
3c13329
added set nms methods
HelenaLC Apr 15, 2026
fae6e13
fix ctgraph when elenm == ctnm
HelenaLC Apr 15, 2026
15ec323
devel
HelenaLC Apr 21, 2026
10ae721
Use duckspatial instead of arrow for ShapeFrame and PointFrame
csoneson Apr 21, 2026
59b48b0
Merge pull request #156 from csoneson/shapes
HelenaLC Apr 21, 2026
afa6432
Implement query function for PointFrame
csoneson Apr 21, 2026
39b8df8
Merge pull request #157 from csoneson/shapes
HelenaLC Apr 21, 2026
c4e71e2
Fix warnings (drop geometry, set CRS to NA)
csoneson Apr 22, 2026
d00944e
Suppress warning caused by dropping the geometry column, add all_of
csoneson Apr 22, 2026
428d669
Specify namespace for table()
csoneson Apr 22, 2026
5540b7e
Allow construction of ShapeFrame from in-memory objects
csoneson Apr 22, 2026
4f47839
Define `[[` for ShapeFrame
csoneson Apr 22, 2026
a9a379f
Allow sf objects for queries
csoneson Apr 22, 2026
f51791f
Allow also sfc and sfg objects in query
csoneson Apr 22, 2026
72aabc1
Merge pull request #158 from csoneson/shapes
HelenaLC Apr 23, 2026
6025414
stash
HelenaLC Apr 23, 2026
73f2a1e
merge query
HelenaLC Apr 23, 2026
d756d86
fix unit tests
HelenaLC Apr 24, 2026
0ad831f
track changes
HelenaLC Apr 24, 2026
4a34743
+hugo,charlotte,michael as authors
HelenaLC Apr 24, 2026
ee064f2
valTable -> getTable
HelenaLC Apr 24, 2026
a13efa9
simplify methods dispatch
HelenaLC Apr 24, 2026
3b012db
+Imports: rlang
HelenaLC Apr 24, 2026
54d09ce
+@importFrom rlang git add R/trans.R
HelenaLC Apr 24, 2026
898b167
+samuel
HelenaLC Apr 24, 2026
d93ffcb
add missing imports; fiix examples
HelenaLC Apr 24, 2026
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
33 changes: 25 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: SpatialData
Title: Representation of Python's SpatialData in R
Depends: R (>= 4.6)
Version: 0.99.29
Version: 0.99.30
Description: Interface to Python's 'SpatialData', currently including:
reticulate-based use of 'spatialdata-io' for reading of manufacturer
data and writing to .zarr, on-disk representation of images/labels as
Expand All @@ -12,18 +12,34 @@ Authors@R: c(
role=c("aut", "cre"),
email="helena@crowell.eu",
comment=c(ORCID="0000-0002-4801-1767")),
person("Artür", "Manukyan",
role=c("aut"),
email="artur-man@hotmail.com",
comment=c(ORCID="0000-0002-0441-9517")),
person("Hugo", "Gruson",
role=c("aut"),
email="charlotte.soneson@fmi.ch",
comment=c(ORCID="0000-0002-4094-1476")),
person("Vince", "Carey",
role=c("aut"),
email="stvjc@channing.harvard.edu",
email="hugo.gruson@embl.de",
comment=c(ORCID="0000-0003-4046-0063")),
person("Charlotte", "Soneson",
role=c("aut"),
email="charlotte.soneson@fmi.ch",
comment=c(ORCID="0000-0003-3833-2169")),
person("Michael", "Stadler",
role=c("aut"),
email="michael.stadler@fmi.ch",
comment=c(ORCID="0000-0002-2269-4934")),
person("Samuel", "Gunz",
role=c("aut"),
email="samuel.gunz@uzh.ch",
comment=c(ORCID="0000-0002-8909-0932")),
person("Yixing E.", "Dong",
role=c("aut"),
email="estelladong729@gmail.com",
comment=c(ORCID="0009-0003-5115-5686")),
person("Artür", "Manukyan",
role=c("aut"),
email="artur-man@hotmail.com",
comment=c(ORCID="0000-0002-0441-9517")),
person("Dario", "Righelli",
role=c("aut"),
email="dario.righelli@gmail.com",
Expand All @@ -33,11 +49,12 @@ Authors@R: c(
email="louise.deconinck@gmail.com",
comment=c(ORCID="0000-0001-8100-6823")))
Imports:
arrow,
anndataR,
basilisk,
BiocGenerics,
DelayedArray,
dplyr,
duckspatial,
EBImage,
geoarrow,
graph,
Expand All @@ -47,7 +64,7 @@ Imports:
Rarr,
RBGL,
reticulate,
anndataR,
rlang,
sf,
S4Arrays,
S4Vectors,
Expand Down
32 changes: 26 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ exportMethods("[")
exportMethods("[[")
exportMethods("[[<-")
exportMethods("image<-")
exportMethods("imageNames<-")
exportMethods("images<-")
exportMethods("label<-")
exportMethods("labelNames<-")
exportMethods("labels<-")
exportMethods("point<-")
exportMethods("pointNames<-")
exportMethods("points<-")
exportMethods("shape<-")
exportMethods("shapeNames<-")
exportMethods("shapes<-")
exportMethods("table<-")
exportMethods("tableNames<-")
exportMethods("tables<-")
exportMethods(CTdata)
exportMethods(CTgraph)
Expand All @@ -49,6 +54,7 @@ exportMethods(axes)
exportMethods(centroids)
exportMethods(channels)
exportMethods(colnames)
exportMethods(combine)
exportMethods(data)
exportMethods(data_type)
exportMethods(dim)
Expand All @@ -64,6 +70,7 @@ exportMethods(image)
exportMethods(imageNames)
exportMethods(images)
exportMethods(instance_key)
exportMethods(instances)
exportMethods(label)
exportMethods(labelNames)
exportMethods(labels)
Expand All @@ -83,31 +90,31 @@ exportMethods(rmvCT)
exportMethods(rotate)
exportMethods(rownames)
exportMethods(scale)
exportMethods(sequence)
exportMethods(setTable)
exportMethods(shape)
exportMethods(shapeNames)
exportMethods(shapes)
exportMethods(table)
exportMethods(tableNames)
exportMethods(tables)
exportMethods(transform)
exportMethods(translation)
exportMethods(valTable)
import(anndataR)
import(geoarrow)
importClassesFrom(S4Arrays,Array)
importClassesFrom(S4Vectors,DFrame)
importFrom(BiocGenerics,as.data.frame)
importFrom(BiocGenerics,colnames)
importFrom(BiocGenerics,combine)
importFrom(BiocGenerics,rownames)
importFrom(DelayedArray,DelayedArray)
importFrom(EBImage,resize)
importFrom(EBImage,rotate)
importFrom(EBImage,translate)
importFrom(Matrix,rowSums)
importFrom(Matrix,sparseMatrix)
importFrom(Matrix,sparseVector)
importFrom(Matrix,summary)
importFrom(Matrix,t)
importFrom(RBGL,sp.between)
importFrom(Rarr,read_zarr_attributes)
importFrom(Rarr,zarr_overview)
Expand All @@ -130,17 +137,26 @@ importFrom(SummarizedExperiment,colData)
importFrom(ZarrArray,ZarrArray)
importFrom(ZarrArray,path)
importFrom(ZarrArray,type)
importFrom(arrow,open_dataset)
importFrom(basilisk,BasiliskEnvironment)
importFrom(basilisk,basiliskRun)
importFrom(basilisk,basiliskStart)
importFrom(basilisk,basiliskStop)
importFrom(dplyr,all_of)
importFrom(dplyr,collect)
importFrom(dplyr,count)
importFrom(dplyr,filter)
importFrom(dplyr,inner_join)
importFrom(dplyr,join_by)
importFrom(dplyr,mutate)
importFrom(dplyr,pull)
importFrom(dplyr,row_number)
importFrom(dplyr,select)
importFrom(dplyr,slice)
importFrom(dplyr,sql)
importFrom(dplyr,tally)
importFrom(duckspatial,as_duckspatial_df)
importFrom(duckspatial,ddbs_intersects)
importFrom(duckspatial,ddbs_open_dataset)
importFrom(graph,"edgeData<-")
importFrom(graph,"edgeDataDefaults<-")
importFrom(graph,"nodeData<-")
Expand All @@ -160,16 +176,20 @@ importFrom(methods,new)
importFrom(methods,setClassUnion)
importFrom(methods,setReplaceMethod)
importFrom(reticulate,import)
importFrom(rlang,"!!")
importFrom(rlang,":=")
importFrom(rlang,.data)
importFrom(sf,"st_geometry<-")
importFrom(sf,st_as_sf)
importFrom(sf,st_as_sfc)
importFrom(sf,st_bbox)
importFrom(sf,st_coordinates)
importFrom(sf,st_crop)
importFrom(sf,st_distance)
importFrom(sf,st_geometry)
importFrom(sf,st_geometry_type)
importFrom(sf,st_intersects)
importFrom(sf,st_polygon)
importFrom(sf,st_sf)
importFrom(sf,st_sfc)
importFrom(utils,.DollarNames)
importFrom(utils,head)
importFrom(utils,tail)
13 changes: 7 additions & 6 deletions R/AllClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
contains="list")

#' @importFrom methods setClassUnion
#' @importClassesFrom S4Arrays Array
#' @importClassesFrom S4Arrays Array
setClassUnion(
"array_OR_df",
c("Array", "array", "data.frame"))
Expand All @@ -22,15 +22,17 @@ setClassUnion(
# this somehow does the trick...
setClass("FileSystemDataset", "VIRTUAL")
setClass("arrow_dplyr_query", "VIRTUAL")
setClass("tbl_duckdb_connection", "VIRTUAL")
setClass("duckspatial_df", "VIRTUAL")
setClass("Table", "VIRTUAL")

# TODO: this isn't great... arrow::open_dataset gives a FileSystemDataset,
# read_parquet gives a Table, dplyr calls give a query, but also wanna
# read_parquet gives a Table, dplyr calls give a query, but also wanna
# be able to store a normal data.frame, maybe?
#' @importFrom methods setClassUnion
setClassUnion(
"arrow_OR_df",
c("FileSystemDataset", "Table", "arrow_dplyr_query", "data.frame"))
c("tbl_duckdb_connection", "duckspatial_df", "FileSystemDataset", "Table", "arrow_dplyr_query", "data.frame"))

.PointFrame <- setClass(
Class="PointFrame",
Expand All @@ -43,9 +45,8 @@ setClassUnion(
contains=c("Annotated"),
slots=list(data="arrow_OR_df", meta="Zattrs"))

setClassUnion(
"sdArray",
c("ImageArray", "LabelArray"))
setClassUnion("sdArray", c("ImageArray", "LabelArray"))
setClassUnion("sdFrame", c("PointFrame", "ShapeFrame"))

setClassUnion(
"SpatialDataElement",
Expand Down
21 changes: 17 additions & 4 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@ setGeneric("shapeNames", \(x, ...) standardGeneric("shapeNames"))
setGeneric("pointNames", \(x, ...) standardGeneric("pointNames"))
setGeneric("tableNames", \(x, ...) standardGeneric("tableNames"))

# set one -----
# set nms ----

setGeneric("imageNames<-", \(x, ..., value) standardGeneric("imageNames<-"))
setGeneric("labelNames<-", \(x, ..., value) standardGeneric("labelNames<-"))
setGeneric("shapeNames<-", \(x, ..., value) standardGeneric("shapeNames<-"))
setGeneric("pointNames<-", \(x, ..., value) standardGeneric("pointNames<-"))
setGeneric("tableNames<-", \(x, ..., value) standardGeneric("tableNames<-"))

# set one ----

setGeneric("image<-", \(x, i, ..., value) standardGeneric("image<-"))
setGeneric("shape<-", \(x, i, ..., value) standardGeneric("shape<-"))
setGeneric("label<-", \(x, i, ..., value) standardGeneric("label<-"))
setGeneric("point<-", \(x, i, ..., value) standardGeneric("point<-"))
setGeneric("table<-", \(x, i, ..., value) standardGeneric("table<-"))

# set all -----
# set all ----

setGeneric("images<-", \(x, value) standardGeneric("images<-"))
setGeneric("labels<-", \(x, value) standardGeneric("labels<-"))
Expand All @@ -53,7 +61,8 @@ setGeneric("addCT", \(x, ...) standardGeneric("addCT"))

setGeneric("scale", \(x, t, ...) standardGeneric("scale"))
setGeneric("rotate", \(x, t, ...) standardGeneric("rotate"))
setGeneric("transform", \(x, ...) standardGeneric("transform"))
setGeneric("sequence", \(x, t, ...) standardGeneric("sequence"))
setGeneric("transform", \(x, i, ...) standardGeneric("transform"))
setGeneric("translation", \(x, t, ...) standardGeneric("translation"))

setGeneric("flip", \(x, ...) standardGeneric("flip"))
Expand All @@ -63,6 +72,11 @@ setGeneric("mirror", \(x, ...) standardGeneric("mirror"))
# sda ----

setGeneric("region", \(x, ...) standardGeneric("region"))
setGeneric("region<-", \(x, ..., value) standardGeneric("region<-"))

setGeneric("regions", \(x, ...) standardGeneric("regions"))
setGeneric("instances", \(x, ...) standardGeneric("instances"))

setGeneric("region_key", \(x, ...) standardGeneric("region_key"))
setGeneric("feature_key", \(x, ...) standardGeneric("feature_key"))
setGeneric("instance_key", \(x, ...) standardGeneric("instance_key"))
Expand Down Expand Up @@ -91,4 +105,3 @@ setGeneric("multiscales", \(x, ...) standardGeneric("multiscales"))
setGeneric("hasTable", \(x, i, ...) standardGeneric("hasTable"))
setGeneric("getTable", \(x, i, ...) standardGeneric("getTable"))
setGeneric("setTable", \(x, i, ...) standardGeneric("setTable"))
setGeneric("valTable", \(x, i, ...) standardGeneric("valTable"))
16 changes: 9 additions & 7 deletions R/CTgraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ setMethod("CTgraph", "ANY", \(x) stop("'x' should be a",
g <- .init_g()
for (l in names(md)) for (e in names(md[[l]])) {
.md <- md[[l]][[e]]
ms <- .md$multiscales
ms <- multiscales(.md)
if (!is.null(ms)) .md <- ms[[1]]
.e <- paste0("_", e)
g <- addNode(.e, g)
nodeData(g, .e, "type") <- "element"
ct <- .md$coordinateTransformations
g <- addNode(e, g)
nodeData(g, e, "type") <- "element"
for (i in seq_along(ct)) {
n <- ct[[i]]$output$name
if (!n %in% nodes(g)) {
Expand All @@ -91,7 +92,7 @@ setMethod("CTgraph", "ANY", \(x) stop("'x' should be a",
t <- ct[[i]]$type
if (t == "sequence") {
sq <- ct[[i]]$transformations
. <- e
. <- .e
for (j in seq_along(sq)) {
if (j == length(sq)) {
m <- n
Expand All @@ -108,10 +109,10 @@ setMethod("CTgraph", "ANY", \(x) stop("'x' should be a",
. <- m
}
} else {
g <- addEdge(e, n, g)
g <- addEdge(.e, n, g)
d <- ct[[i]][[ct[[i]]$type]]
edgeData(g, e, n, "type") <- t
edgeData(g, e, n, "data") <- list(d)
edgeData(g, .e, n, "type") <- t
edgeData(g, .e, n, "data") <- list(d)
}
}
}
Expand All @@ -123,6 +124,7 @@ setMethod("CTgraph", "ANY", \(x) stop("'x' should be a",
#' @importFrom graph edgeData
#' @importFrom RBGL sp.between
.path_ij <- \(g, i, j) {
i <- paste0("_", i)
p <- sp.between(g, i, j)
p <- p[[1]]$path_detail
n <- length(p)-1
Expand Down
Loading
Loading