Distributes samples based on a sample sheet.

assign_from_table(batch_container, samples)

Arguments

batch_container

Instance of BatchContainer class

samples

data.frame with samples (a sample sheet). This data.frame (or tibble::tibble()) should contain samples together with their locations. No .sample_id column can be present in the sample sheet. In batch_container already has samples assigned, the function will check if samples in batch_container are identical to the ones in the samples argument.

Value

Returns a new BatchContainer.

Examples

bc <- BatchContainer$new(
  dimensions = list(
    plate = 2,
    column = list(values = letters[1:3]),
    row = 3
  )
)

sample_sheet <- tibble::tribble(
  ~plate, ~column, ~row, ~sampleID, ~group,
  1, "a", 1, 1, "TRT",
  1, "b", 2, 2, "CNTRL",
  2, "a", 1, 3, "TRT",
  2, "b", 2, 4, "CNTRL",
  2, "a", 3, 5, "TRT",
)
# assign samples from the sample sheet
bc <- assign_from_table(bc, sample_sheet)

bc$get_samples(remove_empty_locations = TRUE)
#> # A tibble: 5 × 5
#>   plate column   row sampleID group
#>   <int> <fct>  <int>    <dbl> <chr>
#> 1     1 a          1        1 TRT  
#> 2     1 b          2        2 CNTRL
#> 3     2 a          1        3 TRT  
#> 4     2 a          3        5 TRT  
#> 5     2 b          2        4 CNTRL