methylKit icon indicating copy to clipboard operation
methylKit copied to clipboard

wrong output file path is checked for existence

Open alexg9010 opened this issue 6 months ago • 0 comments

The output file is currently assumed in the same folder as the input tabix file. This is violated if dbdir argument is given. The file is created at the correct path though.

https://github.com/al2na/methylKit/blob/ecf85842bdd5252161fa5bbe6aa0d285c87e1f77/R/methylDBFunctions.R#L2273-L2294

Simple test:

library(methylKit)
data("methylKit")

dbdir <- "my_storage_path"
dbdir_unite <- file.path(dbdir,"unite")
dbdir_tile <- file.path(dbdir,"tile")
dbdir_diffmeth <- file.path(dbdir,"diffmeth")


## init methylrawlistdb in old dbdir
mlist_db <- methylRawList.obj |> makeMethylDB(dbdir = dbdir)
mlist_db |> getDBPath() |> basename() %in% dir(dbdir) |> all()


get_checked_file <- function(log) {
  matches <- log |> grep(pattern = "checking wether tabix file already exists:" ) + 1 
  return(log[matches])
}

## create new methylbase in new dbdir
unite_log <- {mlist_db_unite <- mlist_db |> unite(dbdir = dbdir_unite)} |> capture.output(type = "message")
identical(
  unite_log |> get_checked_file() |> normalizePath(),
  mlist_db_unite |> getDBPath()
  )

## prints the wrong for diffmeth
diffmeth_log <- {mlist_db_diffmeth <- mlist_db_unite |> calculateDiffMeth(dbdir = dbdir_diffmeth)} |> capture.output(type = "message")
identical(
  diffmeth_log |> get_checked_file() |> normalizePath(),
  mlist_db_diffmeth |> getDBPath()
)


## prints the wrong for tiling
tile_log <- {mlist_db_tiled <- mlist_db |> tileMethylCounts(dbdir = dbdir_tile)} |> capture.output(type = "message") 
identical(
  tile_log |> get_checked_file() |> normalizePath(),
  mlist_db_tiled |> getDBPath()
)


unlink(x = c(dbdir), recursive = TRUE)

alexg9010 avatar Apr 16 '25 09:04 alexg9010