Skip to content

Commit

Permalink
Ensure that all system.file calls must work
Browse files Browse the repository at this point in the history
  • Loading branch information
Shians committed Oct 10, 2024
1 parent 5a411a6 commit d06902a
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion R/NanoMethResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' @return a NanoMethResult object to be used with plotting functions
#'
#' @examples
#' methy <- system.file(package = "NanoMethViz", "methy_subset.tsv.bgz")
#' methy <- system.file(package = "NanoMethViz", "methy_subset.tsv.bgz", mustWork = FALSE)
#' sample <- c(
#' "B6Cast_Prom_1_bl6",
#' "B6Cast_Prom_1_cast",
Expand Down
2 changes: 1 addition & 1 deletion R/bsseq_to_edger.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @export
#'
#' @examples
#' methy <- system.file("methy_subset.tsv.bgz", package = "NanoMethViz")
#' methy <- system.file("methy_subset.tsv.bgz", package = "NanoMethViz", mustWork = FALSE)
#' bsseq <- methy_to_bsseq(methy)
#' edger_mat <- bsseq_to_edger(bsseq)
bsseq_to_edger <- function(bsseq, regions = NULL) {
Expand Down
2 changes: 1 addition & 1 deletion R/create_tabix_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @export
#' @examples
#' methy_calls <- system.file(package = "NanoMethViz",
#' c("sample1_nanopolish.tsv.gz", "sample2_nanopolish.tsv.gz"))
#' c("sample1_nanopolish.tsv.gz", "sample2_nanopolish.tsv.gz"), mustWork = FALSE)
#' temp_file <- paste0(tempfile(), ".tsv.bgz")
#'
#' create_tabix_file(methy_calls, temp_file)
Expand Down
8 changes: 4 additions & 4 deletions R/get_cgi.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ get_cgi <- function(genome) {

rds_path <- switch(
genome,
hg19 = system.file("cgi_hg19.rds", package = "NanoMethViz"),
hg38 = system.file("cgi_hg38.rds", package = "NanoMethViz"),
mm10 = system.file("cgi_mm10.rds", package = "NanoMethViz"),
grcm39 = system.file("cgi_GRCm39.rds", package = "NanoMethViz")
hg19 = system.file("cgi_hg19.rds", package = "NanoMethViz", mustWork = FALSE),
hg38 = system.file("cgi_hg38.rds", package = "NanoMethViz", mustWork = FALSE),
mm10 = system.file("cgi_mm10.rds", package = "NanoMethViz", mustWork = FALSE),
grcm39 = system.file("cgi_GRCm39.rds", package = "NanoMethViz", mustWork = FALSE)
)

readRDS(rds_path)
Expand Down
3 changes: 2 additions & 1 deletion R/modbam_to_tabix.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
#' mbr <- ModBamResult(
#' methy = ModBamFiles(
#' samples = "sample1",
#' paths = system.file("peg3.bam", package = "NanoMethViz")
#' paths = system.file("peg3.bam", package = "NanoMethViz",
#' mustWork = FALSE)
#' ),
#' samples = data.frame(
#' sample = "sample1",
Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @examples
#' nmr <- load_example_nanomethresult()
load_example_nanomethresult <- function() {
methy <- system.file(package = "NanoMethViz", "methy_subset.tsv.bgz")
methy <- system.file(package = "NanoMethViz", "methy_subset.tsv.bgz", mustWork = FALSE)

sample <- c(
"B6Cast_Prom_1_bl6",
Expand Down Expand Up @@ -51,7 +51,7 @@ load_example_nanomethresult <- function() {
load_example_modbamresult <- function() {
ModBamResult(
methy = ModBamFiles(
paths = system.file(package = "NanoMethViz", "peg3.bam"),
paths = system.file(package = "NanoMethViz", "peg3.bam", mustWork = FALSE),
samples = "sample1"
),
samples = tibble::tibble(
Expand Down
2 changes: 1 addition & 1 deletion man/NanoMethResult-class.Rd

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

2 changes: 1 addition & 1 deletion man/bsseq_to_edger.Rd

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

2 changes: 1 addition & 1 deletion man/create_tabix_file.Rd

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

3 changes: 2 additions & 1 deletion man/modbam_to_tabix.Rd

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

4 changes: 2 additions & 2 deletions tests/testthat/test-ModBamResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ test_that("ModBamResults getters and setters work", {

expect_error(
ModBamFiles(
paths = system.file(package = "NanoMethViz", "missing.bam"),
paths = system.file(package = "NanoMethViz", "missing.bam", mustWork = FALSE),
samples = "sample1"
),
regex = "Path .+ does not exist"
)

expect_error(
ModBamFiles(
paths = system.file(package = "NanoMethViz", "no_index.bam"),
paths = system.file(package = "NanoMethViz", "no_index.bam", mustWork = FALSE),
samples = "sample1"
),
regex = ".+ does not have bam index"
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-modbam_to_tabix.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_that("Modbam to tabix conversion works", {
mbr <- ModBamResult(
methy = ModBamFiles(
samples = "sample1",
paths = system.file("peg3.bam", package = "NanoMethViz")
paths = system.file("peg3.bam", package = "NanoMethViz", mustWork = FALSE)
),
samples = data.frame(
sample = "sample1",
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-plot_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test_that("Plotting gene works", {

mbr_lower <- load_example_modbamresult()
methy(mbr_lower) <- ModBamFiles(
paths = system.file(package = "NanoMethViz", "peg3_lower_case.bam"),
paths = system.file(package = "NanoMethViz", "peg3_lower_case.bam", mustWork = FALSE),
samples = "sample1"
)

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-query_methy.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ test_that("Querying methylation works", {
expect_true(length(methy_data_list) == 4)

# test to make sure that reading from text connection works for methylation data
methy_data_with_inf <- readLines(system.file("methy_data_with_inf.tsv", package = "NanoMethViz"))
methy_data_with_inf <- readLines(system.file("methy_data_with_inf.tsv", package = "NanoMethViz", mustWork = FALSE))
methy_data <- expect_no_warning(read_methy_lines(methy_data_with_inf))
expect_equal(nrow(methy_data), length(methy_data_with_inf))

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-tabix_utils.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test_that("Importing nanopolish works", {
# setup
methy_calls <- system.file(package = "NanoMethViz",
c("sample1_nanopolish.tsv.gz", "sample2_nanopolish.tsv.gz"))
c("sample1_nanopolish.tsv.gz", "sample2_nanopolish.tsv.gz"), mustWork = FALSE)
temp_file <- paste0(tempfile(), ".tsv.bgz")
withr::defer(file.remove(temp_file))

Expand All @@ -13,7 +13,7 @@ test_that("Importing nanopolish works", {
test_that("Importing megalodon works", {
# setup
methy_calls <- system.file(package = "NanoMethViz",
"megalodon_calls.txt.gz")
"megalodon_calls.txt.gz", mustWork = FALSE)
temp_file <- paste0(tempfile(), ".tsv.bgz")
withr::defer(file.remove(temp_file))

Expand Down

0 comments on commit d06902a

Please sign in to comment.