Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit e8cf7b8

Browse files
committed
Use duckdb instead of sqlite
1 parent f110413 commit e8cf7b8

File tree

4 files changed

+23
-30
lines changed

4 files changed

+23
-30
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Imports:
4040
S4Vectors,
4141
tibble,
4242
utils,
43-
dbplyr (>= 2.3.0)
43+
dbplyr (>= 2.3.0),
44+
duckdb
4445
Suggests:
4546
here,
4647
stringr,

NAMESPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import(Seurat)
88
import(dbplyr)
99
importFrom(BiocGenerics,cbind)
1010
importFrom(DBI,dbConnect)
11+
importFrom(DBI,dbDisconnect)
1112
importFrom(HDF5Array,HDF5RealizationSink)
1213
importFrom(HDF5Array,loadHDF5SummarizedExperiment)
13-
importFrom(RSQLite,SQLITE_RO)
14-
importFrom(RSQLite,SQLite)
1514
importFrom(S4Vectors,DataFrame)
1615
importFrom(SeuratObject,as.Seurat)
1716
importFrom(SeuratObject,as.sparse)
@@ -35,6 +34,7 @@ importFrom(dplyr,pull)
3534
importFrom(dplyr,tbl)
3635
importFrom(dplyr,tibble)
3736
importFrom(dplyr,transmute)
37+
importFrom(duckdb,duckdb)
3838
importFrom(glue,glue)
3939
importFrom(httr,GET)
4040
importFrom(httr,modify_url)

R/query.R

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,16 @@ get_seurat <- function(...) {
342342
get_SingleCellExperiment(...) |> as.Seurat(data = NULL)
343343
}
344344

345-
#' Downloads an SQLite database of the Human Cell Atlas metadata to a local
345+
#' Downloads a parquet database of the Human Cell Atlas metadata to a local
346346
#' cache, and then opens it as a data frame. It can then be filtered and
347347
#' passed into [get_SingleCellExperiment()]
348348
#' to obtain a [`SingleCellExperiment`](SingleCellExperiment::SingleCellExperiment-class)
349349
#'
350350
#' @param remote_url Optional character vector of length 1. An HTTP URL pointing
351-
#' to the location of the sqlite database.
351+
#' to the location of the parquet database.
352352
#' @param cache_directory Optional character vector of length 1. A file path on
353353
#' your local system to a directory (not a file) that will be used to store
354-
#' metadata.sqlite
354+
#' metadata.parquet
355355
#' @return A lazy data.frame subclass containing the metadata. You can interact
356356
#' with this object using most standard dplyr functions. For string matching,
357357
#' it is recommended that you use `stringr::str_like` to filter character
@@ -368,30 +368,22 @@ get_seurat <- function(...) {
368368
#' )
369369
#'
370370
#' @importFrom DBI dbConnect
371-
#' @importFrom RSQLite SQLite SQLITE_RO
371+
#' @importFrom duckdb duckdb
372372
#' @importFrom dplyr tbl
373373
#' @importFrom httr progress
374374
#' @importFrom cli cli_alert_info
375375
#' @importFrom utils untar
376376
get_metadata <- function(
377-
remote_url = "https://object-store.rc.nectar.org.au/v1/AUTH_06d6e008e3e642da99d806ba3ea629c5/metadata-sqlite/metadata.tar.xz",
377+
remote_url = "https://object-store.rc.nectar.org.au/v1/AUTH_06d6e008e3e642da99d806ba3ea629c5/metadata-sqlite/metadata.parquet",
378378
cache_directory = get_default_cache_dir()
379379
) {
380-
tar_path <- file.path(cache_directory, "metadata.tar.xz")
381-
sqlite_path <- file.path(cache_directory, "metadata.sqlite")
382-
if (!file.exists(sqlite_path)){
383-
tar_dir <- tempdir()
384-
tar_file <- file.path(tar_dir, "metadata.tar.xz")
385-
cli_alert_info("Downloading tar archive. The following procedure is performed once and will take approximately 3 minutes.")
386-
sync_remote_file(
387-
remote_url,
388-
tar_file,
389-
progress(type = "down", con = stderr())
390-
)
391-
cli_alert_info("Decompressing tar archive")
392-
untar(tar_file, exdir = cache_directory)
393-
}
394-
SQLite() |>
395-
dbConnect(drv = _, dbname = sqlite_path, flags = SQLITE_RO) |>
396-
tbl("metadata")
380+
db_path <- file.path(cache_directory, "metadata.parquet")
381+
sync_remote_file(
382+
remote_url,
383+
db_path,
384+
progress(type = "down", con = stderr())
385+
)
386+
table <- duckdb() |>
387+
dbConnect(drv = _, read_only = TRUE) |>
388+
tbl(db_path)
397389
}

man/get_metadata.Rd

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

0 commit comments

Comments
 (0)