| rduckhts_bed | R Documentation |
Creates a DuckDB table from a BED file using the DuckHTS extension.
rduckhts_bed(
con,
table_name,
path,
region = NULL,
index_path = NULL,
scan_mode = NULL,
overwrite = FALSE,
error_policy = NULL
)
con |
A DuckDB connection with DuckHTS loaded |
table_name |
Name for the created table |
path |
Path to the BED file |
region |
Optional genomic region for tabix-backed BED queries |
index_path |
Optional explicit path to a BED tabix index |
scan_mode |
Optional scan mode. Use |
overwrite |
Logical. If TRUE, overwrites an existing table |
error_policy |
Optional short-line policy: |
Invisible TRUE on success
con <- rduckhts_connect()
# Intervals are 0-based and half-open, like BED: keep BED starts as they are.
DBI::dbExecute(con, 'CREATE TABLE tiles AS SELECT * FROM (VALUES
(\'CHROMOSOME_I\', 0, 10), (\'CHROMOSOME_I\', 10, 20)) t(chrom, start, "end")')
DBI::dbGetQuery(con, "SELECT * FROM duckhts_cgranges_from_table(
'tiles_idx', 'tiles', 'chrom', 'start', 'end')")
# end is a reserved SQL word: quote the column as "end" in the select list and
# pass that column, not the string 'end', to the scalar functions.
rduckhts_bed(con, "targets", system.file("extdata", "targets.bed", package = "Rduckhts"))
DBI::dbGetQuery(con, 'SELECT chrom, start, "end",
duckhts_cgranges_count_overlaps(\'tiles_idx\', chrom, start, "end") AS tiles
FROM targets')
DBI::dbDisconnect(con, shutdown = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.