Skip to content

Commit

Permalink
Fix add option and symmetric pairwise dispensing.
Browse files Browse the repository at this point in the history
Add a private `set_block_` function to ease debugging.
  • Loading branch information
charles-plessy committed Sep 26, 2023
1 parent 1a7abc6 commit 20a139e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
4 changes: 2 additions & 2 deletions R/dispensing.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ dispense_pairs <- function (plate, set1, set2 = set1, volume, start = "A01") {
}

for (Nth in seq_along(set1)) {
plate <- set_block(plate, dispense_pairs_first(Nth), set1[Nth], volume)
plate <- set_block(plate, dispense_pairs_first(Nth), set1[Nth], volume, add = TRUE)
}

for (Nth in seq_along(set2)) {
plate <- set_block(plate, dispense_pairs_second(Nth), set2[Nth], volume)
plate <- set_block(plate, dispense_pairs_second(Nth), set2[Nth], volume, add = TRUE)
}

plate
Expand Down
25 changes: 17 additions & 8 deletions R/plates.R
Original file line number Diff line number Diff line change
Expand Up @@ -379,23 +379,32 @@ setMethod( "setWell", c("Plate", "Well", "character", "logical")
setGeneric("set_block", function(plate, block, what, value, add = FALSE)
standardGeneric("set_block"))

#' @rdname set_block
#' @export

setMethod( "set_block", c("Plate", "character", "character", "numeric")
, function(plate, block, what, value, add) {
set_block_ <- function(plate, block, what, value, add) {
plate$well <- rownames(plate)
if (isTRUE(add)) {
oldVolumes <- plate[,what]
oldVolumes[is.na(oldVolumes)] <- 0
if(what %in% colnames(plate)) {
oldVolumes <- plate[,what]
oldVolumes[is.na(oldVolumes)] <- 0
} else {
oldVolumes <- 0
}
plate[,what] <- 0
plate <- platetools::set_block(plate, block, what, value)
plate[,what] <- plate[,what] + oldVolumes
} else {
plate <- platetools::set_block(plate, block, what, value)
}
plate$well <- NULL
plate
})
}


#' @rdname set_block
#' @export

setMethod( "set_block"
, c("Plate", "character", "character", "numeric")
, set_block_)

#' Get reagent name
#'
Expand Down

0 comments on commit 20a139e

Please sign in to comment.