Skip to content

Commit

Permalink
Style code (GHA)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 28, 2024
1 parent 3a8ecc5 commit 12014f3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 12 deletions.
12 changes: 8 additions & 4 deletions R/process-plate.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ is_valid_normalisation_type <- function(normalisation_type) {
#' process_plate(plate, output_dir = example_dir)
#'
#' # process plate without adjusting blanks and save the output to a file with a custom name
#' process_plate(plate, filename = "plate_without_blanks_adjusted.csv",
#' output_dir = example_dir, adjust_blanks = FALSE)
#' process_plate(plate,
#' filename = "plate_without_blanks_adjusted.csv",
#' output_dir = example_dir, adjust_blanks = FALSE
#' )
#'
#'
#' # nMFI normalisation
Expand Down Expand Up @@ -105,8 +107,10 @@ process_plate <-


output_path <- validate_filepath_and_output_dir(filename, output_dir,
plate$plate_name, normalisation_type,
"csv", verbose = verbose)
plate$plate_name, normalisation_type,
"csv",
verbose = verbose
)


if (!plate$blank_adjusted && adjust_blanks) {
Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test-generate_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test_that("Test generate_plate_report function", {
expect_no_error(generate_plate_report(plate, output_dir = tmp_dir))
expect_no_error(generate_plate_report(plate, output_dir = tmp_dir, filename = "test_report.html"))
file.remove(file.path(tmp_dir, "test_report.html"))
expect_no_error(generate_plate_report(plate, output_dir = tmp_dir, filename = "test_report.html", counts_lower_threshold = 40, counts_higher_threshold = 80))
expect_no_error(generate_plate_report(plate, output_dir = tmp_dir, filename = "test_report.html", counts_lower_threshold = 40, counts_higher_threshold = 80))
file.remove(file.path(tmp_dir, "test_report.html"))
expect_no_error(generate_plate_report(plate, output_dir = tmp_dir, filename = "test_report.html", additional_notes = "This is a test report."))
file.remove(file.path(tmp_dir, "test_report.html"))
Expand All @@ -42,7 +42,6 @@ test_that("Test generate_plate_report function", {
multiline_note <- "This is a test report.\nThis is a test report."
expect_no_error(generate_plate_report(plate, output_dir = tmp_dir, filename = "test_report.html", additional_notes = multiline_note))
file.remove(file.path(tmp_dir, "test_report.html"))

})

test_that("Test generate_levey_jennings_report function", {
Expand Down
12 changes: 8 additions & 4 deletions tests/testthat/test-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,23 @@ test_that("Test validate_filepath_and_output_dir function", {

# filename with no output_dir
expect_warning(
validate_filepath_and_output_dir(file.path(tmp_dir, "test.html"), tmp_dir, "plate_name", "report", "html"))
validate_filepath_and_output_dir(file.path(tmp_dir, "test.html"), tmp_dir, "plate_name", "report", "html")
)

expect_no_warning(
validate_filepath_and_output_dir(file.path(tmp_dir, "test.html"), NULL, "plate_name", "report", "html"))
validate_filepath_and_output_dir(file.path(tmp_dir, "test.html"), NULL, "plate_name", "report", "html")
)

file.create(file.path(tmp_dir, "test.html"))
# overwrite existing file
expect_warning(
validate_filepath_and_output_dir(file.path(tmp_dir, "test.html"), tmp_dir, "plate_name", "report", "html"))
validate_filepath_and_output_dir(file.path(tmp_dir, "test.html"), tmp_dir, "plate_name", "report", "html")
)

# create output directory
expect_no_error(
validate_filepath_and_output_dir("test.html", file.path(tmp_dir, "output"), "plate_name", "report", "html"))
validate_filepath_and_output_dir("test.html", file.path(tmp_dir, "output"), "plate_name", "report", "html")
)

expect_true(dir.exists(file.path(tmp_dir, "output")))
})
4 changes: 2 additions & 2 deletions tests/testthat/test-process-plate.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ test_that("Processing plate with nMFI", {
file.remove(test_output_path)
# Test processing of a plate with reference dilution specified
expect_no_error(
process_plate(plate, output_dir = tmp_dir, filename = "output.csv", normalisation_type = "nMFI", reference_dilution = "1/50")
process_plate(plate, output_dir = tmp_dir, filename = "output.csv", normalisation_type = "nMFI", reference_dilution = "1/50")
)
expect_true(file.exists(test_output_path))
expect_no_error(dilutions <- read.csv(test_output_path))
Expand Down Expand Up @@ -85,7 +85,7 @@ test_that("raw MFI in dataframe", {

# Test processing of a plate, with raw MFI
expect_no_error(
output_df <- process_plate(plate, output_dir = tmp_dir, filename = "output.csv", normalisation_type = "nMFI", include_raw_mfi = TRUE)
output_df <- process_plate(plate, output_dir = tmp_dir, filename = "output.csv", normalisation_type = "nMFI", include_raw_mfi = TRUE)
)
stopifnot(all(colnames(output_df) == c(plate$analyte_names, paste0(plate$analyte_names, "_raw"))))
})

0 comments on commit 12014f3

Please sign in to comment.