diff --git a/DESCRIPTION b/DESCRIPTION index 902fcd5..c4f518c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: bedbaser Title: A BEDbase client -Version: 0.99.16 +Version: 0.99.17 Authors@R: c( person( given = "Jen", diff --git a/R/bedbaser.R b/R/bedbaser.R index ae55231..fdc5e37 100644 --- a/R/bedbaser.R +++ b/R/bedbaser.R @@ -39,16 +39,16 @@ #' @return BEDbase object #' #' @examples -#' api <- BEDbase(cache_path = tempdir()) -#' ex_bed <- bb_example(api, "bed") -#' bb_metadata(api, ex_bed$id) +#' bedbase <- BEDbase(cache_path = tempdir()) +#' ex_bed <- bb_example(bedbase, "bed") +#' bb_metadata(bedbase, ex_bed$id) #' #' @export BEDbase <- function(cache_path, quietly = FALSE) { if (missing(cache_path)) { cache_path <- tools::R_user_dir("bedbaser", which = "cache") } - api <- suppressWarnings( + bedbase <- suppressWarnings( .BEDbase( cache = BiocFileCache::BiocFileCache(cache_path), AnVIL::Service( @@ -62,11 +62,12 @@ BEDbase <- function(cache_path, quietly = FALSE) { ) ) ) - info <- httr::content(api$list_beds_v1_bed_list_get(limit = 0, offset = 0)) + info <- httr::content( + bedbase$list_beds_v1_bed_list_get(limit = 0, offset = 0)) if (!quietly) { message(info$count, " BED files available.") } - api + bedbase } #' @rdname BEDbase @@ -85,8 +86,8 @@ setGeneric("getCache", function(x, quietly = TRUE) standardGeneric("getCache")) #' @return BiocFileCache(1) object of BED files #' #' @examples -#' api <- BEDbase(tempdir()) -#' getCache(api) +#' bedbase <- BEDbase(tempdir()) +#' getCache(bedbase) #' #' @export setMethod( @@ -120,8 +121,8 @@ setGeneric( #' @return BiocFileCache(1) object of BED files #' #' @examples -#' api <- BEDbase(tempdir()) -#' api <- setCache(api, "/tmp") +#' bedbase <- BEDbase(tempdir()) +#' bedbase <- setCache(bedbase, "/tmp") #' #' @export setMethod( @@ -146,8 +147,8 @@ setMethod( #' @return list(1) API end points #' #' @examples -#' api <- BEDbase() -#' operations(api) +#' bedbase <- BEDbase() +#' operations(bedbase) #' #' @export setMethod( @@ -157,17 +158,17 @@ setMethod( } ) -#' Display schemas +#' Display schemas #' #' @param x BEDbase(1) object #' -#' @importFrom AnVIL schemas +#' @importFrom AnVIL schemas #' #' @return list(1) API end points #' #' @examples -#' api <- BEDbase() -#' schemas(api) +#' bedbase <- BEDbase() +#' schemas(bedbase) #' #' @export setMethod( @@ -177,10 +178,10 @@ setMethod( } ) -#' Display tags +#' Display tags #' #' @param x BEDbase(1) object -#' @param .tags character() tags for filtering operations +#' @param .tags character() tags for filtering operations #' @param .deprecated (default \code{FALSE}) if deprecated #' #' @importFrom AnVIL tags @@ -188,8 +189,8 @@ setMethod( #' @return list(1) API end points #' #' @examples -#' api <- BEDbase() -#' tags(api) +#' bedbase <- BEDbase() +#' tags(bedbase) #' #' @export setMethod( @@ -201,23 +202,23 @@ setMethod( #' Get the example BED file or BEDset with metadata #' -#' @param api API object of BEDbase created from BEDbase() +#' @param bedbase API object of BEDbase created from BEDbase() #' @param rec_type character(1) bed or bedset #' #' @return list(1) bed files or bedsets #' #' @examples -#' api <- BEDbase() -#' bb_example(api, "bed") -#' bb_example(api, "bedset") +#' bedbase <- BEDbase() +#' bb_example(bedbase, "bed") +#' bb_example(bedbase, "bedset") #' #' @export -bb_example <- function(api, rec_type = c("bed", "bedset")) { +bb_example <- function(bedbase, rec_type = c("bed", "bedset")) { rec_type <- match.arg(rec_type) if (rec_type == "bed") { - rsp <- api$get_example_bed_record_v1_bed_example_get() + rsp <- bedbase$get_example_bed_record_v1_bed_example_get() } else { - rsp <- api$get_example_bedset_record_v1_bedset_example_get() + rsp <- bedbase$get_example_bedset_record_v1_bedset_example_get() } httr::content(rsp) } @@ -229,7 +230,7 @@ bb_example <- function(api, rec_type = c("bed", "bedset")) { #' #' @rdname bb_metadata #' -#' @param api API object created from \code{BEDbase()} +#' @param bedbase API object created from \code{BEDbase()} #' @param id integer1() record or object identifier #' @param full logical(1) (default \code{FALSE}) include full record with #' stats, files, and metadata @@ -237,22 +238,22 @@ bb_example <- function(api, rec_type = c("bed", "bedset")) { #' @return list(1) metadata #' #' @examples -#' api <- BEDbase() +#' bedbase <- BEDbase() #' -#' ex_bed <- bb_example(api, "bed") -#' bb_metadata(api, ex_bed$id) +#' ex_bed <- bb_example(bedbase, "bed") +#' bb_metadata(bedbase, ex_bed$id) #' -#' ex_bedset <- bb_example(api, "bedset") -#' bb_metadata(api, ex_bedset$id) +#' ex_bedset <- bb_example(bedbase, "bedset") +#' bb_metadata(bedbase, ex_bedset$id) #' #' @export -bb_metadata <- function(api, id, full = FALSE) { - rsp <- api$get_bed_metadata_v1_bed__bed_id__metadata_get( +bb_metadata <- function(bedbase, id, full = FALSE) { + rsp <- bedbase$get_bed_metadata_v1_bed__bed_id__metadata_get( bed_id = id, full = full ) if (rsp$status_code != 200) { - rsp <- api$get_bedset_metadata_v1_bedset__bedset_id__metadata_get( + rsp <- bedbase$get_bedset_metadata_v1_bedset__bedset_id__metadata_get( bedset_id = id, full = full ) @@ -271,7 +272,7 @@ bb_metadata <- function(api, id, full = FALSE) { #' #' @rdname bb_list_beds #' -#' @param api API object created from \code{BEDbase()} +#' @param bedbase API object created from \code{BEDbase()} #' @param genome character(1) (default \code{NULL}) genome keyword #' @param bed_type character(1) (default \code{NULL}) bed file type #' @param limit integer(1) (default \code{1000}) maximum records @@ -280,14 +281,13 @@ bb_metadata <- function(api, id, full = FALSE) { #' @return tibble(1) of BED records #' #' @examples -#' api <- BEDbase() -#' bb_list_beds(api) +#' bedbase <- BEDbase() +#' bb_list_beds(bedbase) #' #' @export -bb_list_beds <- function( - api, genome = NULL, bed_type = NULL, limit = 1000, - offset = 0) { - rsp <- api$list_beds_v1_bed_list_get( +bb_list_beds <- function(bedbase, genome = NULL, bed_type = NULL, limit = 1000, + offset = 0) { + rsp <- bedbase$list_beds_v1_bed_list_get( genome = genome, bed_type = bed_type, limit = limit, offset = offset ) @@ -308,7 +308,7 @@ bb_list_beds <- function( #' #' @rdname bb_list_bedsets #' -#' @param api API object of BEDbase created from BEDbase() +#' @param bedbase API object of BEDbase created from BEDbase() #' @param query character() (default \code{NULL}) keyword #' @param limit integer(1) (default \code{1000}) maximum records #' @param offset integer(1) (default \code{0}) page token of records @@ -316,12 +316,12 @@ bb_list_beds <- function( #' @return tibble(1) of BEDset records #' #' @examples -#' api <- BEDbase() -#' bb_list_bedsets(api) +#' bedbase <- BEDbase() +#' bb_list_bedsets(bedbase) #' #' @export -bb_list_bedsets <- function(api, query = NULL, limit = 1000, offset = 0) { - rsp <- api$list_bedsets_v1_bedset_list_get( +bb_list_bedsets <- function(bedbase, query = NULL, limit = 1000, offset = 0) { + rsp <- bedbase$list_bedsets_v1_bedset_list_get( query = query, limit = limit, offset = offset @@ -339,19 +339,19 @@ bb_list_bedsets <- function(api, query = NULL, limit = 1000, offset = 0) { #' #' @rdname bb_beds_in_bedset #' -#' @param api API object of BEDbase created from BEDbase() +#' @param bedbase API object of BEDbase created from BEDbase() #' @param bedset_id integer(1) BEDset record identifier #' #' @return tibble(1) information of BED files in BEDset #' #' @examples -#' api <- BEDbase() -#' ex_bedset <- bb_example(api, "bedset") -#' bb_beds_in_bedset(api, ex_bedset$id) +#' bedbase <- BEDbase() +#' ex_bedset <- bb_example(bedbase, "bedset") +#' bb_beds_in_bedset(bedbase, ex_bedset$id) #' #' @export -bb_beds_in_bedset <- function(api, bedset_id) { - rsp <- api$get_bedfiles_in_bedset_v1_bedset__bedset_id__bedfiles_get( +bb_beds_in_bedset <- function(bedbase, bedset_id) { + rsp <- bedbase$get_bedfiles_in_bedset_v1_bedset__bedset_id__bedfiles_get( bedset_id = bedset_id ) recs <- httr::content(rsp) @@ -373,7 +373,7 @@ bb_beds_in_bedset <- function(api, bedset_id) { #' #' @rdname bb_bed_text_search #' -#' @param api API object of BEDbase created from \code{BEDbase()} +#' @param bedbase API object of BEDbase created from \code{BEDbase()} #' @param query character(1) keywords to search #' @param limit integer(1) (default \code{10}) maximum number of results #' @param offset integer(1) (default \code{0}) page offset of results @@ -381,13 +381,13 @@ bb_beds_in_bedset <- function(api, bedset_id) { #' @return tibble(1) of results #' #' @examples -#' api <- BEDbase() -#' bb_bed_text_search(api, "hg38") +#' bedbase <- BEDbase() +#' bb_bed_text_search(bedbase, "hg38") #' #' @export -bb_bed_text_search <- function(api, query, limit = 10, offset = 0) { +bb_bed_text_search <- function(bedbase, query, limit = 10, offset = 0) { encoded_query <- utils::URLencode(query, reserved = TRUE) - rsp <- api$text_to_bed_search_v1_bed_search_text_post( + rsp <- bedbase$text_to_bed_search_v1_bed_search_text_post( query = encoded_query, limit = limit, offset = offset @@ -407,7 +407,7 @@ bb_bed_text_search <- function(api, query, limit = 10, offset = 0) { #' #' @rdname bb_to_granges #' -#' @param api API object of BEDbase created from \code{BEDbase()} +#' @param bedbase API object of BEDbase created from \code{BEDbase()} #' @param bed_id integer(1) BED record identifier #' @param file_type character(1) bed or bigbed #' @param extra_cols character() (default \code{NULL}) extra column names to @@ -417,17 +417,17 @@ bb_bed_text_search <- function(api, query, limit = 10, offset = 0) { #' @return GRanges(1) object #' #' @examples -#' api <- BEDbase() -#' ex_bed <- bb_example(api, "bed") -#' bb_to_granges(api, ex_bed$id) +#' bedbase <- BEDbase() +#' ex_bed <- bb_example(bedbase, "bed") +#' bb_to_granges(bedbase, ex_bed$id) #' #' @export -bb_to_granges <- function( - api, bed_id, file_type = "bed", extra_cols = NULL, - quietly = TRUE) { +bb_to_granges <- function(bedbase, bed_id, file_type = "bed", extra_cols = NULL, + quietly = TRUE) { stopifnot(file_type %in% c("bed", "bigbed")) - metadata <- bb_metadata(api, bed_id, TRUE) - file_path <- .get_file(metadata, getCache(api), file_type, "http", quietly) + metadata <- bb_metadata(bedbase, bed_id, TRUE) + file_path <- .get_file(metadata, getCache(bedbase), file_type, "http", + quietly) if (file_type == "bed") { .bed_file_to_granges(file_path, metadata, extra_cols, quietly) @@ -449,22 +449,22 @@ bb_to_granges <- function( #' #' @rdname bb_to_grangeslist #' -#' @param api API object of BEDbase created from \code{BEDbase()} +#' @param bedbase API object of BEDbase created from \code{BEDbase()} #' @param bedset_id integer(1) BEDset record identifier #' @param quietly logical(1) (default \code{TRUE}) display messages #' #' @return GRangesList(1) object #' #' @examples -#' api <- BEDbase() -#' bb_to_grangeslist(api, "lola_hg38_ucsc_features") +#' bedbase <- BEDbase() +#' bb_to_grangeslist(bedbase, "lola_hg38_ucsc_features") #' #' @export -bb_to_grangeslist <- function(api, bedset_id, quietly = TRUE) { - beds <- bb_beds_in_bedset(api, bedset_id) +bb_to_grangeslist <- function(bedbase, bedset_id, quietly = TRUE) { + beds <- bb_beds_in_bedset(bedbase, bedset_id) gros <- list() for (bed_id in beds$id) { - gro <- bb_to_granges(api, bed_id, quietly = quietly) + gro <- bb_to_granges(bedbase, bed_id, quietly = quietly) gros[[length(gros) + 1]] <- gro } GenomicRanges::GRangesList(gros) @@ -474,7 +474,7 @@ bb_to_grangeslist <- function(api, bedset_id, quietly = TRUE) { #' #' @rdname bb_save #' -#' @param api API object of BEDbase created from BEDbase() +#' @param bedbase API object of BEDbase created from BEDbase() #' @param bed_or_bedset_id integer(1) BED or BEDset record identifier #' @param path character(1) directory to save file #' @param file_type character(1) (default \code{"bed"}) bed, bigbed, etc. @@ -484,25 +484,24 @@ bb_to_grangeslist <- function(api, bedset_id, quietly = TRUE) { #' @return An invisible \code{NULL} #' #' @examples -#' api <- BEDbase() -#' ex_bed <- bb_example(api, "bed") -#' bb_save(api, ex_bed$id, tempdir()) +#' bedbase <- BEDbase() +#' ex_bed <- bb_example(bedbase, "bed") +#' bb_save(bedbase, ex_bed$id, tempdir()) #' #' @export -bb_save <- function( - api, bed_or_bedset_id, path, file_type = "bed", - access_type = "http", quietly = TRUE) { +bb_save <- function(bedbase, bed_or_bedset_id, path, file_type = "bed", + access_type = "http", quietly = TRUE) { if (!dir.exists(path)) { rlang::abort(paste(path, "doesn't exist.", sep = " ")) } - metadata <- bb_metadata(api, bed_or_bedset_id, TRUE) + metadata <- bb_metadata(bedbase, bed_or_bedset_id, TRUE) if ("bedsets" %in% names(metadata)) { ids <- list(metadata$id) } else { ids <- metadata$bed_ids } for (id in ids) { - metadata <- bb_metadata(api, id, TRUE) + metadata <- bb_metadata(bedbase, id, TRUE) .get_file(metadata, path, file_type, access_type, quietly) } } diff --git a/R/utils.R b/R/utils.R index f0e7a68..a140c99 100644 --- a/R/utils.R +++ b/R/utils.R @@ -5,9 +5,9 @@ #' @return tibble(1) file metadata #' #' @examples -#' api <- BEDbase() -#' ex_bed <- bb_example(api, "bed") -#' ex_metadata <- bb_metadata(api, ex_bed$id, TRUE) +#' bedbase <- BEDbase() +#' ex_bed <- bb_example(bedbase, "bed") +#' ex_metadata <- bb_metadata(bedbase, ex_bed$id, TRUE) #' .format_metadata_files(ex_bed$files) #' #' @noRd @@ -30,9 +30,9 @@ #' @return character(1) file path #' #' @examples -#' api <- BEDbase() -#' ex_bed <- bb_example(api, "bed") -#' md <- bb_metadata(api, ex_bed$id, TRUE) +#' bedbase <- BEDbase() +#' ex_bed <- bb_example(bedbase, "bed") +#' md <- bb_metadata(bedbase, ex_bed$id, TRUE) #' .get_file(md, tempdir(), "bed", "http") #' #' @noRd @@ -75,9 +75,9 @@ #' #' @examples #' id <- "608827efc82fcaa4b0bfc65f590ffef8" -#' api <- BEDbase() -#' md <- bb_metadata(api, id, TRUE) -#' file_path <- .get_file(md, getCache(api), "bed", "http") +#' bedbase <- BEDbase() +#' md <- bb_metadata(bedbase, id, TRUE) +#' file_path <- .get_file(md, getCache(bedbase), "bed", "http") #' .get_extra_cols(file_path, 3, 9) #' #' @noRd @@ -104,10 +104,10 @@ #' @return GRanges(1) object representing BED #' #' @examples -#' api <- BEDbase() -#' ex_bed <- bb_example(api, "bed") -#' md <- bb_metadata(api, ex_bed$id, TRUE) -#' file_path <- .get_file(md, getCache(api), "bed", "http") +#' bedbase <- BEDbase() +#' ex_bed <- bb_example(bedbase, "bed") +#' md <- bb_metadata(bedbase, ex_bed$id, TRUE) +#' file_path <- .get_file(md, getCache(bedbase), "bed", "http") #' args <- list( #' con = file_path, #' format = gsub("peak", "Peak", metadata$bed_format), @@ -145,10 +145,10 @@ #' @return GRanges(1) object representing BED #' #' @examples -#' api <- BEDbase() -#' ex_bed <- bb_example(api, "bed") -#' md <- bb_metadata(api, ex_bed$id, TRUE) -#' file_path <- .get_file(md, getCache(api), "bed", "http") +#' bedbase <- BEDbase() +#' ex_bed <- bb_example(bedbase, "bed") +#' md <- bb_metadata(bedbase, ex_bed$id, TRUE) +#' file_path <- .get_file(md, getCache(bedbase), "bed", "http") #' .bed_file_to_granges(file_path, md) #' #' @noRd diff --git a/man/BEDbase.Rd b/man/BEDbase.Rd index e8edbb9..4a7f344 100644 --- a/man/BEDbase.Rd +++ b/man/BEDbase.Rd @@ -44,8 +44,8 @@ The convenience functions are as follows } } \examples{ -api <- BEDbase(cache_path = tempdir()) -ex_bed <- bb_example(api, "bed") -bb_metadata(api, ex_bed$id) +bedbase <- BEDbase(cache_path = tempdir()) +ex_bed <- bb_example(bedbase, "bed") +bb_metadata(bedbase, ex_bed$id) } diff --git a/man/bb_bed_text_search.Rd b/man/bb_bed_text_search.Rd index ee08600..be83dca 100644 --- a/man/bb_bed_text_search.Rd +++ b/man/bb_bed_text_search.Rd @@ -4,10 +4,10 @@ \alias{bb_bed_text_search} \title{Search BED files by text} \usage{ -bb_bed_text_search(api, query, limit = 10, offset = 0) +bb_bed_text_search(bedbase, query, limit = 10, offset = 0) } \arguments{ -\item{api}{API object of BEDbase created from \code{BEDbase()}} +\item{bedbase}{API object of BEDbase created from \code{BEDbase()}} \item{query}{character(1) keywords to search} @@ -22,7 +22,7 @@ tibble(1) of results Returns all available results scored. } \examples{ -api <- BEDbase() -bb_bed_text_search(api, "hg38") +bedbase <- BEDbase() +bb_bed_text_search(bedbase, "hg38") } diff --git a/man/bb_beds_in_bedset.Rd b/man/bb_beds_in_bedset.Rd index 0b1f5a2..edbe6d1 100644 --- a/man/bb_beds_in_bedset.Rd +++ b/man/bb_beds_in_bedset.Rd @@ -4,10 +4,10 @@ \alias{bb_beds_in_bedset} \title{Get BEDs associated with BEDset} \usage{ -bb_beds_in_bedset(api, bedset_id) +bb_beds_in_bedset(bedbase, bedset_id) } \arguments{ -\item{api}{API object of BEDbase created from BEDbase()} +\item{bedbase}{API object of BEDbase created from BEDbase()} \item{bedset_id}{integer(1) BEDset record identifier} } @@ -18,8 +18,8 @@ tibble(1) information of BED files in BEDset Get BEDs associated with BEDset } \examples{ -api <- BEDbase() -ex_bedset <- bb_example(api, "bedset") -bb_beds_in_bedset(api, ex_bedset$id) +bedbase <- BEDbase() +ex_bedset <- bb_example(bedbase, "bedset") +bb_beds_in_bedset(bedbase, ex_bedset$id) } diff --git a/man/bb_example.Rd b/man/bb_example.Rd index 8a894f6..caa298c 100644 --- a/man/bb_example.Rd +++ b/man/bb_example.Rd @@ -4,10 +4,10 @@ \alias{bb_example} \title{Get the example BED file or BEDset with metadata} \usage{ -bb_example(api, rec_type = c("bed", "bedset")) +bb_example(bedbase, rec_type = c("bed", "bedset")) } \arguments{ -\item{api}{API object of BEDbase created from BEDbase()} +\item{bedbase}{API object of BEDbase created from BEDbase()} \item{rec_type}{character(1) bed or bedset} } @@ -18,8 +18,8 @@ list(1) bed files or bedsets Get the example BED file or BEDset with metadata } \examples{ -api <- BEDbase() -bb_example(api, "bed") -bb_example(api, "bedset") +bedbase <- BEDbase() +bb_example(bedbase, "bed") +bb_example(bedbase, "bedset") } diff --git a/man/bb_list_beds.Rd b/man/bb_list_beds.Rd index b337361..17961ec 100644 --- a/man/bb_list_beds.Rd +++ b/man/bb_list_beds.Rd @@ -4,10 +4,10 @@ \alias{bb_list_beds} \title{List BEDs} \usage{ -bb_list_beds(api, genome = NULL, bed_type = NULL, limit = 1000, offset = 0) +bb_list_beds(bedbase, genome = NULL, bed_type = NULL, limit = 1000, offset = 0) } \arguments{ -\item{api}{API object created from \code{BEDbase()}} +\item{bedbase}{API object created from \code{BEDbase()}} \item{genome}{character(1) (default \code{NULL}) genome keyword} @@ -24,7 +24,7 @@ tibble(1) of BED records List BEDs } \examples{ -api <- BEDbase() -bb_list_beds(api) +bedbase <- BEDbase() +bb_list_beds(bedbase) } diff --git a/man/bb_list_bedsets.Rd b/man/bb_list_bedsets.Rd index f8620f5..c379379 100644 --- a/man/bb_list_bedsets.Rd +++ b/man/bb_list_bedsets.Rd @@ -4,10 +4,10 @@ \alias{bb_list_bedsets} \title{List BEDsets} \usage{ -bb_list_bedsets(api, query = NULL, limit = 1000, offset = 0) +bb_list_bedsets(bedbase, query = NULL, limit = 1000, offset = 0) } \arguments{ -\item{api}{API object of BEDbase created from BEDbase()} +\item{bedbase}{API object of BEDbase created from BEDbase()} \item{query}{character() (default \code{NULL}) keyword} @@ -22,7 +22,7 @@ tibble(1) of BEDset records List BEDsets } \examples{ -api <- BEDbase() -bb_list_bedsets(api) +bedbase <- BEDbase() +bb_list_bedsets(bedbase) } diff --git a/man/bb_metadata.Rd b/man/bb_metadata.Rd index 26506ae..ebb5138 100644 --- a/man/bb_metadata.Rd +++ b/man/bb_metadata.Rd @@ -4,10 +4,10 @@ \alias{bb_metadata} \title{Get metadata for a BED file or BEDset} \usage{ -bb_metadata(api, id, full = FALSE) +bb_metadata(bedbase, id, full = FALSE) } \arguments{ -\item{api}{API object created from \code{BEDbase()}} +\item{bedbase}{API object created from \code{BEDbase()}} \item{id}{integer1() record or object identifier} @@ -22,12 +22,12 @@ Get metadata for a BED file or BEDset. Abort if not found or id is not not 32 characters } \examples{ -api <- BEDbase() +bedbase <- BEDbase() -ex_bed <- bb_example(api, "bed") -bb_metadata(api, ex_bed$id) +ex_bed <- bb_example(bedbase, "bed") +bb_metadata(bedbase, ex_bed$id) -ex_bedset <- bb_example(api, "bedset") -bb_metadata(api, ex_bedset$id) +ex_bedset <- bb_example(bedbase, "bedset") +bb_metadata(bedbase, ex_bedset$id) } diff --git a/man/bb_save.Rd b/man/bb_save.Rd index 825334c..6d069d7 100644 --- a/man/bb_save.Rd +++ b/man/bb_save.Rd @@ -5,7 +5,7 @@ \title{Save a BED or BEDset files to a path given an id} \usage{ bb_save( - api, + bedbase, bed_or_bedset_id, path, file_type = "bed", @@ -14,7 +14,7 @@ bb_save( ) } \arguments{ -\item{api}{API object of BEDbase created from BEDbase()} +\item{bedbase}{API object of BEDbase created from BEDbase()} \item{bed_or_bedset_id}{integer(1) BED or BEDset record identifier} @@ -33,8 +33,8 @@ An invisible \code{NULL} Save a BED or BEDset files to a path given an id } \examples{ -api <- BEDbase() -ex_bed <- bb_example(api, "bed") -bb_save(api, ex_bed$id, tempdir()) +bedbase <- BEDbase() +ex_bed <- bb_example(bedbase, "bed") +bb_save(bedbase, ex_bed$id, tempdir()) } diff --git a/man/bb_to_granges.Rd b/man/bb_to_granges.Rd index 320e581..dfc2be7 100644 --- a/man/bb_to_granges.Rd +++ b/man/bb_to_granges.Rd @@ -5,7 +5,7 @@ \title{Create a GRanges object given a BED id} \usage{ bb_to_granges( - api, + bedbase, bed_id, file_type = "bed", extra_cols = NULL, @@ -13,7 +13,7 @@ bb_to_granges( ) } \arguments{ -\item{api}{API object of BEDbase created from \code{BEDbase()}} +\item{bedbase}{API object of BEDbase created from \code{BEDbase()}} \item{bed_id}{integer(1) BED record identifier} @@ -31,8 +31,8 @@ GRanges(1) object Generates the column and types for broad and narrow peak files. } \examples{ -api <- BEDbase() -ex_bed <- bb_example(api, "bed") -bb_to_granges(api, ex_bed$id) +bedbase <- BEDbase() +ex_bed <- bb_example(bedbase, "bed") +bb_to_granges(bedbase, ex_bed$id) } diff --git a/man/bb_to_grangeslist.Rd b/man/bb_to_grangeslist.Rd index f35fc3b..9350e98 100644 --- a/man/bb_to_grangeslist.Rd +++ b/man/bb_to_grangeslist.Rd @@ -4,10 +4,10 @@ \alias{bb_to_grangeslist} \title{Create a GRangesList object given a BEDset id} \usage{ -bb_to_grangeslist(api, bedset_id, quietly = TRUE) +bb_to_grangeslist(bedbase, bedset_id, quietly = TRUE) } \arguments{ -\item{api}{API object of BEDbase created from \code{BEDbase()}} +\item{bedbase}{API object of BEDbase created from \code{BEDbase()}} \item{bedset_id}{integer(1) BEDset record identifier} @@ -20,7 +20,7 @@ GRangesList(1) object Create a GRangesList object given a BEDset id } \examples{ -api <- BEDbase() -bb_to_grangeslist(api, "lola_hg38_ucsc_features") +bedbase <- BEDbase() +bb_to_grangeslist(bedbase, "lola_hg38_ucsc_features") } diff --git a/man/getCache-BEDbase-method.Rd b/man/getCache-BEDbase-method.Rd index b77b3c0..633c442 100644 --- a/man/getCache-BEDbase-method.Rd +++ b/man/getCache-BEDbase-method.Rd @@ -18,7 +18,7 @@ BiocFileCache(1) object of BED files Return cache path } \examples{ -api <- BEDbase(tempdir()) -getCache(api) +bedbase <- BEDbase(tempdir()) +getCache(bedbase) } diff --git a/man/operations-BEDbase-method.Rd b/man/operations-BEDbase-method.Rd index 1547a48..5f84433 100644 --- a/man/operations-BEDbase-method.Rd +++ b/man/operations-BEDbase-method.Rd @@ -20,7 +20,7 @@ list(1) API end points Display API } \examples{ -api <- BEDbase() -operations(api) +bedbase <- BEDbase() +operations(bedbase) } diff --git a/man/schemas-BEDbase-method.Rd b/man/schemas-BEDbase-method.Rd new file mode 100644 index 0000000..986063a --- /dev/null +++ b/man/schemas-BEDbase-method.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bedbaser.R +\name{schemas,BEDbase-method} +\alias{schemas,BEDbase-method} +\title{Display schemas} +\usage{ +\S4method{schemas}{BEDbase}(x) +} +\arguments{ +\item{x}{BEDbase(1) object} +} +\value{ +list(1) API end points +} +\description{ +Display schemas +} +\examples{ +bedbase <- BEDbase() +schemas(bedbase) + +} diff --git a/man/setCache-BEDbase-method.Rd b/man/setCache-BEDbase-method.Rd index f629c90..2c73488 100644 --- a/man/setCache-BEDbase-method.Rd +++ b/man/setCache-BEDbase-method.Rd @@ -20,7 +20,7 @@ BiocFileCache(1) object of BED files Set cache path } \examples{ -api <- BEDbase(tempdir()) -api <- setCache(api, "/tmp") +bedbase <- BEDbase(tempdir()) +bedbase <- setCache(bedbase, "/tmp") } diff --git a/man/tags-BEDbase-method.Rd b/man/tags-BEDbase-method.Rd new file mode 100644 index 0000000..fcc3f1b --- /dev/null +++ b/man/tags-BEDbase-method.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bedbaser.R +\name{tags,BEDbase-method} +\alias{tags,BEDbase-method} +\title{Display tags} +\usage{ +\S4method{tags}{BEDbase}(x, .tags, .deprecated = FALSE) +} +\arguments{ +\item{x}{BEDbase(1) object} + +\item{.tags}{character() tags for filtering operations} + +\item{.deprecated}{(default \code{FALSE}) if deprecated} +} +\value{ +list(1) API end points +} +\description{ +Display tags +} +\examples{ +bedbase <- BEDbase() +tags(bedbase) + +} diff --git a/tests/testthat/test-bedbaser.R b/tests/testthat/test-bedbaser.R index 6d91d29..6ce448e 100644 --- a/tests/testthat/test-bedbaser.R +++ b/tests/testthat/test-bedbaser.R @@ -1,9 +1,9 @@ test_that("setCache changes cache", { - api <- BEDbase(quietly = TRUE) + bedbase <- BEDbase(quietly = TRUE) path <- tempdir() - expect_true(BiocFileCache::bfccache(getCache(api)) != path) - api <- setCache(api, path) - expect_true(BiocFileCache::bfccache(getCache(api)) == path) + expect_true(BiocFileCache::bfccache(getCache(bedbase)) != path) + bedbase <- setCache(bedbase, path) + expect_true(BiocFileCache::bfccache(getCache(bedbase)) == path) }) test_that("bb_example has bed_format of 'bed' given rec_type 'bed'", { @@ -17,71 +17,71 @@ test_that("bb_example has 'bed_ids' given rec_type 'bedset'", { }) test_that("bb_metadata returns metadata for BEDs", { - api <- BEDbase(quietly = TRUE) - ex_bed <- bb_example(api, "bed") - ex_metadata <- httr::content(api$get_bed_metadata_v1_bed__bed_id__metadata_get(ex_bed$id, TRUE)) - bed_metadata <- bb_metadata(api, ex_bed$id, TRUE) + bedbase <- BEDbase(quietly = TRUE) + ex_bed <- bb_example(bedbase, "bed") + ex_metadata <- httr::content(bedbase$get_bed_metadata_v1_bed__bed_id__metadata_get(ex_bed$id, TRUE)) + bed_metadata <- bb_metadata(bedbase, ex_bed$id, TRUE) expect_identical(ex_metadata, bed_metadata) }) test_that("bb_metadata returns metadata for BEDsets", { - api <- BEDbase(quietly = TRUE) - ex_bedset <- bb_example(api, "bedset") - ex_bedset_metadata <- httr::content(api$get_bedset_metadata_v1_bedset__bedset_id__metadata_get(ex_bedset$id, TRUE)) - bedset_metadata <- bb_metadata(api, ex_bedset$id, TRUE) + bedbase <- BEDbase(quietly = TRUE) + ex_bedset <- bb_example(bedbase, "bedset") + ex_bedset_metadata <- httr::content(bedbase$get_bedset_metadata_v1_bedset__bedset_id__metadata_get(ex_bedset$id, TRUE)) + bedset_metadata <- bb_metadata(bedbase, ex_bedset$id, TRUE) expect_identical(ex_bedset_metadata, bedset_metadata) }) test_that("bb_metadata errors on invalid input", { - api <- BEDbase(quietly = TRUE) - expect_error(bb_metadata(api, "invalid_invalid_invalid_invalid_", "bed")) + bedbase <- BEDbase(quietly = TRUE) + expect_error(bb_metadata(bedbase, "invalid_invalid_invalid_invalid_", "bed")) }) test_that("bb_list_beds returns same number of results for the hg19 genome", { - api <- BEDbase(quietly = TRUE) - hg19_beds_raw <- httr::content(api$list_beds_v1_bed_list_get(genome = "hg19")) + bedbase <- BEDbase(quietly = TRUE) + hg19_beds_raw <- httr::content(bedbase$list_beds_v1_bed_list_get(genome = "hg19")) hg19_bed_names <- unlist(lapply(hg19_beds_raw$results, `[`, c("name")), use.names = FALSE ) - hg19_beds <- bb_list_beds(api, genome = "hg19") + hg19_beds <- bb_list_beds(bedbase, genome = "hg19") expect_equal(hg19_bed_names, hg19_beds$name) expect_true(all(hg19_beds$genome_alias == "hg19")) }) test_that("bb_list_bedsets returns same number for query hg19", { - api <- BEDbase(quietly = TRUE) - bedsets_raw <- httr::content(api$list_bedsets_v1_bedset_list_get(query = "hg19")) + bedbase <- BEDbase(quietly = TRUE) + bedsets_raw <- httr::content(bedbase$list_bedsets_v1_bedset_list_get(query = "hg19")) bedsets_names_bed_ids_list <- lapply(bedsets_raw$results, `[`, c("id", "bed_ids")) bedsets_names_bed_ids <- dplyr::bind_rows(bedsets_names_bed_ids_list) |> tidyr::unnest(cols = c(bed_ids)) - bedsets <- bb_list_bedsets(api, query = "hg19") + bedsets <- bb_list_bedsets(bedbase, query = "hg19") expect_equal(bedsets_names_bed_ids$bed_ids, bedsets$bed_ids) }) test_that("bb_list_bedsets returns number of bed ids", { - api <- BEDbase(quietly = TRUE) - bedsets_raw <- httr::content(api$list_bedsets_v1_bedset_list_get(limit = 1)) + bedbase <- BEDbase(quietly = TRUE) + bedsets_raw <- httr::content(bedbase$list_bedsets_v1_bedset_list_get(limit = 1)) bedsets_names_bed_ids_list <- lapply(bedsets_raw$results, `[`, c("id", "bed_ids")) bedsets_names_bed_ids <- dplyr::bind_rows(bedsets_names_bed_ids_list) |> tidyr::unnest(cols = c(bed_ids)) - bedsets <- bb_list_bedsets(api, limit = 1) + bedsets <- bb_list_bedsets(bedbase, limit = 1) expect_equal(bedsets$bed_ids, bedsets_names_bed_ids$bed_ids) }) test_that("bb_beds_in_bedset returns expected bed_ids", { - api <- BEDbase(quietly = TRUE) - ex_bedset <- httr::content(api$get_example_bedset_record_v1_bedset_example_get()) - ex_bedset_raw <- httr::content(api$get_bedfiles_in_bedset_v1_bedset__bedset_id__bedfiles_get(ex_bedset$id)) + bedbase <- BEDbase(quietly = TRUE) + ex_bedset <- httr::content(bedbase$get_example_bedset_record_v1_bedset_example_get()) + ex_bedset_raw <- httr::content(bedbase$get_bedfiles_in_bedset_v1_bedset__bedset_id__bedfiles_get(ex_bedset$id)) ex_bed_ids_list <- lapply(ex_bedset_raw$results, `[`, c("id")) ex_bed_ids <- unlist(ex_bed_ids_list, use.names = FALSE) - bed_ids <- bb_beds_in_bedset(api, ex_bedset$id)$id + bed_ids <- bb_beds_in_bedset(bedbase, ex_bedset$id)$id expect_equal(ex_bed_ids, bed_ids) }) test_that("bb_bed_text_search returns results scored against the query", { - api <- BEDbase(quietly = TRUE) - beds <- bb_bed_text_search(api, "hg38") - ex_beds <- httr::content(api$text_to_bed_search_v1_bed_search_text_post( + bedbase <- BEDbase(quietly = TRUE) + beds <- bb_bed_text_search(bedbase, "hg38") + ex_beds <- httr::content(bedbase$text_to_bed_search_v1_bed_search_text_post( query = "hg38", limit = 10, offset = 0 @@ -93,34 +93,34 @@ test_that("bb_bed_text_search returns results scored against the query", { }) test_that("bb_to_granges returns a GRanges object given a 3+0 bed file", { - api <- BEDbase(quietly = TRUE) + bedbase <- BEDbase(quietly = TRUE) id <- "95a593b8337074a334b425aba5e77d4c" - md <- bb_metadata(api, id, TRUE) + md <- bb_metadata(bedbase, id, TRUE) expect_equal("bed3+0", md$bed_type) - gro <- bb_to_granges(api, id) + gro <- bb_to_granges(bedbase, id) expect_true(methods::is((gro)[1], "GRanges")) }) test_that("bb_to_granges returns a GRanges object given a bigbed file", { - api <- BEDbase(quietly = TRUE) + bedbase <- BEDbase(quietly = TRUE) id <- "ffc1e5ac45d923135500bdd825177356" if (.Platform$OS.type != "windows") { - gro <- bb_to_granges(api, id, "bigbed") + gro <- bb_to_granges(bedbase, id, "bigbed") expect_true(methods::is((gro)[1], "GRanges")) } else { expect_warning( rlang::warn("This feature does not work on Windows."), - bb_to_granges(api, id, "bigbed") + bb_to_granges(bedbase, id, "bigbed") ) } }) test_that("bb_to_granges returns a GRanges object given narrowpeak (6+4) file", { - api <- BEDbase(quietly = TRUE) + bedbase <- BEDbase(quietly = TRUE) id <- "bbad85f21962bb8d972444f7f9a3a932" - md <- bb_metadata(api, id, TRUE) + md <- bb_metadata(bedbase, id, TRUE) expect_equal("bed6+4", md$bed_type) - gro <- bb_to_granges(api, id) + gro <- bb_to_granges(bedbase, id) expect_true(methods::is((gro)[1], "GRanges")) df <- as.data.frame(gro) expect_contains( @@ -133,11 +133,11 @@ test_that("bb_to_granges returns a GRanges object given narrowpeak (6+4) file", }) test_that("bb_to_granges returns GRanges object given bed3+9 with genome", { - api <- BEDbase(quietly = TRUE) + bedbase <- BEDbase(quietly = TRUE) id <- "608827efc82fcaa4b0bfc65f590ffef8" - md <- bb_metadata(api, id, TRUE) + md <- bb_metadata(bedbase, id, TRUE) expect_equal("bed3+9", md$bed_type) - gro <- bb_to_granges(api, id) + gro <- bb_to_granges(bedbase, id) df <- as.data.frame(gro) expect_contains( c( @@ -149,11 +149,11 @@ test_that("bb_to_granges returns GRanges object given bed3+9 with genome", { }) test_that("bb_to_granges allows passing extra_cols", { - api <- BEDbase(quietly = TRUE) + bedbase <- BEDbase(quietly = TRUE) id <- "608827efc82fcaa4b0bfc65f590ffef8" - md <- bb_metadata(api, id, TRUE) + md <- bb_metadata(bedbase, id, TRUE) expect_equal("bed3+9", md$bed_type) - gro <- bb_to_granges(api, id, + gro <- bb_to_granges(bedbase, id, extra_cols = c( "t1" = "character", "t2" = "character", "t3" = "character", "t4" = "character", "t5" = "character", @@ -168,23 +168,23 @@ test_that("bb_to_granges allows passing extra_cols", { }) test_that("bb_to_grangeslist creates a GRangesList", { - api <- BEDbase(quietly = TRUE) - grl <- bb_to_grangeslist(api, "lola_hg38_ucsc_features") + bedbase <- BEDbase(quietly = TRUE) + grl <- bb_to_grangeslist(bedbase, "lola_hg38_ucsc_features") expect_true(methods::is((grl)[1], "CompressedGRangesList")) expect_equal(11, length(grl)) }) test_that("bb_save saves bed files to a path", { - api <- BEDbase(quietly = TRUE) + bedbase <- BEDbase(quietly = TRUE) path <- tempdir() if (!dir.exists(path)) { dir.create(path) } - bed <- bb_example(api, "bed") - bb_save(api, bed$id, path, quietly = TRUE) + bed <- bb_example(bedbase, "bed") + bb_save(bedbase, bed$id, path, quietly = TRUE) expect_true(file.exists(file.path(path, paste0(bed$id, ".bed.gz")))) - bedset <- bb_metadata(api, "lola_hg38_ucsc_features") - bb_save(api, bedset$id, path, quietly = TRUE) + bedset <- bb_metadata(bedbase, "lola_hg38_ucsc_features") + bb_save(bedbase, bedset$id, path, quietly = TRUE) for (id in bedset$bed_ids) { expect_true(file.exists(file.path(path, paste0(id, ".bed.gz")))) } diff --git a/tests/testthat/test-cache.R b/tests/testthat/test-cache.R index 8bfcae8..d5fd364 100644 --- a/tests/testthat/test-cache.R +++ b/tests/testthat/test-cache.R @@ -1,23 +1,23 @@ test_that("default cache location is used", { path <- tools::R_user_dir("bedbaser", which = "cache") - api <- BEDbase(quietly = TRUE) + bedbase <- BEDbase(quietly = TRUE) id <- "bbad85f21962bb8d972444f7f9a3a932" - gro <- bb_to_granges(api, id, "bed") + gro <- bb_to_granges(bedbase, id, "bed") bfc <- BiocFileCache::BiocFileCache(path) expect_equal(BiocFileCache::bfccache(bfc), path) - md <- bb_metadata(api, id, TRUE) - file_path <- .get_file(md, getCache(api), "bed", "http") + md <- bb_metadata(bedbase, id, TRUE) + file_path <- .get_file(md, getCache(bedbase), "bed", "http") expect_true(paste0(file_path, ".gz") %in% BiocFileCache::bfcinfo(bfc)$rpath) }) test_that("path is used if set when calling constructor", { path <- tempdir() - api <- BEDbase(path, TRUE) - bfc <- getCache(api) + bedbase <- BEDbase(path, TRUE) + bfc <- getCache(bedbase) id <- "bbad85f21962bb8d972444f7f9a3a932" - gro <- bb_to_granges(api, id, "bed") + gro <- bb_to_granges(bedbase, id, "bed") expect_equal(BiocFileCache::bfccache(bfc), path) - md <- bb_metadata(api, id, TRUE) - file_path <- .get_file(md, getCache(api), "bed", "http") + md <- bb_metadata(bedbase, id, TRUE) + file_path <- .get_file(md, getCache(bedbase), "bed", "http") expect_true(paste0(file_path, ".gz") %in% BiocFileCache::bfcinfo(bfc)$rpath) }) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 10c961c..1b6b626 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,28 +1,28 @@ test_that(".format_metadata_files returns a tibble with a url column", { - api <- BEDbase(quietly = TRUE) - ex_bed <- bb_example(api, "bed") - ex_md <- bb_metadata(api, ex_bed$id, TRUE) + bedbase <- BEDbase(quietly = TRUE) + ex_bed <- bb_example(bedbase, "bed") + ex_md <- bb_metadata(bedbase, ex_bed$id, TRUE) mdf <- .format_metadata_files(ex_md$files) expect_true(methods::is((mdf)[1], "tbl_df")) expect_true("url" %in% names(mdf)) }) test_that(".get_file returns a valid file path", { - api <- BEDbase(quietly = TRUE) - ex_bed <- bb_example(api, "bed") - md <- bb_metadata(api, ex_bed$id, TRUE) + bedbase <- BEDbase(quietly = TRUE) + ex_bed <- bb_example(bedbase, "bed") + md <- bb_metadata(bedbase, ex_bed$id, TRUE) temp_path <- tempdir() file_path <- .get_file(md, temp_path, "bed", "http") expect_true(file.exists(file_path)) - file_path <- .get_file(md, getCache(api), "bed", "http") + file_path <- .get_file(md, getCache(bedbase), "bed", "http") expect_true(file.exists(file_path)) }) test_that(".get_extra_cols returns a named vector", { - api <- BEDbase(quietly = TRUE) + bedbase <- BEDbase(quietly = TRUE) id <- "608827efc82fcaa4b0bfc65f590ffef8" - md <- bb_metadata(api, id, TRUE) - file_path <- .get_file(md, getCache(api), "bed", "http") + md <- bb_metadata(bedbase, id, TRUE) + file_path <- .get_file(md, getCache(bedbase), "bed", "http") extra_cols <- .get_extra_cols(file_path, 3, 9) expect_equal(9, length(extra_cols)) }) diff --git a/vignettes/bedbaser.Rmd b/vignettes/bedbaser.Rmd index dd9ed03..d533032 100644 --- a/vignettes/bedbaser.Rmd +++ b/vignettes/bedbaser.Rmd @@ -41,7 +41,7 @@ Load the package and create a BEDbase instance. ```{r bedbase} library(bedbaser) -api <- BEDbase() +bedbase <- BEDbase() ``` ## (Optional) Set the cache @@ -54,7 +54,7 @@ bedbaser will choose the default location. bedbaser can use the same cache as ```{r set_cache, eval = FALSE} library(bedbaser) -api <- BEDbase(cache_path = "/path/to/cache") +bedbase <- BEDbase(cache_path = "/path/to/cache") ``` # Convenience Functions @@ -70,9 +70,9 @@ BEDbase. Both functions display the id and names of BED files and BEDsets. An id can be used to access a specific resource. ```{r bb_list_beds} -bb_list_beds(api) +bb_list_beds(bedbase) -bb_list_bedsets(api) +bb_list_bedsets(bedbase) ``` ## Examine metadata @@ -80,8 +80,8 @@ bb_list_bedsets(api) Use `bb_metadata()` to learn more about a BED or BEDset associated with an id. ```{r bb_metadata} -ex_bed <- bb_example(api, "bed") -md <- bb_metadata(api, ex_bed$id) +ex_bed <- bb_example(bedbase, "bed") +md <- bb_metadata(bedbase, ex_bed$id) head(md) ``` @@ -90,7 +90,7 @@ head(md) Use `bb_beds_in_bedset()` to display the id of BEDs in a BEDset. ```{r bb_beds_in_bedset} -bb_beds_in_bedset(api, "excluderanges") +bb_beds_in_bedset(bedbase, "excluderanges") ``` ## Search for a BED file by keyword @@ -99,7 +99,7 @@ Search for BED files by keywords. `bb_bed_text_search()` returns all BED files scored against a keyword query. ```{r bb_search} -bb_bed_text_search(api, "cancer", limit = 10) +bb_bed_text_search(bedbase, "cancer", limit = 10) ``` ## Import a BED into a GRanges object @@ -108,10 +108,10 @@ Create a GRanges object with a BED id with `bb_to_granges`, which downloads and imports a BED file using `r Biocpkg("rtracklayer")`. ```{r bb_to_granges} -ex_bed <- bb_example(api, "bed") +ex_bed <- bb_example(bedbase, "bed") head(ex_bed) # Allow bedbaser to assign column names and types -bb_to_granges(api, ex_bed$id, quietly = FALSE) +bb_to_granges(bedbase, ex_bed$id, quietly = FALSE) ``` For BEDX+Y formats, a named list with column types may be passed through @@ -120,7 +120,7 @@ guesses the column types and assigns column names. ```{r bb_to_granges_manual, eval=FALSE} # Manually assign column name and type using `extra_cols` -bb_to_granges(api, ex_bed$id, extra_cols = c("column_name" = "character")) +bb_to_granges(bedbase, ex_bed$id, extra_cols = c("column_name" = "character")) ``` `bb_to_granges` automatically assigns the column names and types for broad peak @@ -128,16 +128,16 @@ and narrow peak files. ```{r bb_to_granges_narrowpeak, message=FALSE} bed_id <- "bbad85f21962bb8d972444f7f9a3a932" -md <- bb_metadata(api, bed_id) +md <- bb_metadata(bedbase, bed_id) head(md) -bb_to_granges(api, bed_id) +bb_to_granges(bedbase, bed_id) ``` `bb_to_granges` can also import big BED files. ```{r bb_to_granges_big_bed} bed_id <- "ffc1e5ac45d923135500bdd825177356" -bb_to_granges(api, bed_id, "bigbed", quietly = FALSE) +bb_to_granges(bedbase, bed_id, "bigbed", quietly = FALSE) ``` ## Import a BEDset into a GRangesList @@ -146,7 +146,7 @@ Create a GRangesList given a BEDset id with `bb_to_grangeslist`. ```{r bb_to_grangeslist, message=FALSE} bedset_id <- "lola_hg38_ucsc_features" -bb_to_grangeslist(api, bedset_id) +bb_to_grangeslist(bedbase, bedset_id) ``` # Accessing BEDbase API endpoints @@ -155,7 +155,7 @@ Because bedbaser uses the `r Biocpkg("AnVIL")` Service class, it's possible to access any endpoint of the [BEDbase API](https://api.bedbase.org/v1/docs). ```{r operations} -show(api) +show(bedbase) ``` For example, to access a BED file's stats, access the endpoint with `$` and use @@ -164,9 +164,9 @@ endpoint. ```{r service_class_example} library(httr) -show(api$get_bed_stats_v1_bed__bed_id__metadata_stats_get) +show(bedbase$get_bed_stats_v1_bed__bed_id__metadata_stats_get) id <- "bbad85f21962bb8d972444f7f9a3a932" -rsp <- api$get_bed_stats_v1_bed__bed_id__metadata_stats_get(id) +rsp <- bedbase$get_bed_stats_v1_bed__bed_id__metadata_stats_get(id) content(rsp) ``` @@ -195,8 +195,8 @@ object from the BEDbase `id`. ```{r convertCoordinates_createGRangesObject, message=FALSE} id <- "7816f807ffe1022f438e1f5b094acf1a" -api <- BEDbase() -gro <- bb_to_granges(api, id) +bedbase <- BEDbase() +gro <- bb_to_granges(bedbase, id) gro ```