
Build precision-weight input from a curveR calibration result
Source:R/as_weight_data.R
as_weight_data.RdConverts a curveRcore calibration_result or
calibration_result_multiplate (the object returned by
curveRfreq::fit_calibration_freq_multiplate() or
curveRbayes::fit_calibration_bayes()) into the tidy, standardized
data frame consumed by fit_precision_weights(). A plain data frame is also
accepted (validation/passthrough), which is the escape hatch for the
original foreign-data workflow.
Usage
as_weight_data(
x,
design,
source = c("samples", "grid"),
conc_scale = c("log10", "natural"),
include_plate = TRUE,
plate_in_cell = FALSE,
drop_oor = FALSE,
...
)
# S3 method for class 'calibration_result_multiplate'
as_weight_data(
x,
design,
source = c("samples", "grid"),
conc_scale = c("log10", "natural"),
include_plate = TRUE,
plate_in_cell = FALSE,
drop_oor = FALSE,
...
)
# S3 method for class 'calibration_result'
as_weight_data(
x,
design,
source = c("samples", "grid"),
conc_scale = c("log10", "natural"),
include_plate = TRUE,
plate_in_cell = FALSE,
drop_oor = FALSE,
...
)
# S3 method for class 'data.frame'
as_weight_data(
x,
design,
source = c("samples", "grid"),
conc_scale = c("log10", "natural"),
include_plate = TRUE,
plate_in_cell = FALSE,
drop_oor = FALSE,
...
)Arguments
- x
A
calibration_result,calibration_result_multiplate, ordata.frame.- design
Character vector of design-group column names that define the saturated cells (e.g.
c("timeperiod", "cohort_arm")). These must be present on the input. For acalibration_result(_multiplate)they are carried through from the originalsamplesdata frame passed at fit time — if they are absent, supply them on the fitting input first, or use thedata.framemethod with a pre-joined frame.- source
"samples"(default) extracts per-sample predictions;"grid"extracts the precision grid (used bypredict_weights()to build a continuous weight profile).- conc_scale
Location-response scale:
"log10"(default, usespredicted_concentration) or"natural"(usesfinal_concentrationwhen present, else10^predicted_concentration).- include_plate
Logical: attach
curve_idas a column and make it available as a plate grouping. DefaultTRUE.- plate_in_cell
Logical: fold
curve_idinto the cell factor alongsidedesign. DefaultFALSE— plate variation is left to be absorbed byphi/ the plate random effect (see the plan, §5).- drop_oor
Logical: drop rows with
pcov_pass == FALSE? DefaultFALSE(keep but warn) — not discarding out-of-range observations is the point of the package.- ...
Passed to methods.
Value
A data frame (class weight_data) with at least: obs_id,
sampleid (if present), curve_id (if include_plate),
concentration (location response on conc_scale),
predicted_concentration (log10, for the estimator), se
(= se_concentration, the canonical uncapped scale predictor),
pcov (reference only), pcov_pass, the design columns,
and .cell. Carries attributes conc_scale,
is_log_independent, design, plate_in_cell.
Details
Extraction from the S3 object is delegated to
curveRcore::tidy_samples() / curveRcore::tidy_grid() so that
the data contract has a single owner; this adapter never reaches into object
internals.