Skip to content

Commit

Permalink
refactor: remove fs dependency - file_exists with file.exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jamespeapen committed Aug 29, 2024
1 parent 5b8e4d4 commit 89e7067
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 12 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ LinkingTo:
Imports:
Rcpp,
Matrix,
fs,
data.table,
parallelly
Suggests:
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ export(region_map)
export(set_log_level)
export(set_threads)
importFrom(Rcpp,sourceCpp)
importFrom(fs,file_exists)
importFrom(parallelly,availableCores)
useDynLib(iscream, .registration = TRUE)
1 change: 0 additions & 1 deletion R/query_all.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#' ("dgCMatrix"). Set this `TRUE` only for scWGBS data
#' @param nthreads Set number of threads to use overriding the
#' `"iscream.threads"` option. See `?set_threads` for more information.
#' @importFrom fs file_exists
#' @return A named list of
#' - M and coverage matrices
#' - a character vector of chromosomes and numeric vector of corresponding CpG
Expand Down
1 change: 0 additions & 1 deletion R/region_map.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#' `mval =` FALSE and aggregated M values if `mval =` TRUE
#' - `"average"` averages the values in the region with average beta values if
#' `mval =` FALSE and average M values if `mval =` TRUE
#' @importFrom fs file_exists
#' @return A data.frame
#'
#' @export
Expand Down
4 changes: 1 addition & 3 deletions R/verify_files.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
#'
#' @param files_vec A vector of file paths
#' @param error_file_prefix Error message prefix for 'Bedfile' vs 'Tabix file'
#' @importFrom fs file_exists
#' @return TRUE if all input bedfiles have an associated tabix index file.
#' FALSE if not
#'
#' @keywords internal
check_files_exist <- function(files_vec, error_file_prefix = "Bedfile") {
valid_files <- file_exists(files_vec)
valid_files <- file.exists(files_vec)
missing_files <- files_vec[!valid_files]
if (length(missing_files != 0)) {
stop(paste0(error_file_prefix, ": ", missing_files, " could not be found\n"))
Expand All @@ -19,7 +18,6 @@ check_files_exist <- function(files_vec, error_file_prefix = "Bedfile") {
#'
#' @param bedfiles A vector of bedfile paths
#' @param verify_tabix Whether to verify the presence of tabix files
#' @importFrom fs file_exists
#' @return TRUE if all input bedfiles have an associated tabix index file.
#' FALSE if not
#'
Expand Down
9 changes: 4 additions & 5 deletions tests/testthat/test-region_map.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
library(fs)
extdata <- system.file("extdata", package = "iscream")
bedfiles <- list.files(extdata, pattern = "[a|b|c|d].bed.gz$", full.names = TRUE)
regions <- c("chr1:1-6", "chr1:7-10", "chr1:11-14")

m_agg <- read.csv(path(extdata, "region_map_m_agg.test"))
m_ave <- read.csv(path(extdata, "region_map_m_ave.test"))
beta_ave <- read.csv(path(extdata, "region_map_beta_ave.test"))
beta_agg <- read.csv(path(extdata, "region_map_beta_agg.test"))
m_agg <- read.csv(file.path(extdata, "region_map_m_agg.test"))
m_ave <- read.csv(file.path(extdata, "region_map_m_ave.test"))
beta_ave <- read.csv(file.path(extdata, "region_map_beta_ave.test"))
beta_agg <- read.csv(file.path(extdata, "region_map_beta_agg.test"))

test_that("region_map 1 thread", {
expect_equal(
Expand Down

0 comments on commit 89e7067

Please sign in to comment.