Package 'omicidxr'

Title: Query SRA, GEO, BioSample and BioProject Metadata from OmicIDX
Description: OmicIDX publishes metadata from NCBI SRA, GEO, BioSample and BioProject as Parquet files, rebuilt nightly and released monthly. omicidxr connects DuckDB to a chosen release, so tens of millions of records can be queried with SQL or dplyr without downloading them. Helpers for accession conversion, run listing, GEO sample annotation and text search replace the main functions of the SRAdb and GEOmetadb packages, and releases can be pinned for reproducible analyses.
Authors: Sean Davis [aut, cre] (ORCID: <https://orcid.org/0000-0002-8991-6458>), National Cancer Institute [fnd] (ITCR award U24CA289073)
Maintainer: Sean Davis <[email protected]>
License: MIT + file LICENSE
Version: 0.99.0
Built: 2026-12-02 22:41:33 UTC
Source: https://github.com/BiocStaging/omicidxr

Help Index


Characteristics of GEO samples

Description

The characteristics_ch1 and characteristics_ch2 tag/value pairs of each sample, one row per pair. In GEOmetadb these were one ⁠;\t⁠-separated string per channel.

Usage

geo_characteristics(con, gsm)

Arguments

con

A connection from omicidx_connect(), or an omicidx_db().

gsm

character. GEO sample accessions.

Value

A tibble with columns gsm, channel (1 or 2), tag and value.

Examples

con <- omicidx_connect()
geo_characteristics(con, c("GSM4996084", "GSM4996085"))
DBI::dbDisconnect(con)

Samples and platforms of GEO series

Description

The GEOmetadb join of gse_gsm, gsm and gpl as one call.

Usage

geo_samples(con, gse)

Arguments

con

A connection from omicidx_connect(), or an omicidx_db().

gse

character. GEO series accessions.

Value

A tibble with one row per series and sample: gse, gsm, sample title, gpl, platform_title, organism, source, molecule, sample type, library_source, biosample and sra_experiment.

Examples

con <- omicidx_connect()
geo_samples(con, "GSE164073")
DBI::dbDisconnect(con)

Connect to an OmicIDX release

Description

Opens an in-memory DuckDB database and makes an OmicIDX release available in it. Nothing is downloaded up front: queries read the remote Parquet files over HTTPS, fetching only the columns and row groups they need.

Usage

omicidx_connect(version = "latest")

Arguments

version

character(1). "latest" (default), a date "YYYY-MM-DD" or a month "YYYY-MM". See the Versions section.

Details

After connecting, tables are referenced as schema.table, for example sradb.study or geometadb.gsm. Use omicidx_tables() to list them and omicidx_db() for tab-completable dplyr tables.

Value

A DuckDB DBI::DBIConnection. Close it with DBI::dbDisconnect(). omicidx_release() tells which release it is connected to.

Versions

  • "latest": the nightly build at ⁠https://omicidx.cancerdatasci.org/data/latest/⁠.

  • "YYYY-MM-DD": a dated nightly build. The 7 newest are kept, plus each week's last build (normally Sunday's) for 5 weeks; pin a Sunday build for an analysis you'll rerun over the next month.

  • "YYYY-MM": a monthly release on HuggingFace (seandavis/omicidx@YYYY-MM). Monthly releases are kept long term and are the version to cite.

Query "latest" and dated builds in place: they are served without rate limits. Treat monthly releases as the archive: copy one with omicidx_download("YYYY-MM", path) and query the local file. Connecting to a monthly release in place works, but takes about 30 seconds (DuckDB inspects every Parquet file while it creates the views) and runs into HuggingFace's rate limits.

HuggingFace rate limits

HuggingFace allows 3000 anonymous requests per 5 minutes per IP address, and connecting to a monthly release or running one query can make hundreds, so heavy use, or a shared IP address, fails with HTTP 429 (Too Many Requests) until the window resets. To avoid it:

  • Download the release with omicidx_download(), which waits out the limit, and query the local copy.

  • Set the environment variable HF_TOKEN to a HuggingFace access token, which raises the limit to that of a signed-in user.

  • Within a week of a monthly release, connect to the dated build it was published from (omicidx_release(con)$publish_date), which holds the same data.

Timeouts

Each HTTP request times out after 30 seconds and is retried up to 4 times, after waits of 0, 1, 4 and 16 seconds, which also rides out a brief HTTP 429. If connecting still fails, omicidx_connect() stops with an error naming the release URL.

Requests carry the User-Agent ⁠omicidxr/<package version>⁠. DuckDB extensions (httpfs, json) are downloaded once and cached in tools::R_user_dir("omicidxr", "cache"). The connection neither uses ⁠~/.duckdb⁠ nor reads DuckDB secrets persisted there.

Examples

con <- omicidx_connect()
DBI::dbGetQuery(con, "SELECT count(*) AS n FROM sradb.study")
DBI::dbDisconnect(con)

Tab-completable lazy tables for an OmicIDX release

Description

Returns every table in the release as a lazy dplyr table, nested by schema, so that ⁠db$sradb$<TAB>⁠ completes table names. Each table is built the first time it is accessed, and no data are read until a query is run (for example with dplyr::collect()).

Usage

omicidx_db(con = NULL, version = "latest")

Arguments

con

A connection from omicidx_connect(), or a version string to open a new one. Defaults to version.

version

character(1). Release to connect to when con is NULL; see omicidx_connect().

Value

An omicidx_db object: a named list with one element per schema, each an environment of lazy tables. The connection is available as attr(db, "con"), and its release, with row counts, as omicidx_release(db). All omicidxr helpers accept an omicidx_db in place of a connection.

Examples

db <- omicidx_db()
db
db$sradb$study |>
    dplyr::count(study_type, sort = TRUE) |>
    head() |>
    dplyr::collect()
DBI::dbDisconnect(attr(db, "con"))

Describe the columns of an OmicIDX table

Description

Describe the columns of an OmicIDX table

Usage

omicidx_describe(con, table)

Arguments

con

A connection from omicidx_connect(), or an omicidx_db() object.

table

character(1). A table name, schema-qualified as in "sradb.study". Unqualified names are looked up in main.

Value

A tibble with one row per column: column_name, column_type and null (whether the column may hold NULLs).

Examples

con <- omicidx_connect()
omicidx_describe(con, "sradb.study")
DBI::dbDisconnect(con)

Download an OmicIDX release into a local DuckDB file

Description

Copies the tables of a release into a new DuckDB database file, so they can be queried offline and at local-disk speed. The copy is checked against the row counts in the release's manifest.json. This is the R counterpart of the restore.sql published with each nightly build.

Usage

omicidx_download(version = "latest", path, tables = NULL)

Arguments

version

character(1). "latest" (default), a date "YYYY-MM-DD" or a month "YYYY-MM". See the Versions section.

path

character(1). The DuckDB file to create. It must not exist.

tables

character. The tables to copy, as "schema.table" (for example "sradb.study" or "main.sra_runs") or whole schemas (for example "sradb"). NULL (default) copies every table. omicidx_tables() lists them.

Details

A full release is large: about 75 GB of Parquet, which becomes a DuckDB file about 5 times that size (400 GB for "2026-10"), and took about an hour to copy. Pass tables to copy only what you need, such as the "sradb" or "geometadb" marts. Before copying, omicidx_download() reports the size of the Parquet it will read.

Tables are copied one at a time. Copying a monthly release makes tens of thousands of requests to HuggingFace, more than its rate limit allows in 5 minutes (see omicidx_connect()), so each request is retried for up to 6 minutes and the copy pauses while the limit resets. Setting HF_TOKEN raises the limit.

Value

path, invisibly. Open it with DBI::dbConnect(duckdb::duckdb(), path); tables keep their names, for example sradb.study.

Examples

path <- omicidx_download(
    "latest", tempfile(fileext = ".duckdb"), tables = "geometadb.gpl"
)
con <- DBI::dbConnect(duckdb::duckdb(), path, read_only = TRUE)
DBI::dbGetQuery(con, "SELECT count(*) AS n FROM geometadb.gpl")
DBI::dbDisconnect(con)

Which OmicIDX release a connection is on

Description

The release a connection from omicidx_connect() points at, with the provenance recorded in the release's manifest.json. Cite version and publish_date; transform_sha and lake_snapshot_id identify exactly how and from what the release was built.

Usage

omicidx_release(con)

Arguments

con

A connection from omicidx_connect(), or an omicidx_db() object.

Value

A list with version (as passed to omicidx_connect()), url (the release folder), and from manifest.json: publish_date, transform_sha (the commit of the OmicIDX transform code), lake_snapshot_id (the source data snapshot) and tables (a tibble of schema, table and row_count). The manifest fields are NA (tables is NULL) if manifest.json could not be read.

Examples

con <- omicidx_connect()
omicidx_release(con)$publish_date
DBI::dbDisconnect(con)

List the tables in an OmicIDX connection

Description

List the tables in an OmicIDX connection

Usage

omicidx_tables(con)

Arguments

con

A connection from omicidx_connect(), or an omicidx_db() object.

Value

A tibble with columns schema, table and type ("VIEW" or "BASE TABLE"), one row per table.

Examples

con <- omicidx_connect()
omicidx_tables(con)
DBI::dbDisconnect(con)

Convert between SRA, GEO, BioSample and BioProject accessions

Description

The successor to SRAdb::sraConvert() and GEOmetadb::geoConvert(). Accessions of any supported type, mixed freely, are mapped to the requested types.

Usage

sra_convert(con, in_acc, out_type = c("study", "sample", "experiment", "run"))

geo_convert(con, in_acc, out_type = c("gse", "gpl", "gsm"))

Arguments

con

A connection from omicidx_connect(), or an omicidx_db().

in_acc

character. Accessions to convert; in_list in GEOmetadb::geoConvert().

out_type

character. Accession types to return.

Details

Supported types: SRA study (SRP/ERP/DRP), sample (SRS/ERS/DRS), experiment (SRX/ERX/DRX) and run (SRR/ERR/DRR); biosample (SAMN/SAMEA/SAMD); bioproject (PRJNA/PRJEB/PRJDB); and GEO gse, gsm and gpl. SRA accessions are linked through runs (sradb.sra), so experiments without runs are not found, and GEO samples link to SRA through their SRA experiment. Converting a GPL returns every sample on that platform, which can be large.

Value

A tibble with one column per input type present and per out_type, with one row per distinct combination. NA where an accession has no link of that type.

Examples

con <- omicidx_connect()
sra_convert(con, "SRP000001")
geo_convert(con, "GSE164073", c("gsm", "run"))
DBI::dbDisconnect(con)

SRA runs for studies, experiments, samples or GEO accessions

Description

The runs behind each accession, with the fields needed to choose and download them: pass run_accession to prefetch or fasterq-dump from the SRA Toolkit. File URLs, sizes and checksums, as given by SRAdb::listSRAfile(), are out of scope.

Usage

sra_runs(con, in_acc)

Arguments

con

A connection from omicidx_connect(), or an omicidx_db().

in_acc

character. Accessions of any type sra_convert() supports, for example studies, experiments or GSEs.

Value

A tibble with one row per run: its accessions, spots, bases, library strategy, source, selection and layout, platform, instrument model and organism.

Examples

con <- omicidx_connect()
sra_runs(con, "SRP000001")
DBI::dbDisconnect(con)