Skip to contents

Classify specimens at the stored cutoff

Usage

classify_specimen(
  deployable,
  x_new,
  meta = NULL,
  detected = NULL,
  strict = FALSE,
  run_offset = 0
)

Arguments

deployable

A singlesample_deployable object from deploy_singlesample.

x_new

A single named numeric vector, or a numeric matrix/data frame with one or more specimen rows and feature columns. With an attached preprocessor, supply raw counts, Ct values or log-scale measurements. Ct character markers are accepted and converted to non-detects.

meta

Optional per-specimen metadata, one row per row of x_new. Legacy metadata routes require their training metadata field (kit, biofluid, technology or rin). Missing values raise `MISSING_METADATA`; unseen categorical levels raise `UNSEEN_METADATA_LEVEL`. Hemolysis residuals accept a finite `hemo_score` or require both frozen hemolysis anchors.

detected

Optional logical matrix aligned to x_new (or a named logical vector for one specimen). TRUE means detected before imputation. Supply this mask when preprocessing replaces nondetects by positive values that cannot be distinguished from measured values. No detection status is inferred from scored-batch variation or from a constant specimen profile. With a preprocessor, align this mask to the raw input, including extra columns. It is combined with preprocessing detection by logical AND.

strict

Logical scalar; defaults to FALSE. If TRUE, k-TSP and pair-ratio require every fitted-pair feature, trimmed rCLR requires the frozen training feature universe, and balance ILR requires every frozen balance member. Other routes and custom adapters reject with STRICT_UNSUPPORTED. Existing input guards apply in both modes. Registered custom scorers declaring `strict_support = TRUE` receive the flag and apply their documented strict policy.

run_offset

One finite number on the score scale, usually from estimate_calibrator_offset(). Subtracted from each score before classification. The default is zero.

Value

A data frame in input order with score from score_specimen(), adjusted_score after subtraction, and character result equal to "positive" when the adjusted score is at least the cutoff and "negative" otherwise. The character column reason_code is NA for scored specimens. For a single specimen declined with ALL_NONDETECT or NO_ACTIVE_FEATURE_DETECTED, the score, adjusted score and result are NA and reason_code gives the code. Other input errors and the rejection of a batch containing a declined row follow score_specimen().