Skip to contents

Bed files can contain peak or blacklist annotations. These utilities help read thos annotations

Usage

read_bed(
  path,
  additional_columns = character(0),
  backup_url = NULL,
  timeout = 300
)

read_encode_blacklist(
  dir,
  genome = c("hg38", "mm10", "hg19", "dm6", "dm3", "ce11", "ce10"),
  timeout = 300
)

Arguments

path

Path to file (or desired save location if backup_url is used)

additional_columns

Names for additional columns in the bed file

backup_url

If path does not exist, provides a URL to download the gtf from

timeout

Maximum time in seconds to wait for download from backup_url

dir

Output directory to cache the downloaded gtf file

genome

genome name

Value

Data frame with coordinates using the 0-based convention.

Details

read_bed

Read a bed file from disk or a url.

read_encode_blacklist

Downloads the Boyle Lab blacklist, as described in https://doi.org/10.1038/s41598-019-45839-z

Examples

## Dummy bed file creation
data.frame(
 chrom = rep("chr1", 6),
 start = seq(20, 121, 20),
 end = seq(39, 140, 20)
) %>% write.table("./references/example.bed", row.names = FALSE, col.names = FALSE, sep = "\t")
#> Warning: cannot open file './references/example.bed': No such file or directory
#> Error in file(file, ifelse(append, "a", "w")): cannot open the connection


#######################################################################
## read_bed() example
#######################################################################
read_bed("./references/example.bed")
#> Error: In function read_bed: "path" is not a valid file path (file not found)
#>      
#>   1. └─pkgdown::build_reference("r", lazy = FALSE)
#>   2.   ├─pkgdown:::unwrap_purrr_error(...)
#>   3.   │ └─base::withCallingHandlers(...)
#>   4.   └─purrr::map(...)
#>   5.     └─purrr:::map_("list", .x, .f, ..., .progress = .progress)
#>   6.       ├─purrr:::with_indexed_errors(...)
#>   7.       │ └─base::withCallingHandlers(...)
#>   8.       ├─purrr:::call_with_cleanup(...)
#>   9.       └─pkgdown (local) .f(.x[[i]], ...)
#>  10.         ├─base::withCallingHandlers(...)
#>  11.         └─pkgdown:::data_reference_topic(...)
#>  12.           └─pkgdown:::run_examples(...)
#>  13.             └─pkgdown:::highlight_examples(code, topic, env = env)
#>  14.               └─downlit::evaluate_and_highlight(...)
#>  15.                 └─evaluate::evaluate(code, child_env(env), new_device = TRUE, output_handler = output_handler)
#>  16.                   └─evaluate:::evaluate_call(...)
#>  17.                     ├─evaluate (local) timing_fn(...)
#>  18.                     ├─evaluate (local) handle(...)
#>  19.                     │ └─base::try(f, silent = TRUE)
#>  20.                     │   └─base::tryCatch(...)
#>  21.                     │     └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#>  22.                     │       └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#>  23.                     │         └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#>  24.                     ├─base::withCallingHandlers(...)
#>  25.                     ├─base::withVisible(...)
#>  26.                     └─evaluate:::eval_with_user_handlers(expr, envir, enclos, user_handlers)
#>  27.                       └─base::eval(expr, envir, enclos)
#>  28.                         └─base::eval(expr, envir, enclos)
#>  29.                           └─BPCells::read_bed("./references/example.bed")
#>  30.                             └─BPCells:::assert_is_file(...) at r/R/genomeAnnotations.R:231:3


#######################################################################
## read_encode_blacklist() example
#######################################################################
read_encode_blacklist("./reference")
#> # A tibble: 636 × 4
#>    chr       start       end reason            
#>    <chr>     <dbl>     <dbl> <chr>             
#>  1 chr10         0     45700 Low Mappability   
#>  2 chr10  38481300  38596500 High Signal Region
#>  3 chr10  38782600  38967900 High Signal Region
#>  4 chr10  39901300  41712900 High Signal Region
#>  5 chr10  41838900  42107300 High Signal Region
#>  6 chr10  42279400  42322500 High Signal Region
#>  7 chr10 126946300 126953400 Low Mappability   
#>  8 chr10 133625800 133797400 High Signal Region
#>  9 chr11         0    194500 Low Mappability   
#> 10 chr11    518900    520700 Low Mappability   
#> # ℹ 626 more rows