Skip to content

Commit 20b28ed

Browse files
authored
Replace pizzarr support with Rarr for importing tables (anndataR) (#139)
2 parents b7a6daa + f49d150 commit 20b28ed

6 files changed

Lines changed: 36 additions & 30 deletions

File tree

DESCRIPTION

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ Imports:
4646
ZarrArray,
4747
RBGL,
4848
reticulate,
49+
anndataR,
4950
sf,
5051
S4Arrays,
5152
S4Vectors,
5253
SingleCellExperiment,
53-
SummarizedExperiment,
54-
zellkonverter
54+
SummarizedExperiment
5555
Suggests:
5656
BiocStyle,
5757
ggnewscale,
@@ -63,11 +63,7 @@ Suggests:
6363
SpatialData.plot,
6464
testthat,
6565
DT
66-
Enhances:
67-
anndataR,
68-
pizzarr
6966
Remotes:
70-
keller-mark/pizzarr,
7167
keller-mark/anndataR@spatialdata,
7268
HelenaLC/SpatialData.data,
7369
HelenaLC/SpatialData.plot,

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ exportMethods(tableNames)
8080
exportMethods(tables)
8181
exportMethods(translation)
8282
exportMethods(valTable)
83+
import(anndataR)
8384
import(geoarrow)
8485
importClassesFrom(S4Arrays,Array)
8586
importClassesFrom(S4Vectors,DFrame)
@@ -149,4 +150,3 @@ importFrom(sf,st_sfc)
149150
importFrom(utils,.DollarNames)
150151
importFrom(utils,head)
151152
importFrom(utils,tail)
152-
importFrom(zellkonverter,AnnData2SCE)

R/read.R

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
# "zarr==2.18.4", "zict==3.0.0")
2828
allp = c("zarr==3.1.5", "spatialdata==0.7.0", "spatialdata_io==0.6.0",
2929
"spatialdata_plot==0.2.14", "setuptools==75.8.0")
30-
# notes from VJC -- readSpatialData was modified below so
31-
# that if anndataR = FALSE, spatialdata.read_zarr is used
30+
# notes from VJC/AM -- readSpatialData was modified below so
31+
# that if anndataR = FALSE, anndata.read_zarr is used
3232
# to get the whole zarr store, and then the tables are
33-
# transformed via zellkonverter. this gives a 10x speedup
33+
# transformed via anndataR. This gives a 10x speedup
3434
# for ingesting the visium_hd_3.0.0 example but fails on
3535
# the blobs dataset in example("table-utils") because
3636
# of matters related to metadata/hasTable behavior
@@ -51,9 +51,9 @@ allp = c("zarr==3.1.5", "spatialdata==0.7.0", "spatialdata_io==0.6.0",
5151
#' The default, NULL, reads all elements; alternatively, may be FALSE
5252
#' to skip a layer, or a integer vector specifying which elements to read.
5353
#' @param anndataR logical specifying whether
54-
#' to use \code{anndataR} to read tables; defaults to FALSE in `readSpatialData`,
55-
#' and `readTable`,
56-
#' so that pythonic \code{spatialdata} and \code{zellkonverter} are used.
54+
#' to use \code{anndataR} to read tables;
55+
#' defaults to FALSE in `readSpatialData`, and `readTable`,
56+
#' so that pythonic \code{anndata} are used.
5757
#' @param ... option arguments passed to and from other methods.
5858
#'
5959
#' @return
@@ -67,6 +67,9 @@ allp = c("zarr==3.1.5", "spatialdata==0.7.0", "spatialdata_io==0.6.0",
6767
#' dir.create(tf <- tempfile())
6868
#' base <- SpatialData.data:::.unzip_merfish_demo(tf)
6969
#' (x <- readSpatialData(base))
70+
#'
71+
#' # import tables using anndataR
72+
#' (x <- readSpatialData(base, anndataR=TRUE))
7073
NULL
7174

7275
#' @importFrom ZarrArray ZarrArray
@@ -123,9 +126,9 @@ readShape <- function(x, ...) {
123126
packages=c( "python==3.13.0"),
124127
pip=allp)
125128

129+
#' @import anndataR
126130
#' @importFrom reticulate import
127131
#' @importFrom S4Vectors metadata
128-
#' @importFrom zellkonverter AnnData2SCE
129132
#' @importFrom SingleCellExperiment int_metadata
130133
#' @importFrom basilisk basiliskStart basiliskStop basiliskRun
131134
.readTables_basilisk <- function(x) {
@@ -141,7 +144,7 @@ readShape <- function(x, ...) {
141144
full.names = FALSE)
142145
lapply(ts, \(z) {
143146
zs <- sd$read_zarr(file.path(x, "tables", z))
144-
se <- AnnData2SCE(zs)
147+
se <- zs$as_SingleCellExperiment()
145148
nm <- "spatialdata_attrs"
146149
md <- metadata(se)[[nm]]
147150
int_metadata(se)[[nm]] <- md
@@ -152,16 +155,12 @@ readShape <- function(x, ...) {
152155
}
153156
.readTable_anndataR <- function(x) {
154157
if (!requireNamespace('anndataR', quietly=TRUE)) {
155-
stop("To use this function, install the 'anndataR' package via\n",
156-
"`BiocManager::install(\"keller-mark/anndataR\", ref=\"spatialdata\")`")
157-
}
158-
if (!requireNamespace('pizzarr', quietly=TRUE)) {
159-
stop("To use this function, install the 'pizzarr' package via\n",
160-
"`BiocManager::install(\"keller-mark/pizzarr\")`")
158+
message("To make sure 'anndataR' package works as intended, ",
159+
"install the development version via\n",
160+
"`BiocManager::install(\"keller-mark/anndataR\", ref=\"spatialdata\")`")
161161
}
162162
suppressWarnings({ # suppress warnings related to hidden files
163-
adata <- anndataR::read_zarr(x)
164-
anndataR::to_SingleCellExperiment(adata)
163+
anndataR::read_zarr(x, as="SingleCellExperiment")
165164
})
166165
}
167166

inst/NEWS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
changes in version 0.99.24
2+
3+
- ZarrArray imported by Bioconductor/ZarrArray
4+
- Rarr replaces pizzarr for importing tables via anndataR
5+
- anndataR replaces zellkonverter
6+
- update basilisk env to spatialdata==0.7.0
7+
- replace spatialdata.read with anndata.read_zarr to read tables
8+
19
changes in version 0.99.22
210

311
- split off 'SpatialData.data'

man/SpatialData.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/readSpatialData.Rd

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)