| 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 |
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.
geo_characteristics(con, gsm)geo_characteristics(con, gsm)
con |
A connection from
|
gsm |
character. GEO sample accessions. |
A tibble with columns gsm, channel (1 or 2), tag and
value.
con <- omicidx_connect() geo_characteristics(con, c("GSM4996084", "GSM4996085")) DBI::dbDisconnect(con)con <- omicidx_connect() geo_characteristics(con, c("GSM4996084", "GSM4996085")) DBI::dbDisconnect(con)
The GEOmetadb join of gse_gsm, gsm and gpl as one call.
geo_samples(con, gse)geo_samples(con, gse)
con |
A connection from
|
gse |
character. GEO series accessions. |
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.
con <- omicidx_connect() geo_samples(con, "GSE164073") DBI::dbDisconnect(con)con <- omicidx_connect() geo_samples(con, "GSE164073") DBI::dbDisconnect(con)
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.
omicidx_connect(version = "latest")omicidx_connect(version = "latest")
version |
character(1). |
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.
A DuckDB DBI::DBIConnection. Close it with
DBI::dbDisconnect().
omicidx_release() tells which release it is
connected to.
"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 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.
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.
con <- omicidx_connect() DBI::dbGetQuery(con, "SELECT count(*) AS n FROM sradb.study") DBI::dbDisconnect(con)con <- omicidx_connect() DBI::dbGetQuery(con, "SELECT count(*) AS n FROM sradb.study") DBI::dbDisconnect(con)
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()).
omicidx_db(con = NULL, version = "latest")omicidx_db(con = NULL, version = "latest")
con |
A connection from
|
version |
character(1). Release to connect to when |
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.
db <- omicidx_db() db db$sradb$study |> dplyr::count(study_type, sort = TRUE) |> head() |> dplyr::collect() DBI::dbDisconnect(attr(db, "con"))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
omicidx_describe(con, table)omicidx_describe(con, table)
con |
A connection from
|
table |
character(1). A table name, schema-qualified as in
|
A tibble with one row per column: column_name,
column_type and null (whether the column may hold NULLs).
con <- omicidx_connect() omicidx_describe(con, "sradb.study") DBI::dbDisconnect(con)con <- omicidx_connect() omicidx_describe(con, "sradb.study") DBI::dbDisconnect(con)
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.
omicidx_download(version = "latest", path, tables = NULL)omicidx_download(version = "latest", path, tables = NULL)
version |
character(1). |
path |
character(1). The DuckDB file to create. It must not exist. |
tables |
character. The tables to copy, as |
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.
path, invisibly. Open it with
DBI::dbConnect(duckdb::duckdb(), path); tables keep their names,
for example sradb.study.
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)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)
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.
omicidx_release(con)omicidx_release(con)
con |
A connection from
|
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.
con <- omicidx_connect() omicidx_release(con)$publish_date DBI::dbDisconnect(con)con <- omicidx_connect() omicidx_release(con)$publish_date DBI::dbDisconnect(con)
List the tables in an OmicIDX connection
omicidx_tables(con)omicidx_tables(con)
con |
A connection from
|
A tibble with columns schema, table and type ("VIEW"
or "BASE TABLE"), one row per table.
con <- omicidx_connect() omicidx_tables(con) DBI::dbDisconnect(con)con <- omicidx_connect() omicidx_tables(con) DBI::dbDisconnect(con)
The successor to SRAdb::sraConvert() and GEOmetadb::geoConvert().
Accessions of any supported type, mixed freely, are mapped to the
requested types.
sra_convert(con, in_acc, out_type = c("study", "sample", "experiment", "run")) geo_convert(con, in_acc, out_type = c("gse", "gpl", "gsm"))sra_convert(con, in_acc, out_type = c("study", "sample", "experiment", "run")) geo_convert(con, in_acc, out_type = c("gse", "gpl", "gsm"))
con |
A connection from
|
in_acc |
character. Accessions to convert; |
out_type |
character. Accession types to return. |
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.
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.
con <- omicidx_connect() sra_convert(con, "SRP000001") geo_convert(con, "GSE164073", c("gsm", "run")) DBI::dbDisconnect(con)con <- omicidx_connect() sra_convert(con, "SRP000001") geo_convert(con, "GSE164073", c("gsm", "run")) DBI::dbDisconnect(con)
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.
sra_runs(con, in_acc)sra_runs(con, in_acc)
con |
A connection from
|
in_acc |
character. Accessions of any type
|
A tibble with one row per run: its accessions, spots,
bases, library strategy, source, selection and layout, platform,
instrument model and organism.
con <- omicidx_connect() sra_runs(con, "SRP000001") DBI::dbDisconnect(con)con <- omicidx_connect() sra_runs(con, "SRP000001") DBI::dbDisconnect(con)
Case-insensitive substring search (SQL ILIKE) over SRA study titles
and abstracts, or GEO series titles and summaries. The successor to
SRAdb::getSRA() for finding studies; it is a plain pattern match,
not a ranked full-text search.
sra_search(con, query, limit = 100L) geo_search(con, query, limit = 100L)sra_search(con, query, limit = 100L) geo_search(con, query, limit = 100L)
con |
A connection from
|
query |
character(1). Text to find. |
limit |
integer(1). Maximum number of rows to return. |
A tibble of matching studies (sra_search(): from
sradb.study) or series (geo_search(): from geometadb.gse).
In geo_search() results, type, bioprojects and
sra_studies
are list-columns, since a series can have several of each; use
tidyr::unnest_longer() to get one row per value.
con <- omicidx_connect() sra_search(con, "single cell%glioma", limit = 5) series <- geo_search(con, "glioblastoma", limit = 5) if (requireNamespace("tidyr", quietly = TRUE)) { tidyr::unnest_longer(series[c("gse", "sra_studies")], "sra_studies") } DBI::dbDisconnect(con)con <- omicidx_connect() sra_search(con, "single cell%glioma", limit = 5) series <- geo_search(con, "glioblastoma", limit = 5) if (requireNamespace("tidyr", quietly = TRUE)) { tidyr::unnest_longer(series[c("gse", "sra_studies")], "sra_studies") } DBI::dbDisconnect(con)