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 Jan 13, 2025
1 parent 92b30e8 commit 531d70f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
10 changes: 5 additions & 5 deletions R/classes-plate.R
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,11 @@ Plate <- R6::R6Class(
If you want to try doing it using different method, consider reversing this process")
}
method <- switch(threshold,
"min" = min,
"max" = max,
"mean" = mean,
"median" = median,
stop(threshold, " not available for `threshold`, consider using one of the following: ", available_methods)
"min" = min,
"max" = max,
"mean" = mean,
"median" = median,
stop(threshold, " not available for `threshold`, consider using one of the following: ", available_methods)
)

plate <- if (in_place) self else self$clone(deep = TRUE)
Expand Down
34 changes: 19 additions & 15 deletions R/classes-plate_builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PlateBuilder <- R6::R6Class(
stopifnot(is.character(sample_names) && length(sample_names) > 0)
self$sample_names <- sample_names
stopifnot(is.character(analyte_names) &&
length(analyte_names) > 0)
length(analyte_names) > 0)
self$analyte_names <- analyte_names

stopifnot(is.character(batch_name) && is.scalar(batch_name))
Expand All @@ -65,7 +65,7 @@ PlateBuilder <- R6::R6Class(
#' @param sample_locations vector of sample locations pretty name ie. A1, B2
set_sample_locations = function(sample_locations) {
stopifnot(is.character(sample_locations) &&
length(sample_locations) > 0)
length(sample_locations) > 0)
stopifnot(length(sample_locations) == length(self$sample_names))
stopifnot(all(stringr::str_detect(sample_locations, "^[A-Z][0-9]+$")))

Expand Down Expand Up @@ -240,8 +240,9 @@ PlateBuilder <- R6::R6Class(
stop("Data type `", name, "` is not a valid data type")
}
}
stopifnot(all(sapply(data, function(x)
is.data.frame(x))))
stopifnot(all(sapply(data, function(x) {
is.data.frame(x)
})))
for (data_type_df in data) {
if (nrow(data_type_df) != length(self$sample_names)) {
stop("Number of rows in data frame does not match the number of samples")
Expand Down Expand Up @@ -339,8 +340,10 @@ PlateBuilder <- R6::R6Class(
validate = function() {
errors <- list()
if (length(self$sample_names) != length(self$sample_locations)) {
append(errors,
"Length of sample_names and sample_locations is not equal")
append(
errors,
"Length of sample_names and sample_locations is not equal"
)

Check warning on line 346 in R/classes-plate_builder.R

View check run for this annotation

Codecov / codecov/patch

R/classes-plate_builder.R#L343-L346

Added lines #L343 - L346 were not covered by tests
}
if (length(self$sample_names) != length(self$dilutions)) {
append(errors, "Length of sample_names and dilutions is not equal")
Expand Down Expand Up @@ -427,7 +430,7 @@ is_dilution <- function(character_vector) {
dilution_regex <- "^\\d+/\\d+$"
is_valid_dilution <-
(!is.na(character_vector)) &
(stringr::str_detect(character_vector, dilution_regex))
(stringr::str_detect(character_vector, dilution_regex))
is_valid_dilution
}

Expand Down Expand Up @@ -527,24 +530,24 @@ translate_sample_names_to_sample_types <-
positive_control_pattern <-
"^(P.|POS.+|[A-Za-z0-9/-_]+ )(1/\\d+)$"
if (grepl(positive_control_pattern, name) ||
grepl(positive_control_pattern, name_layout)) {
grepl(positive_control_pattern, name_layout)) {
sample_type <- "POSITIVE CONTROL"
}
# Check if the sample is a negative control
negative_types <- c("NEGATIVE CONTROL", "N")
negative_pattern <- "^(N..|.*\\bNEG\\b)"
if (name %in% negative_types ||
grepl(negative_pattern, name) ||
grepl(negative_pattern, name_layout)) {
grepl(negative_pattern, name) ||
grepl(negative_pattern, name_layout)) {
sample_type <- "NEGATIVE CONTROL"
}
# Check if the sample is a standard curve
standard_curve_types <- c("STANDARD CURVE", "SC", "S")
standard_curve_pattern <- "^(S_|S|S\\s|CP.+)(1/\\d+)$"
standard_curve_loc_pattern <- "^(1/\\d+)$"
if (name %in% standard_curve_types ||
grepl(standard_curve_pattern, name) ||
grepl(standard_curve_loc_pattern, name_layout)) {
grepl(standard_curve_pattern, name) ||
grepl(standard_curve_loc_pattern, name_layout)) {
sample_type <- "STANDARD CURVE"
}
# Assign the determined sample type
Expand Down Expand Up @@ -575,7 +578,8 @@ get_location_matrix <- function(nrow = 8, ncol = 12, as_vector = FALSE) {
return(all_locations)
}
all_location_matrix <- matrix(all_locations,
nrow = nrow,
ncol = ncol,
byrow = TRUE)
nrow = nrow,
ncol = ncol,
byrow = TRUE
)
}

0 comments on commit 531d70f

Please sign in to comment.