Skip to content
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check-bioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ jobs:
install.packages(c("BiocManager", "remotes"), quiet = TRUE)
## update=FALSE avoids calling old.packages(type="both") which
## triggers the R-devel bug in .available.both() (commit dd03406)
BiocManager::install(version = "3.23", ask = FALSE, update = FALSE)
cat("R_BIOC_VERSION=3.23\n", file = Sys.getenv("GITHUB_ENV"), append = TRUE)
BiocManager::install(version = "devel", ask = FALSE, update = FALSE)
cat("R_BIOC_VERSION=3.24\n", file = Sys.getenv("GITHUB_ENV"), append = TRUE)

- name: Install pandoc
uses: r-lib/actions/setup-pandoc@v2
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Suggests:
knitr,
processx,
rhdf5 (>= 2.52.1),
Rarr (>= 1.11.12),
Rarr,
rmarkdown,
S4Vectors,
Seurat,
Expand All @@ -72,5 +72,5 @@ Config/Needs/website: pkgdown, tibble, knitr, rprojroot, stringr, readr, purrr,
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE, r6 = TRUE)
RoxygenNote: 7.3.3
Language: en-GB
Config/roxygen2/version: 8.0.0
17 changes: 13 additions & 4 deletions R/Rarr_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ZARR_METADATA_FILES <- c(".zarray", ".zattrs", ".zgroup", "zarr.json")
#' @return `NULL`
#'
#' @noRd
create_zarr_group <- function(store, name, version = "v2") {
create_zarr_group <- function(store, name, version = .get_zarr_version()) {
# Split "a/b/c" into c("a", "b", "c")
split_name <- strsplit(name, split = "/", fixed = TRUE)[[1]]
if (length(split_name) > 1) {
Expand All @@ -31,6 +31,7 @@ create_zarr_group <- function(store, name, version = "v2") {
}
}
dir.create(file.path(store, split_name[1]), showWarnings = FALSE)
version <- paste0("v", version)
switch(
version,
v2 = {
Expand All @@ -40,9 +41,12 @@ create_zarr_group <- function(store, name, version = "v2") {
)
},
v3 = {
cli_abort("Currently only zarr v2 is supported!")
write(
"{\"zarr_format\": 3,\n\"node_type\": \"group\"}",
file = file.path(store, split_name[1], "zarr.json")
)
},
cli_abort("Only zarr v2 is supported. Use version = 'v2'")
cli_abort("Incorrect Zarr version specified. Must be '2' or '3'.")
)
}

Expand All @@ -56,7 +60,7 @@ create_zarr_group <- function(store, name, version = "v2") {
#' @return `NULL`
#'
#' @noRd
create_zarr <- function(store, version = "v2") {
create_zarr <- function(store, version = .get_zarr_version()) {
prefix <- basename(store)
dir <- gsub(paste0(prefix, "$"), "", store)
create_zarr_group(store = dir, name = prefix, version = version)
Expand Down Expand Up @@ -103,3 +107,8 @@ zarr_path_exists <- function(store, target_path) {
}
}
}

.get_zarr_version <- function() {
vr <- getOption("anndataR.zarr_version")
if (is.null(vr)) 2 else vr
}
79 changes: 46 additions & 33 deletions R/ZarrAnnData.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
cloneable = FALSE,
private = list(
.zarrobj = NULL,
.zarrversion = NULL,
.compression = NULL,
.readonly = NULL,

Expand Down Expand Up @@ -62,7 +63,8 @@
write_zarr_element(
private$.zarrobj,
"X",
private$.compression
private$.compression,
private$.zarrversion
)
}
},
Expand All @@ -87,7 +89,8 @@
write_zarr_element(
private$.zarrobj,
"layers",
private$.compression
private$.compression,
private$.zarrversion
)
}
},
Expand All @@ -114,7 +117,8 @@
write_zarr_element(
private$.zarrobj,
"obsm",
private$.compression
private$.compression,
private$.zarrversion
)
}
},
Expand All @@ -141,7 +145,8 @@
write_zarr_element(
private$.zarrobj,
"varm",
private$.compression
private$.compression,
private$.zarrversion
)
}
},
Expand All @@ -166,7 +171,8 @@
write_zarr_element(
private$.zarrobj,
"obsp",
private$.compression
private$.compression,
private$.zarrversion
)
}
},
Expand All @@ -191,7 +197,8 @@
write_zarr_element(
private$.zarrobj,
"varp",
private$.compression
private$.compression,
private$.zarrversion
)
}
},
Expand All @@ -209,7 +216,8 @@
write_zarr_element(
private$.zarrobj,
"obs",
private$.compression
private$.compression,
private$.zarrversion
)
}
},
Expand All @@ -227,7 +235,8 @@
write_zarr_element(
private$.zarrobj,
"var",
private$.compression
private$.compression,
private$.zarrversion
)
}
},
Expand Down Expand Up @@ -275,7 +284,8 @@
write_zarr_element(
private$.zarrobj,
"uns",
private$.compression
private$.compression,
private$.zarrversion
)
}
}
Expand Down Expand Up @@ -308,28 +318,29 @@
#' create a new one. If any additional slot arguments are set an existing
#' file will be overwritten.
initialize = function(
file,
X = NULL,
obs = NULL,
var = NULL,
layers = NULL,
obsm = NULL,
varm = NULL,
obsp = NULL,
varp = NULL,
uns = NULL,
shape = NULL,
mode = c("a", "r", "r+", "w", "w-", "x"),
compression = c(
"none",
"gzip",
"blosc",
"zstd",
"lzma",
"bz2",
"zlib",
"lz4"
)
file,

Check warning on line 321 in R/ZarrAnnData.R

View workflow job for this annotation

GitHub Actions / lint

file=R/ZarrAnnData.R,line=321,col=4,[indentation_linter] Indentation should be 6 spaces but is 4 spaces.
X = NULL,
obs = NULL,
var = NULL,
layers = NULL,
obsm = NULL,
varm = NULL,
obsp = NULL,
varp = NULL,
uns = NULL,
shape = NULL,
mode = c("a", "r", "r+", "w", "w-", "x"),
compression = c(
"none",
"gzip",
"blosc",
"zstd",
"lzma",
"bz2",
"zlib",
"lz4"
),
zarr_version = .get_zarr_version()
) {
check_requires("ZarrAnnData", "Rarr", where = "Bioc")

Expand All @@ -338,6 +349,7 @@

private$.compression <- compression

private$.zarrversion <- zarr_version
is_readonly <- FALSE

if (is.character(file)) {
Expand Down Expand Up @@ -520,7 +532,7 @@
#'
# nolint start: object_name_linter
as_ZarrAnnData <- function(
# nolint end: object_name_linter
# nolint end: object_name_linter
adata,
file,
compression = c(
Expand Down Expand Up @@ -555,6 +567,7 @@
uns = adata$uns,
shape = adata$shape(),
mode = mode,
compression = compression
compression = compression,
zarr_version = .get_zarr_version()
)
}
Loading
Loading