Describes container dimensions and samples to container location assignment.
A typical workflow starts with creating a BatchContainer
. Then
samples can be assigned to locations in that container.
trace
Optimization trace, a tibble::tibble()
scoring_f
Scoring functions used for optimization. Each scoring function should receive a BatchContainer. This function should return a floating point score value for the assignment. This a list of functions. Upon assignment a single function will be automatically converted to a list In the later case each function is called.
has_samples
Returns TRUE if BatchContainer
has samples.
has_samples_attr
Returns TRUE if BatchContainer
has sample atrributes assigned.
n_locations
Returns number of locations in a BatchContainer
.
n_dimensions
Returns number of dimensions in a BatchContainer
.
This field cannot be assigned.
dimension_names
character vector with dimension names. This field cannot be assigned.
samples
Samples in the batch container. When assigning data.frame should not have column named .sample_id column.
samples_attr
Extra attributes of samples. If set, this is included into
BatchContainer$get_samples()
output.
assignment
Sample assignment vector. Should contain NAs for empty locations.
Assigning this field is deprecated, please use $move_samples()
instead.
new()
Create a new BatchContainer object.
BatchContainer$new(locations_table, dimensions, exclude = NULL)
locations_table
A table with available locations.
dimensions
A vector or list of dimensions. Every dimension
should have a name. Could be an integer vector of dimensions or
a named list. Every value of a list could be either dimension size
or parameters for
BatchContainerDimension$new().
Can be used as an alternative to passing locations_table
.
exclude
data.frame with excluded locations of a container. Only used together with dimensions.
bc <- BatchContainer$new(
dimensions = list(
"plate" = 3,
"row" = list(values = letters[1:3]),
"column" = list(values = c(1, 3))
),
exclude = data.frame(plate = 1, row = "a", column = c(1, 3), stringsAsFactors = FALSE)
)
bc
get_samples()
Return table with samples and sample assignment.
BatchContainer$get_samples(
assignment = TRUE,
include_id = FALSE,
remove_empty_locations = FALSE,
as_tibble = TRUE
)
assignment
Return sample assignment. If FALSE, only samples table is returned, with out batch assignment.
include_id
Keep .sample_id in the table. Use TRUE
for
lower overhead.
remove_empty_locations
Removes empty locations from the result tibble.
as_tibble
Return tibble
.
If FALSE
returns data.table
. This should have
lower overhead, as internally there is a cached data.table
.
get_locations()
Get a table with all the locations in a BatchContainer
.
A tibble
with all the available locations.
move_samples()
Move samples between locations
This method can receive either src
and dst
or locations_assignment
.
score()
Score current sample assignment,
print()
Prints information about BatchContainer
.
scores_table()
Return a table with scores from an optimization.
a tibble::tibble()
with scores
plot_trace()
Plot trace
index
optimization index, all by default
include_aggregated
include aggregated scores
...
not used.
a ggplot2::ggplot()
object
List of scoring functions.
Tibble with batch container locations.
Tibble with sample information and sample ids.
Sample attributes, a data.table.
Vector with assignment of sample ids to locations.
Cached data.table with samples assignment.
Validate sample assignment.
## ------------------------------------------------
## Method `BatchContainer$new`
## ------------------------------------------------
bc <- BatchContainer$new(
dimensions = list(
"plate" = 3,
"row" = list(values = letters[1:3]),
"column" = list(values = c(1, 3))
),
exclude = data.frame(plate = 1, row = "a", column = c(1, 3), stringsAsFactors = FALSE)
)
bc
#> Batch container with 16 locations.
#> Dimensions: plate, row, column