Proficiency Testing Program (PTP) Visualization & Analysis — R Shiny Module
A web-based R Shiny application for clinical laboratory proficiency testing data visualization and statistical analysis, with full alignment to Chinese national accreditation standards (CNAS) and international guidelines (ISO 13528 / GB/T 27418-2017).
- Project Background
- Standards & Regulatory References
- Key Features
- Statistical Methods
- Getting Started
- Project Structure
- Contributing
- License
Proficiency Testing (PT), also called External Quality Assessment (EQA), is a programme in which an independent PT provider sends identical samples to a group of participating laboratories. Each laboratory analyses the samples with its routine methods and returns results to the provider. The provider then compares each laboratory's results against a consensus or reference value and assigns a performance score.
PT programmes are the primary external tool for:
- Verifying the accuracy and reliability of laboratory measurements.
- Detecting systematic errors (bias) that internal quality-control schemes may miss.
- Supporting accreditation and regulatory compliance.
- Facilitating inter-laboratory harmonisation of clinical measurements.
This project focuses on Therapeutic Drug Monitoring (TDM), a branch of clinical pharmacology and laboratory medicine in which drug concentrations in patient specimens (typically blood/plasma) are measured to optimise individual dosage regimens. Accurate TDM measurements are clinically critical: under-dosing leads to treatment failure, while over-dosing increases the risk of toxic side effects.
PT programmes for TDM analytes (e.g., immunosuppressants, antibiotics, antiepileptics, cardiac drugs) therefore carry direct patient-safety implications, making rigorous statistical evaluation and transparent reporting essential.
This project aims to develop an interactive R Shiny module that:
- Ingests raw PT result data (from laboratories and PT providers).
- Performs all mandatory statistical calculations required by CNAS and ISO 13528 / GB/T 27418-2017.
- Produces publication-quality visualizations (Youden plots, z-score charts, kernel-density distributions, trend charts, etc.).
- Generates structured performance reports suitable for accreditation audits.
The China National Accreditation Service for Conformity Assessment (CNAS, 中国合格评定国家认可委员会) is the sole national accreditation body in China. The following CNAS documents govern laboratory competence and PT participation requirements:
| Document | Title | Relevance to This Project |
|---|---|---|
| CNAS CL01 | General Requirements for the Competence of Testing and Calibration Laboratories (equivalent to ISO/IEC 17025:2017) | Core accreditation standard; defines minimum requirements for quality management and technical competence that all accredited laboratories must meet. |
| CNAS CL01-A012 | Application Requirements for Testing and Calibration Laboratories in Medical Testing | Supplements CNAS CL01 with medical-laboratory-specific requirements including PT participation obligations, sample handling, and reporting of measurement uncertainty. |
| CNAS CL01-A001 | General Application Requirements for CNAS CL01 in Specific Fields | Provides cross-sector guidance on how to interpret and implement CL01 across various testing domains, including clinical chemistry. |
| CNAS-R01 | Regulations on CNAS Recognition (认可规则) | Sets out the procedural rules for obtaining and maintaining CNAS accreditation, including mandatory PT participation frequencies and acceptable performance criteria. |
| CNAS CL01-A026 | Application Requirements for Medical Laboratory Proficiency Testing | Directly governs PT programme design, administration, and result evaluation for medical/clinical laboratories; defines acceptable performance thresholds and required corrective-action procedures. |
| Standard | Title | Description |
|---|---|---|
| GB/T 27418-2017 | 合格评定 — 能力验证的统计方法 (Conformity Assessment — Statistical Methods for Use in Proficiency Testing) | Chinese national standard adopted from ISO 13528:2015. Defines the statistical procedures (assigned value derivation, performance score calculation, robust statistics, etc.) that PT providers and laboratories must follow. |
| ISO 13528:2022 | Statistical Methods for Use in Proficiency Testing by Interlaboratory Comparison | International standard (latest edition) on which GB/T 27418-2017 is based. Describes robust algorithms (Algorithm A, Hampel estimators), z-score and z′-score calculations, and guidance on outlier handling. The 2022 edition supersedes ISO 13528:2015. |
Note: GB/T 27418-2017 is derived from ISO 13528:2015. The core assigned-value and z-score calculations in this project follow GB/T 27418-2017 / ISO 13528:2015. Two additions introduced in ISO 13528:2022 — the expanded guidance on ζ-scores and the updated outlier-screening criteria — are progressively being incorporated and will be flagged in release notes as they land.
- Data Import — Upload PT result tables in CSV/Excel format; supports multi-round and multi-analyte datasets.
- Assigned Value Calculation — Robust mean (Algorithm A per ISO 13528), median, consensus value, or certified reference material value.
- Performance Scoring — z-scores, z′-scores, ζ-scores, and En numbers; configurable σ_pt targets.
- Visualizations
- Youden plots (two-analyte correlation)
- z-score run charts (per laboratory and per round)
- Kernel density / histogram overlays
- Cumulative performance trend charts
- Mandel's h and k statistics charts for within-/between-laboratory variance
- Report Generation — Downloadable HTML/PDF performance certificates and summary statistics tables.
- Multi-round Tracking — Longitudinal tracking of individual laboratory performance across PT rounds.
- Regulatory Alignment — Built-in pass/fail thresholds from CNAS CL01-A026 and GB/T 27418-2017.
The following ISO 13528 / GB/T 27418-2017 methods are implemented or planned:
| Method | Purpose |
|---|---|
| Robust mean (Algorithm A) | Derive assigned value resistant to outliers |
| Robust standard deviation (Algorithm A) | Derive σ_pt for z-score denominator |
| Hampel estimators (median/NIQR) | Alternative robust location and spread estimates |
| z-score | Standardised performance score: z = (x − x̂) / σ_pt |
| z′-score | z-score adjusted for measurement uncertainty of the assigned value |
| ζ-score | Performance score incorporating laboratory measurement uncertainty |
| En number | Performance score relative to a reference laboratory result |
| Mandel's h statistic | Between-laboratory consistency check |
| Mandel's k statistic | Within-laboratory repeatability check |
Performance criteria follow CNAS CL01-A026: |z| ≤ 2 → satisfactory; 2 < |z| < 3 → questionable; |z| ≥ 3 → unsatisfactory.
- R ≥ 4.2.0 (required for the native pipe operator
|>used throughout the codebase and for{shinydashboard}≥ 0.7.2) - The following R packages:
install.packages(c(
"shiny",
"shinydashboard",
"ggplot2",
"dplyr",
"tidyr",
"readxl",
"DT",
"rmarkdown",
"knitr",
"plotly"
))# Clone the repository
# setwd to project root, then:
shiny::runApp("app")Or launch directly from RStudio by opening app/app.R and clicking Run App.
| Column | Description | Example |
|---|---|---|
lab_id |
Laboratory identifier | LAB001 |
round |
PT round identifier | 2024-01 |
analyte |
Analyte name | Cyclosporine A |
result |
Measured result | 120.5 |
unit |
Measurement unit | ng/mL |
method |
Analytical method (optional) | CMIA |
PTP_proj/
├── app/
│ ├── app.R # Main Shiny application entry point
│ ├── ui.R # Dashboard UI (sidebar + tab layout)
│ ├── server.R # Server: calls Shiny modules
│ └── modules/
│ └── mod_sample_randomization.R # Part 1: sample randomization module
├── R/
│ └── randomization.R # Core randomization functions (ISO 13528 / GB/T 27418)
├── tests/
│ └── testthat/
│ └── test_randomization.R # Unit tests for randomization functions
├── data/ # (placeholder for example datasets)
├── docs/
│ └── references/ # (placeholder for regulatory documents)
├── .gitignore
└── README.md
Contributions are welcome! Please:
- Fork the repository and create a feature branch.
- Follow the tidyverse style guide for R code.
- Add or update unit tests for any new statistical methods.
- Submit a pull request with a clear description of your changes.
Bug reports and feature requests can be filed via GitHub Issues.
This project is released under the MIT License. See LICENSE for details.
The statistical methodology is based on:
- ISO 13528:2022 (© ISO — all rights reserved)
- GB/T 27418-2017 (© SAC — all rights reserved)
- CNAS documents (© CNAS — all rights reserved)
Copies or summaries of these standards included in this repository are for informational and educational purposes only.