R/plate_layout.R

Defines functions .plate_layout

.plate_layout <- function(plate.dimensions,forbidden.wells) {
  plate.dimensions <- as.integer(plate.dimensions)

  plate.layout <- matrix(FALSE,
                         nrow=plate.dimensions[1],
                         ncol=plate.dimensions[2])

  rownames(plate.layout) <- LETTERS[seq_len(plate.dimensions[1])]
  colnames(plate.layout) <- seq_len(plate.dimensions[2])

  if(!is.null(forbidden.wells)) {
    forbidden.wells <- lapply(forbidden.wells,function(x) {
      return(list(row=(gsub("[[:digit:]]","",x) |> match(LETTERS)),
                  column=(gsub("[^[:digit:]]","",x)) |> as.integer()))
    }) |> data.table::rbindlist()

    plate.layout[cbind(forbidden.wells[,row],
                       forbidden.wells[,column])] <- NA
  }

  return(plate.layout)
}
dimitriskokoretsis/qpcrR documentation built on May 29, 2022, 10:11 p.m.