Skip to contents

htan_con() opens an in-memory DuckDB connection over a versioned parquet snapshot of the ISB-CGC HTAN release tables. It reads the release's manifest.json, fetches each parquet file, checks its sha256 against the manifest, caches it in a BiocFileCache (for http(s):// snapshots), and creates one SQL VIEW per table. All other functions in the package take this connection, so changing where the snapshot lives never changes the API.

Usage

htan_con(
  release = "r7",
  base_url = getOption("HTAN.base_url", .default_base_url),
  cache = getOption("HTAN.cache", tools::R_user_dir("HTAN", "cache")),
  refresh = FALSE
)

Arguments

release

character(1). The HTAN release, e.g. "r7". Always explicit, so results are reproducible.

base_url

character(1). Where the snapshot lives: an https:// or http:// URL, a local directory, or a file:// URL. If it contains {release}, that is replaced by release (the Hugging Face layout, where the release is a tag); otherwise the release is a subdirectory, <base_url>/<release>/manifest.json (the layout just snapshot writes). Defaults to getOption("HTAN.base_url"), then the Hugging Face dataset.

cache

character(1). BiocFileCache directory for downloaded parquet files. Defaults to getOption("HTAN.cache"), then tools::R_user_dir("HTAN", "cache").

refresh

logical(1). Open a new connection even if one is cached.

Value

A duckdb_connection (a DBI connection).

Details

By default the snapshot comes from the public Hugging Face dataset https://huggingface.co/datasets/seandavis/htan, one git tag per release (r7). Set options(HTAN.base_url = ...) to use a mirror or a local build.

The connection is cached for the session: calling htan_con() again with the same arguments returns the same connection.

Examples

fixture <- system.file("extdata", "snapshot", package = "HTAN")
con <- htan_con("r7", base_url = fixture)
htan_tables(con)
#> # A tibble: 78 × 5
#>    name                                     category  rows source source_version
#>    <chr>                                    <chr>    <dbl> <chr>  <chr>         
#>  1 10xvisium_spatialtranscriptomics_auxili… metadata     7 isb-c… r7            
#>  2 10xvisium_spatialtranscriptomics_scRNAs… metadata    14 isb-c… r7            
#>  3 10xvisium_spatialtranscriptomics_scRNAs… metadata     7 isb-c… r7            
#>  4 10xvisium_spatialtranscriptomics_scRNAs… metadata    42 isb-c… r7            
#>  5 10xvisium_spatialtranscriptomics_scRNAs… metadata     7 isb-c… r7            
#>  6 10xxenium_spatialtranscriptomics_experi… metadata     0 isb-c… r7            
#>  7 ScDNAseq_level1_metadata                 metadata     0 isb-c… r7            
#>  8 ScDNAseq_level2_metadata                 metadata     0 isb-c… r7            
#>  9 Slide_seqLevel1_metadata                 metadata     0 isb-c… r7            
#> 10 Slide_seqLevel2_metadata                 metadata     0 isb-c… r7            
#> # ℹ 68 more rows
htan_disconnect()