| BatchContainer {designit} | R Documentation |
R6 Class representing a batch container.
Description
Describes container dimensions and samples to container location assignment.
Details
A typical workflow starts with creating a BatchContainer. Then
samples can be assigned to locations in that container.
Public fields
traceOptimization trace, a
tibble::tibble()
Active bindings
scoring_fScoring 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_samplesReturns TRUE if
BatchContainerhas samples.has_samples_attrReturns TRUE if
BatchContainerhas sample atrributes assigned.n_locationsReturns number of locations in a
BatchContainer.n_dimensionsReturns number of dimensions in a
BatchContainer. This field cannot be assigned.dimension_namescharacter vector with dimension names. This field cannot be assigned.
samplesSamples in the batch container. When assigning data.frame should not have column named .sample_id column.
samples_attrExtra attributes of samples. If set, this is included into
BatchContainer$get_samples()output.assignmentSample assignment vector. Should contain NAs for empty locations.
Assigning this field is deprecated, please use
$move_samples()instead.
Methods
Public methods
Method new()
Create a new BatchContainer object.
Usage
BatchContainer$new(locations_table, dimensions, exclude = NULL)
Arguments
locations_tableA table with available locations.
dimensionsA 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.excludedata.frame with excluded locations of a container. Only used together with dimensions.
Examples
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
Method get_samples()
Return table with samples and sample assignment.
Usage
BatchContainer$get_samples( assignment = TRUE, include_id = FALSE, remove_empty_locations = FALSE, as_tibble = TRUE )
Arguments
assignmentReturn sample assignment. If FALSE, only samples table is returned, with out batch assignment.
include_idKeep .sample_id in the table. Use
TRUEfor lower overhead.remove_empty_locationsRemoves empty locations from the result tibble.
as_tibbleReturn
tibble. IfFALSEreturnsdata.table. This should have lower overhead, as internally there is a cacheddata.table.
Returns
table with samples and sample assignment.
Method get_locations()
Get a table with all the locations in a BatchContainer.
Usage
BatchContainer$get_locations()
Returns
A tibble with all the available locations.
Method move_samples()
Move samples between locations
This method can receive either src and dst or locations_assignment.
Usage
BatchContainer$move_samples(src, dst, location_assignment)
Arguments
srcinteger vector of source locations
dstinteger vector of destination locations (the same length as
src).location_assignmentinteger vector with location assignment. The length of the vector should match the number of locations,
NAshould be used for empty locations.
Returns
BatchContainer, invisibly
Method score()
Score current sample assignment,
Usage
BatchContainer$score(scoring)
Arguments
scoringa function or a names list of scoring functions. Each function should return a numeric vector.
Returns
Returns a named vector of all scoring functions values.
Method copy()
Create an independent copy (clone) of a BatchContainer
Usage
BatchContainer$copy()
Returns
Returns a new BatchContainer
Method print()
Prints information about BatchContainer.
Usage
BatchContainer$print(...)
Arguments
...not used.
Method scores_table()
Return a table with scores from an optimization.
Usage
BatchContainer$scores_table(index = NULL, include_aggregated = FALSE)
Arguments
indexoptimization index, all by default
include_aggregatedinclude aggregated scores
Returns
a tibble::tibble() with scores
Method plot_trace()
Plot trace
Usage
BatchContainer$plot_trace(index = NULL, include_aggregated = FALSE, ...)
Arguments
indexoptimization index, all by default
include_aggregatedinclude aggregated scores
...not used.
Returns
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.
Examples
## ------------------------------------------------
## 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