Skip to contents

The `Omicidx` R6 class provides an interface for interacting with the omicidx database.

Public fields

connection

A DBI connection object to the omicidx database.

.dplyr_tbls

A list to cache dplyr table objects.

Methods


Method new()

Create a new `Omicidx` object

Usage

Omicidx$new(con = NULL)

Arguments

con

An optional DBI connection object. If NULL, a new connection will be created.

Returns

A new `Omicidx` object.


Method sql()

Execute a SQL query on the omicidx database.

Usage

Omicidx$sql(query)

Arguments

query

A string containing the SQL query to execute.

Returns

A data frame containing the results of the query.


Method table_names()

List all table names in the omicidx database.

Usage

Omicidx$table_names()

Returns

A data frame containing the names of all tables in the database.


Method tbl()

Get a dplyr table object for a specified table in the omicidx database.

Usage

Omicidx$tbl(table_name)

Arguments

table_name

A string specifying the name of the table.

Details

This method retrieves a dplyr table object for the specified table name. If the table has been previously accessed, it will return the cached version. If the table_name does not exist, an error will be raised.

Returns

A dplyr table object for the specified table.


Method clone()

The objects of this class are cloneable with this method.

Usage

Omicidx$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# # Create a new Omicidx object
omicidx <- Omicidx$new()
# # List all table names in the database
omicidx$table_names()
#>    ((table_schema || '.') || table_name)
#> 1                          main._catalog
#> 2                      mart.sra_metadata
#> 3                    raw.ncbi_biosamples
#> 4                    raw.sra_experiments
#> 5                           raw.sra_runs
#> 6                        raw.sra_samples
#> 7                        raw.sra_studies
#> 8              staging.stg_geo_platforms
#> 9                staging.stg_geo_samples
#> 10                staging.stg_geo_series
#> 11          staging.stg_ncbi_bioprojects
#> 12           staging.stg_ncbi_biosamples
#> 13            staging.stg_sra_accessions
#> 14           staging.stg_sra_experiments
#> 15                  staging.stg_sra_runs
#> 16               staging.stg_sra_samples
#> 17               staging.stg_sra_studies
# Get a dplyr table object for a specific table
sra_studies_tbl <- omicidx$tbl("staging.stg_sra_studies")
# Perform a dplyr query
result <- sra_studies_tbl |>
  filter(study_type == "RNA-Seq") |>
  head(10) |>
  collect()
print(result)
#> # A tibble: 0 × 17
#> # ℹ 17 variables: accession <chr>, study_accession <chr>, title <chr>,
#> #   description <chr>, abstract <chr>, study_type <chr>, center_name <chr>,
#> #   broker_name <chr>, alias <chr>, BioProject <chr>, GEO <chr>,
#> #   pubmed_ids <list>, has_complete_metadata <lgl>, attributes <list>,
#> #   identifiers <list>, xrefs <list>, _loaded_at <dttm>