diff --git a/R/query_all.R b/R/query_all.R index bb391cd..d809b2f 100644 --- a/R/query_all.R +++ b/R/query_all.R @@ -10,6 +10,16 @@ #' @return A data.frame #' #' @export +#' @examples +#' bedfiles <- system.file("extdata", package = "iscream") |> +#' list.files(pattern = "[a|b|c|d].bed.gz$", full.names = TRUE) +#' # examine the bedfiles +#' colnames <- c("chr", "start", "end", "beta", "coverage") +#' lapply(bedfiles, function(i) knitr::kable(data.table::fread(i, col.names = colnames))) +#' +#' # make a vector of regions +#' regions <- c("chr1:1-6", "chr1:7-10", "chr1:11-14") +#' query_all(bedfiles, regions) query_all <- function(bedfiles, regions, nthreads = NULL) { verify_files_or_stop(bedfiles, verify_tabix = TRUE) diff --git a/R/region_map.R b/R/region_map.R index a17fd16..91c1eda 100644 --- a/R/region_map.R +++ b/R/region_map.R @@ -1,7 +1,7 @@ #' Run a defined function over genomic regions #' #' Run a function on the CpGs in bedfiles across genomic regions. Currently -#' supported functions are aggregate, average, and ... +#' supported functions are aggregate and average. #' @param bedfiles A vector of bedfile paths #' @param regions A vector of genomic regions strings #' @param fun Function to apply over the region. See details. @@ -20,6 +20,19 @@ #' @return A data.frame #' #' @export +#' +#' @examples +#' bedfiles <- system.file("extdata", package = "iscream") |> +#' list.files(pattern = "[a|b|c|d].bed.gz$", full.names = TRUE) +#' # examine the bedfiles +#' colnames <- c("chr", "start", "end", "beta", "coverage") +#' lapply(bedfiles, function(i) knitr::kable(data.table::fread(i, col.names = colnames))) +#' +#' # make a vector of regions +#' regions <- c("chr1:1-6", "chr1:7-10", "chr1:11-14") +#' region_map(bedfiles, regions) +#' region_map(bedfiles, regions, mval = FALSE) +#' region_map(bedfiles, regions, fun = "average") region_map <- function(bedfiles, regions, fun = "aggregate", mval = TRUE, nthreads = NULL) { supported_funcs <- c("aggregate", "average") diff --git a/man/query_all.Rd b/man/query_all.Rd index 54345cb..a73069b 100644 --- a/man/query_all.Rd +++ b/man/query_all.Rd @@ -21,3 +21,14 @@ A data.frame Queries the provided regions and produces M and Coverage matrices that are wrapped in a BSSeq object } +\examples{ +bedfiles <- system.file("extdata", package = "iscream") |> + list.files(pattern = "[a|b|c|d].bed.gz$", full.names = TRUE) +# examine the bedfiles +colnames <- c("chr", "start", "end", "beta", "coverage") +lapply(bedfiles, function(i) knitr::kable(data.table::fread(i, col.names = colnames))) + +# make a vector of regions +regions <- c("chr1:1-6", "chr1:7-10", "chr1:11-14") +query_all(bedfiles, regions) +} diff --git a/man/region_map.Rd b/man/region_map.Rd index 3cddc56..f2a035f 100644 --- a/man/region_map.Rd +++ b/man/region_map.Rd @@ -25,7 +25,7 @@ A data.frame } \description{ Run a function on the CpGs in bedfiles across genomic regions. Currently -supported functions are aggregate, average, and ... +supported functions are aggregate and average. } \details{ Available functions: @@ -36,3 +36,16 @@ Available functions: \verb{mval =} FALSE and average M values if \verb{mval =} TRUE } } +\examples{ +bedfiles <- system.file("extdata", package = "iscream") |> + list.files(pattern = "[a|b|c|d].bed.gz$", full.names = TRUE) +# examine the bedfiles +colnames <- c("chr", "start", "end", "beta", "coverage") +lapply(bedfiles, function(i) knitr::kable(data.table::fread(i, col.names = colnames))) + +# make a vector of regions +regions <- c("chr1:1-6", "chr1:7-10", "chr1:11-14") +region_map(bedfiles, regions) +region_map(bedfiles, regions, mval = FALSE) +region_map(bedfiles, regions, fun = "average") +}