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
8 changes: 2 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ Imports:
ZarrArray,
RBGL,
reticulate,
anndataR,
sf,
S4Arrays,
S4Vectors,
SingleCellExperiment,
SummarizedExperiment,
zellkonverter
SummarizedExperiment
Suggests:
BiocStyle,
ggnewscale,
Expand All @@ -63,11 +63,7 @@ Suggests:
SpatialData.plot,
testthat,
DT
Enhances:
anndataR,
pizzarr
Remotes:
keller-mark/pizzarr,
keller-mark/anndataR@spatialdata,
HelenaLC/SpatialData.data,
HelenaLC/SpatialData.plot,
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ exportMethods(tableNames)
exportMethods(tables)
exportMethods(translation)
exportMethods(valTable)
import(anndataR)
import(geoarrow)
importClassesFrom(S4Arrays,Array)
importClassesFrom(S4Vectors,DFrame)
Expand Down Expand Up @@ -149,4 +150,3 @@ importFrom(sf,st_sfc)
importFrom(utils,.DollarNames)
importFrom(utils,head)
importFrom(utils,tail)
importFrom(zellkonverter,AnnData2SCE)
31 changes: 15 additions & 16 deletions R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
# "zarr==2.18.4", "zict==3.0.0")
allp = c("zarr==3.1.5", "spatialdata==0.7.0", "spatialdata_io==0.6.0",
"spatialdata_plot==0.2.14", "setuptools==75.8.0")
# notes from VJC -- readSpatialData was modified below so
# that if anndataR = FALSE, spatialdata.read_zarr is used
# notes from VJC/AM -- readSpatialData was modified below so
# that if anndataR = FALSE, anndata.read_zarr is used
# to get the whole zarr store, and then the tables are
# transformed via zellkonverter. this gives a 10x speedup
# transformed via anndataR. This gives a 10x speedup
# for ingesting the visium_hd_3.0.0 example but fails on
# the blobs dataset in example("table-utils") because
# of matters related to metadata/hasTable behavior
Expand All @@ -51,9 +51,9 @@ allp = c("zarr==3.1.5", "spatialdata==0.7.0", "spatialdata_io==0.6.0",
#' The default, NULL, reads all elements; alternatively, may be FALSE
#' to skip a layer, or a integer vector specifying which elements to read.
#' @param anndataR logical specifying whether
#' to use \code{anndataR} to read tables; defaults to FALSE in `readSpatialData`,
#' and `readTable`,
#' so that pythonic \code{spatialdata} and \code{zellkonverter} are used.
#' to use \code{anndataR} to read tables;
#' defaults to FALSE in `readSpatialData`, and `readTable`,
#' so that pythonic \code{anndata} are used.
#' @param ... option arguments passed to and from other methods.
#'
#' @return
Expand All @@ -67,6 +67,9 @@ allp = c("zarr==3.1.5", "spatialdata==0.7.0", "spatialdata_io==0.6.0",
#' dir.create(tf <- tempfile())
#' base <- SpatialData.data:::.unzip_merfish_demo(tf)
#' (x <- readSpatialData(base))
#'
#' # import tables using anndataR
#' (x <- readSpatialData(base, anndataR=TRUE))
NULL

#' @importFrom ZarrArray ZarrArray
Expand Down Expand Up @@ -123,9 +126,9 @@ readShape <- function(x, ...) {
packages=c( "python==3.13.0"),
pip=allp)

#' @import anndataR
#' @importFrom reticulate import
#' @importFrom S4Vectors metadata
#' @importFrom zellkonverter AnnData2SCE
#' @importFrom SingleCellExperiment int_metadata
#' @importFrom basilisk basiliskStart basiliskStop basiliskRun
.readTables_basilisk <- function(x) {
Expand All @@ -141,7 +144,7 @@ readShape <- function(x, ...) {
full.names = FALSE)
lapply(ts, \(z) {
zs <- sd$read_zarr(file.path(x, "tables", z))
se <- AnnData2SCE(zs)
se <- zs$as_SingleCellExperiment()
nm <- "spatialdata_attrs"
md <- metadata(se)[[nm]]
int_metadata(se)[[nm]] <- md
Expand All @@ -152,16 +155,12 @@ readShape <- function(x, ...) {
}
.readTable_anndataR <- function(x) {
if (!requireNamespace('anndataR', quietly=TRUE)) {
stop("To use this function, install the 'anndataR' package via\n",
"`BiocManager::install(\"keller-mark/anndataR\", ref=\"spatialdata\")`")
}
if (!requireNamespace('pizzarr', quietly=TRUE)) {
stop("To use this function, install the 'pizzarr' package via\n",
"`BiocManager::install(\"keller-mark/pizzarr\")`")
message("To make sure 'anndataR' package works as intended, ",
"install the development version via\n",
"`BiocManager::install(\"keller-mark/anndataR\", ref=\"spatialdata\")`")
}
suppressWarnings({ # suppress warnings related to hidden files
adata <- anndataR::read_zarr(x)
anndataR::to_SingleCellExperiment(adata)
anndataR::read_zarr(x, as="SingleCellExperiment")
})
}

Expand Down
8 changes: 8 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
changes in version 0.99.24

- ZarrArray imported by Bioconductor/ZarrArray
- Rarr replaces pizzarr for importing tables via anndataR
- anndataR replaces zellkonverter
- update basilisk env to spatialdata==0.7.0
- replace spatialdata.read with anndata.read_zarr to read tables

changes in version 0.99.22

- split off 'SpatialData.data'
Expand Down
8 changes: 4 additions & 4 deletions man/SpatialData.Rd

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

9 changes: 6 additions & 3 deletions man/readSpatialData.Rd

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

Loading