Skip to contents

Executes a database operation while managing the connection lifecycle automatically.

Usage

withTxDb(x, expr, ...)

# S4 method for class 'character,function'
withTxDb(x, expr, ...)

Arguments

x

Character string specifying the genome ("hg38", "hg19", or "mm10")

expr

Function to execute with database connection

...

Additional arguments passed to expr

Value

Result of the database operation

Details

Execute Database Operation with Automatic Connection Management

Examples

if (FALSE) { # \dontrun{
requireNamespace("TxDb.Hsapiens.UCSC.hg38.knownGene")
requireNamespace("org.Hs.eg.db")
result <- withTxDb("hg38", function(src) {
  genes <- Organism.dplyr::genes(src)
  return(genes)
})
print(result)
} # }