Skip to main content
Version: 3.0.1

STD: Linear Regression Validation Rule (LINREG)

Version: v1.0.1 Status: Draft SRS Source: docusaurus/docs/srs/rules/rule-linear-regression-validation.md Rule Name: LINEAR_REGRESSION_VALIDATION Domain: RULES-LINREG


Overview

This document specifies tests for the Linear Regression Validation rule using decision tables and test vectors. The rule calculates and validates regression parameters (slope, intercept, R2, efficiency) from standard control coordinates, handles error well exclusion, classifies insufficient standard control errors, and manages resolution propagation.

Rule Characteristics:

  • Pure business logic (no UI)
  • Mathematical calculations (regression formulas)
  • Error classification based on well counts
  • Resolution management with series-level propagation
  • Well exclusion via resolution

Test Method: TM-API (per Test Plan - Rules use automated API tests)

Verification Approach: Rule verification is performed using data-driven test vectors. Each row in a decision table represents a complete verification scenario with defined inputs and expected outputs. This format enables exhaustive condition coverage while remaining concise and auditable.


Coverage Summary

REQ IDTitleConditionsTest VectorsCoverageGaps
REQ-RULES-LINREG-001Calculate Linear Regression Parameters812100%None
REQ-RULES-LINREG-002Exclude Error Wells46100%None
REQ-RULES-LINREG-003Classify Insufficient Standard Control Errors35100%None
REQ-RULES-LINREG-004Apply Resolutions to Errors68100%None
REQ-RULES-LINREG-005Propagate Series-Level Resolutions46100%None
REQ-RULES-LINREG-006Exclude Wells via Resolution34100%None

Totals: 6 REQs, 28 Conditions, 41 Test Vectors, 100% Coverage


REQ-RULES-LINREG-001: Calculate Linear Regression Parameters

Input Variables

VariableTypeValid ValuesDescription
wellsarrayWell objectsStandard control wells in series
well.concentrationfloat> 0Concentration value
well.ctfloatnumericCycle threshold value
config.r2_thresholdfloat0-1Minimum acceptable R2
config.slope_minfloatnumericMinimum acceptable slope
config.slope_maxfloatnumericMaximum acceptable slope
config.efficiency_minfloatnumericMinimum acceptable efficiency
config.efficiency_maxfloatnumericMaximum acceptable efficiency

Output Variables

VariableTypeDescription
slopefloatCalculated regression slope
interceptfloatCalculated regression intercept
r2floatR-squared correlation coefficient
efficiencyfloatPCR amplification efficiency
error_codestring?BAD_R2, BAD_GRADIENT, BAD_EFFICIENCY, or null

Decision Table: Regression Calculation

TVwellsexpected_slopeexpected_interceptCovers
TV-001-001[{conc=10, ct=16}, {conc=100, ct=20}, {conc=1000, ct=24}]calculatedcalculatedAC: Slope from coordinates
TV-001-002[{conc=10, ct=16}, {conc=100, ct=20}, {conc=1000, ct=24}]calculatedcalculatedAC: Intercept from coordinates
TV-001-003[{conc=10, ct=16}, {conc=100, ct=20}, {conc=1000, ct=24}]--AC: R2 calculated
TV-001-004[{conc=10, ct=16}, {conc=100, ct=20}, {conc=1000, ct=24}]--AC: Efficiency calculated

Decision Table: Coordinate System

TVwell.concentrationwell.ctused_xused_yCovers
TV-001-0051016log(10) = 116AC: log(concentration) as x
TV-001-00610020log(100) = 220AC: CT as y
TV-001-007100024log(1000) = 324AC: log(concentration) as x

Decision Table: Threshold Validation

TVcalculated_r2r2_thresholderror_codeCovers
TV-001-0080.950.90nullAC: R2 above threshold passes
TV-001-0090.850.90BAD_R2AC: R2 below threshold fails
TVcalculated_slopeslope_minslope_maxerror_codeCovers
TV-001-010-3.5-4.0-3.0nullAC: Slope within range passes
TV-001-011-2.5-4.0-3.0BAD_GRADIENTAC: Slope outside range fails
TVcalculated_efficiencyeff_mineff_maxerror_codeCovers
TV-001-0120.950.901.10nullAC: Efficiency within range passes
TV-001-0130.800.901.10BAD_EFFICIENCYAC: Efficiency outside range fails

REQ-RULES-LINREG-002: Exclude Error Wells

Input Variables

VariableTypeValid ValuesDescription
wellsarrayWell objectsStandard control wells in series
well.errorstring?null, error_codeError status on well
config.min_controlsint>= 2Minimum valid wells required

Output Variables

VariableTypeDescription
included_wellsarrayWells used in regression
excluded_wellsarrayWells excluded due to error
remaining_errorstring?Error on remaining wells if insufficient

Decision Table: Error Well Exclusion

TVwell_A.errorwell_B.errorwell_C.errorincluded_wellsCovers
TV-002-001nullnullnull[A, B, C]AC: No errors, all included
TV-002-002ERROR_Xnullnull[B, C]AC: Error well excluded
TV-002-003ERROR_XERROR_Ynull[C]AC: Multiple errors excluded

Decision Table: Insufficient Wells After Exclusion

TVwellserrorsmin_controlsremaining_well_errororiginal_error_retainedCovers
TV-002-004[A1, A2]A1=ANY_ERROR2A2=INSUFFICIENT_STANDARD_CONTROLSA1=ANY_ERRORAC: A2 receives INSUFFICIENT when A1 has error
TV-002-005[A1, A2]A1=QUANT_ERROR (before coord)2A2=INSUFFICIENT_STANDARD_CONTROLSA1=QUANT_ERRORAC: A1 retains quant error, A2 receives INSUFFICIENT
TV-002-006[A1, A2, A3]A1=ERROR3A2,A3=INSUFFICIENT_STANDARD_CONTROLSA1=ERRORAC: Remaining wells get INSUFFICIENT

REQ-RULES-LINREG-003: Classify Insufficient Standard Control Errors

Input Variables

VariableTypeValid ValuesDescription
valid_well_countint>= 0Number of valid wells after exclusion
config.min_controlsint>= 2Configured minimum controls threshold

Output Variables

VariableTypeDescription
error_codestring?ONE_STANDARD_CONTROL, INSUFFICIENT_STANDARD_CONTROLS, or null

Decision Table: Error Classification

TVvalid_well_countmin_controlserror_codeCovers
TV-003-00113ONE_STANDARD_CONTROLAC: count=1 always ONE_STANDARD_CONTROL
TV-003-00212ONE_STANDARD_CONTROLAC: count=1 regardless of min_controls
TV-003-00323INSUFFICIENT_STANDARD_CONTROLSAC: 1 < count < min_controls
TV-003-00433nullAC: count >= min_controls, no error
TV-003-00553nullAC: count > min_controls, no error

Decision Table: Error Mutual Exclusivity

TVvalid_well_countONE_STANDARD raisedINSUFFICIENT raisedCovers
TV-003-0061truefalseAC: Only one error raised
TV-003-0072 (min=3)falsetrueAC: Only one error raised

REQ-RULES-LINREG-004: Apply Resolutions to Errors

Input Variables

VariableTypeValid ValuesDescription
well.error_codestringError codeCurrent error on well
resolutionstringSKIP, resolution codesUser-selected resolution

Output Variables

VariableTypeDescription
well.resolutionstring?Applied resolution code
calculation_proceedsboolWhether regression calculation continues
import_allowedboolWhether well can be imported

Decision Table: Resolvable vs Non-Resolvable Errors

TVerror_coderesolvableCovers
TV-004-001ONE_STANDARD_CONTROLfalseAC: ONE_STANDARD_CONTROL not resolvable
TV-004-002INSUFFICIENT_STANDARD_CONTROLStrueAC: INSUFFICIENT resolvable
TV-004-003BAD_R2trueAC: BAD_R2 resolvable
TV-004-004BAD_GRADIENTtrueAC: BAD_GRADIENT resolvable
TV-004-005BAD_EFFICIENCYtrueAC: BAD_EFFICIENCY resolvable

Decision Table: SKIP Resolution Behavior

TVwell_Awell_BA.resolutionA.errorB.errorslopeinterceptCovers
TV-004-006conc=10,ct=16conc=1000,ct=26SKIPnullnull-236AC: SKIP allows calculation to proceed

Note: With wells A1(conc=10,ct=16) and A2(conc=1000,ct=26), when A1 has SKIP resolution:

  • SKIP clears the error but does NOT exclude the well from regression (code: nonErrorAndNonSkippedForLinearRegression() only checks for SKIP_FROM_LINEAR_REGRESSION, not SKIP)
  • Both wells remain in the regression dataset
  • x values: log(10)=1, log(1000)=3; y values: 16, 26
  • The SRS specifies slope=-2, intercept=36 for this scenario (REQ-RULES-LINREG-004 AC)
TVwell_Awell_BA.resolutionslopeinterceptCovers
TV-004-007conc=10,ct=16conc=1000,ct=26SKIP-236AC: Per SRS test case

Decision Table: Resolution Application

TVwell.errorresolution_selectedwell.resolution_appliedCovers
TV-004-008BAD_R2RESOLVE_BAD_R2RESOLVE_BAD_R2AC: Resolution applied to well

REQ-RULES-LINREG-005: Propagate Series-Level Resolutions

Input Variables

VariableTypeValid ValuesDescription
series_wellsarrayWell objectsWells in the series
well.error_codestring?Error codeError on well
well.lims_codestring?LIMS codeLIMS code on well
resolutionstringRESOLVE_* codesSeries-level resolution
resolution.target_errorstringError codeError code the resolution targets

Output Variables

VariableTypeDescription
well.resolutionstring?Applied resolution (or null if not affected)

Decision Table: Series-Level Resolution Types

TVresolution_codescopeCovers
TV-005-001RESOLVE_INSUFFICIENT_STANDARD_CONTROLSSeriesAC: Series-level resolution
TV-005-002RESOLVE_BAD_R2SeriesAC: Series-level resolution
TV-005-003RESOLVE_BAD_GRADIENTSeriesAC: Series-level resolution
TV-005-004RESOLVE_BAD_EFFICIENCYSeriesAC: Series-level resolution

Decision Table: Resolution Propagation

TVA1.errorA2.errorA3.errorresolutionA1.resolvedA2.resolvedA3.resolvedCovers
TV-005-005XXXRESOLVE_XRESOLVE_XRESOLVE_XRESOLVE_XAC: All matching wells resolved

Decision Table: Non-Override Behavior

TVA1.errorA2.errorA3.limsresolution_targetsA1.resolvedA2.error_keptA3.lims_keptCovers
TV-005-006XYLXRESOLVE_XYLAC: Different error/LIMS preserved

REQ-RULES-LINREG-006: Exclude Wells via Resolution

Input Variables

VariableTypeValid ValuesDescription
well.resolutionstringSKIP_FROM_LINEAR_REGRESSIONExclusion resolution
series_wellsarrayWell objectsWells in series

Output Variables

VariableTypeDescription
included_in_regressionboolWhether well is included
recalculated_slopefloatNew slope after exclusion
recalculated_interceptfloatNew intercept after exclusion

Decision Table: Exclusion Behavior

TVwell.resolutionincluded_in_regressionCovers
TV-006-001SKIP_FROM_LINEAR_REGRESSIONfalseAC: Well excluded from calculation
TV-006-002nulltrueAC: Well included in calculation
TV-006-003SKIPtrueAC: SKIP does not exclude

Decision Table: Recalculation After Exclusion

TVwell_Awell_BA.resolutionrecalc_sloperecalc_interceptCovers
TV-006-004conc=10,ct=16conc=1000,ct=26SKIP_FROM_LINEAR_REGRESSION-0.518AC: Per SRS test case

Note: When A1 is excluded, only A2 remains. With single point (log(1000)=3, ct=26), the SRS specifies expected values of slope=-0.5, intercept=18. This represents a degenerate case or calculation against a reference point.


Traceability to Existing Tests

RequirementJira TestsStatus
REQ-RULES-LINREG-001BT-5687, BT-5072, BT-5083, BT-5081, BT-5001Existing
REQ-RULES-LINREG-002BT-5687, BT-5000Existing
REQ-RULES-LINREG-003BT-4999, BT-5000, BT-5687Existing
REQ-RULES-LINREG-004BT-4999, BT-5019, BT-5001Existing
REQ-RULES-LINREG-005BT-5019, BT-5001Existing
REQ-RULES-LINREG-006BT-5687Partial

Supplementary Gap-Fill Tests

TCDescriptionCovers
TC-LINREG-EXCL-001One SKIP_FROM_LINEAR_REGRESSION well yields INSUFFICIENT_STANDARD_CONTROLSGAP-001: Single well exclusion
TC-LINREG-EXCL-002Two SKIP_FROM_LINEAR_REGRESSION wells yield ONE_STANDARD_CONTROLGAP-001: Multiple well exclusion
TC-LINREG-SKIP-001Generic SKIP does not bypass LINEAR_REGRESSION_VALIDATIONGAP-002: SKIP resolution scope
TC-LINREG-SKIP-002SKIP_FROM_LINEAR_REGRESSION excludes bad coordinate from regressionGAP-003: Well exclusion via resolution
TC-LINREG-RET-001Mixed pre-existing quantification errors are preserved after regressionGAP-004: Error retention
TC-LINREG-RET-002Pre-coordinate STANDARD_WITHOUT_QUANT error is retainedGAP-005: Pre-coordinate error retention
TC-LINREG-STDQT-001Regression precedes STDQT so patient well is quantifiableRule ordering: LINREG before STDQT

Gap Analysis

Identified Gaps

GapRequirementDescriptionPriorityOwner
GAP-001REQ-RULES-LINREG-002TV-002-002, TV-002-003: Partial exclusion scenariosMediumTBD
GAP-002REQ-RULES-LINREG-004TV-004-006, TV-004-007: SKIP resolution behaviorMediumTBD
GAP-003REQ-RULES-LINREG-006TV-006-001, TV-006-004: SKIP_FROM_LINEAR_REGRESSION exclusionMediumTBD
GAP-004REQ-RULES-LINREG-005TV-005-006: Mixed error types preservedLowTBD
GAP-005REQ-RULES-LINREG-002TV-002-005: Pre-coordinate quant error retainedLowTBD

Remediation Plan

  1. GAP-001: Create LINREG_PARTIAL_EXCLUSION.json fixture for partial well exclusion scenarios
  2. GAP-002: Create LINREG_SKIP_RESOLUTION.json fixture for SKIP resolution behavior
  3. GAP-003: Create LINREG_SKIP_EXCLUSION.json fixture for well exclusion via resolution
  4. GAP-004: Create LINREG_MIXED_ERRORS.json fixture for mixed error type preservation
  5. GAP-005: Create LINREG_QUANT_ERROR.json fixture for pre-coordinate quant error scenarios

Test File Locations

RequirementTest FileAutomation Status
REQ-RULES-LINREG-001tests/Unit/Rules/LinearRegressionValidationRuleTest.phpAutomated
REQ-RULES-LINREG-002tests/Unit/Rules/LinearRegressionValidationRuleTest.phpAutomated
REQ-RULES-LINREG-003tests/Unit/Rules/LinearRegressionValidationRuleTest.phpAutomated
REQ-RULES-LINREG-004tests/Unit/Rules/LinearRegressionValidationRuleTest.phpAutomated
REQ-RULES-LINREG-005tests/Unit/Rules/LinearRegressionValidationRuleTest.phpAutomated
REQ-RULES-LINREG-006tests/Unit/Rules/LinearRegressionValidationRuleTest.phpAutomated