Practical Machine Learning in the Clinical Laboratory

Welcome to Practical Machine Learning in the Clinical Laboratory. This site aims to serve as a supplement to the content outlined in the article, “Validating, Implementing, and Monitoring Machine Learning Solutions in the Clinical Laboratory Safely and Effectively”. We hope to provide a more detailed, technical corollary to the concepts and principles discussed in the main article.

The site will guide us through some of the practical components of applying machine learning to clinical laboratory tasks using a real-world example, the detection of basic metabolic panel (BMP) results that have been contaminated by 0.9% normal saline (NS). The data and models used in this example are publicly available on FigShare (see Getting Started), and the code will be written in R.

The Motivating Example

Erroneous laboratory results contribute to a cascade of downstream consequences that negatively impact patient care1, including delays in diagnosis, incorrect treatments, and increased healthcare costs24. The majority of these errors stem from issues of improper collection or transport, and occur prior to a specimen reaching the laboratory5,6. While substantial progress has been made in reducing the burden of mislabeled specimens, improperly ordered tests, and other preanalytical errors711, contamination by IV fluids remains an unsolved problem12,13. Recognizing this unmet need, the IFCC Working Group on Laboratory Error and Patient Safety added a new quality indicator – “Contamination by a non-microbiological source (Pre-Cont)” to its 2019 report14.

Figure 1: Preanalytical errors are common, and occur prior to specimens reaching the laboratory.

IV Fluid Contamination

IV fluid contamination occurs when a sample is collected from a catheter through which a solution is being infused or drawn proximally to the catheter’s insertion site. This leads to divergence in the measured concentrations for all analytes being tested, the nature of which depend on the composition of the contaminating fluid (Figure 2). Current protocols for detecting contaminated specimens vary across institutions, and may rely on delta checks, feasibility flags, or manual technologist review. These methods are often time-consuming and may prone to error15. The multivariate nature of this problem lends itself well to a machine learning solution.

Figure 2: Preanalytical errors, such as IV fluid contamination, often display an “anomaly-with-resolution” pattern across multiple analytes if recollected with proper technique.

The Machine Learning Solution

~2,500,000 BMP results collected from inpatients at a single institution were extracted from the laboratory information system. Contamination by 0.9% normal saline was simulated16 at varying mixture ratios in a randomly selected subset of results (Figure 3). An XGBoost17 model was tuned using cross-validation, then trained to predict the binary class label of simulated contamination vs. physiologic result.

Two models will be described in this example:

  • A real-time model that uses the patients’ current and most recent prior results to predicts contamination at the time the specimen is drawn.

  • A retrospective model which also incorporates patients’ subsequent results to assess for the anomaly-with-resolution pattern.

The real-time model would be intended for live clinical use, while the retrospective model would be intended as a quality assurance tool and mechanism by which ground truth labels could be applied in an automated, scalable fashion.

Figure 3: Simulating normal saline contamination to generate labels for training the XGBoost model.

References

1.
Mold JW, Stein HF. The Cascade Effect in the Clinical Care of Patients. New England Journal of Medicine [Internet] 1986;314(8):512–4. Available from: http://www.nejm.org/doi/abs/10.1056/NEJM198602203140809
2.
Plebani M. Laboratory-associated and diagnostic errors: A neglected link. Diagnosis [Internet] 2014;1(1):89–94. Available from: https://www.degruyter.com/document/doi/10.1515/dx-2013-0030/html
3.
Committee on Diagnostic Error in Health Care, Board on Health Care Services, Institute of Medicine, The National Academies of Sciences, Engineering, and Medicine. Improving Diagnosis in Health Care [Internet]. Washington (DC): National Academies Press (US); 2015. Available from: http://www.ncbi.nlm.nih.gov/books/NBK338596/
4.
Graber ML. The physician and the laboratory: Partners in reducing diagnostic error related to laboratory testing. Pathology Patterns Reviews 2006;126(suppl_1):S44–7.
5.
Carraro P, Plebani M. Errors in a Stat Laboratory: Types and Frequencies 10 Years Later. Clinical Chemistry [Internet] 2007;53(7):1338–42. Available from: https://academic.oup.com/clinchem/article/53/7/1338/5627526
6.
Sciacovelli L, Panteghini M, Lippi G, et al. Defining a roadmap for harmonizing quality indicators in laboratory medicine: A consensus statement on behalf of the IFCC working group laboratory error and patient safety and EFLM task and finish group performance specifications for the extra-analytical phases. Clinical Chemistry and Laboratory Medicine (CCLM) [Internet] 2017;55(10). Available from: https://www.degruyter.com/document/doi/10.1515/cclm-2017-0412/html
7.
Ho CKM, Chen C, Setoh JWS, Yap WWT, Hawkins RCW. Optimization of hemolysis, icterus and lipemia interference thresholds for 35 clinical chemistry assays. Practical Laboratory Medicine [Internet] 2021;25:e00232. Available from: https://linkinghub.elsevier.com/retrieve/pii/S2352551721000329
8.
9.
Mays JA, Greene DN, Merrill AE, Mathias PC. Evidence-Based Validation of Hemolysis Index Thresholds by Use of Retrospective Clinical Data. The Journal of Applied Laboratory Medicine 2018;3(1):109–14.
10.
Farrell C-J, Makuni C, Keenan A, Maeder E, Davies G, Giannoutsos J. A Machine Learning Model for the Routine Detection of Wrong Blood in Complete Blood Count Tube Errors. Clinical Chemistry [Internet] 2023;69(9):1031–7. Available from: https://academic.oup.com/clinchem/article/69/9/1031/7227182
11.
Lippi G, Betsou F, Cadamuro J, et al. Preanalytical challenges time for solutions. Clinical Chemistry and Laboratory Medicine (CCLM) [Internet] 2019;57(7):974–81. Available from: https://www.degruyter.com/document/doi/10.1515/cclm-2018-1334/html
12.
Choucair I, Lee ES, Vera MA, Drongmebaro C, El-Khoury JM, Durant TJS. Contamination of clinical blood samples with crystalloid solutions: An experimental approach to derive multianalyte delta checks. Clinica Chimica Acta [Internet] 2023;538:22–8. Available from: https://linkinghub.elsevier.com/retrieve/pii/S0009898122013456
13.
Spies NC, Farnsworth CW. Impact and frequency of IV fluid contamination on basic metabolic panel results using quality metrics. Journal of Laboratory Medicine [Internet] 2024;0(0). Available from: https://www.degruyter.com/document/doi/10.1515/labmed-2023-0098/html
14.
Sciacovelli L, Lippi G, Sumarac Z, et al. Pre-analytical quality indicators in laboratory medicine: Performance of laboratories participating in the IFCC working group "Laboratory Errors and Patient Safety" project. Clinica Chimica Acta; International Journal of Clinical Chemistry 2019;497:35–40.
15.
Strathmann FG, Baird GS, Hoffman NG. Simulations of delta check rule performance to detect specimen mislabeling using historical laboratory data. Clinica Chimica Acta [Internet] 2011;412(21-22):1973–7. Available from: https://linkinghub.elsevier.com/retrieve/pii/S0009898111003846
16.
Spies NC, Hubler Z, Azimi V, et al. Automating the Detection of IV Fluid Contamination Using Unsupervised Machine Learning. Clinical Chemistry [Internet] 2023;hvad207. Available from: https://academic.oup.com/clinchem/advance-article/doi/10.1093/clinchem/hvad207/7470143
17.
Chen T, Guestrin C. KDD ’16: The 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining [Internet]. San Francisco California USA: ACM; 2016. p. 785–94.Available from: https://dl.acm.org/doi/10.1145/2939672.2939785