2727# "zarr==2.18.4", "zict==3.0.0")
2828allp = 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))
7073NULL
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
0 commit comments