Skip to content

Commit

Permalink
Define regions_bed default in build_browser_hub
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirsouza committed Apr 22, 2024
1 parent 4a8e8af commit c0d152c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
20 changes: 16 additions & 4 deletions R/build_browser_hub.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
#' `regions_bed` and `these_sample_ids`/`these_samples_metadata`, respectively.
#' @param regions_bed A BED-format table with the regions you want to retrieve SSMs
#' from. The columns 1, 2 and 3 must be chromosome names, start positions and
#' end positions, respectively. The default is the `GAMBLR.data::grch37_ashm_regions`
#' object which contains public-available SSMs from aSHM regions, but any other
#' regions can be provided.
#' end positions, respectively. If not provided, the function defaults to aSHM
#' regions, *i.e.* one of `GAMBLR.data::grch37_ashm_regions` or `GAMBLR.data::hg38_ashm_regions`,
#' which is chosen automatically depending on the provided `projection`.
#' @param these_sample_ids A vector of sample IDs that you want results for.
#' @param these_samples_metadata A metadata table (with sample IDs in a column) to
#' subset the samples of interest.
Expand Down Expand Up @@ -99,7 +99,7 @@
#' }
#'
build_browser_hub = function(maf_data,
regions_bed = GAMBLR.data::grch37_ashm_regions,
regions_bed,
these_sample_ids = NULL,
these_samples_metadata = NULL,
these_seq_types = c("genome", "capture"),
Expand Down Expand Up @@ -169,6 +169,18 @@ build_browser_hub = function(maf_data,
track_dir = file.path(hub_dir_full_path, projection)
dir.create(track_dir, showWarnings = FALSE)

# define regions_bed
if( missing(regions_bed) | is.null(regions_bed) ){
if(is.null(regions_bed)){
warning("`regions_bed = NULL` is treated as it was not provided. The default aSHM regions of the provided `projection` are used.")
}
if(projection == "grch37"){
regions_bed = GAMBLR.data::grch37_ashm_regions
}else{
regions_bed = GAMBLR.data::hg38_ashm_regions
}
}

# save regions_bed to a bb file
regions_bed = dplyr::select(regions_bed, 1,2,3) %>%
arrange( .[[1]], .[[2]] )
Expand Down
13 changes: 9 additions & 4 deletions man/build_browser_hub.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0d152c

Please sign in to comment.