Build records describing a scalar/vector/matrix that a computation
consumes or produces. Records are stored in the data slot of a
Contract() and consumed by contractor().
Usage
contract_scalar(name, expectation, type, description)
contract_vector(axis, name, expectation, type, description)
contract_matrix(rows_axis, columns_axis, name, expectation, type, description)Arguments
- name
Property name (character scalar).
- expectation
One of the expectation-constants (e.g.
RequiredInput,CreatedOutput).- type
R class name (e.g.
"integer","numeric","character").- description
Free-text description (character scalar).
- axis
Axis name for a vector property.
- rows_axis, columns_axis
Axis names for a matrix property.
Value
A list record with $kind, $name, $expectation, $type,
$description, and kind-specific axis fields.
Examples
s <- contract_scalar("organism", RequiredInput, "character", "species name")
v <- contract_vector("cell", "donor", RequiredInput, "character", "donor id")
m <- contract_matrix("cell", "gene", "UMIs", RequiredInput, "integer", "UMI counts")
# These records go into Contract(data = ...):
c <- Contract(
axes = list(cell = list(RequiredInput, "per-cell axis"),
gene = list(RequiredInput, "per-gene axis")),
data = list(s, v, m)
)
length(c@data)
#> [1] 3