Datasets:
Upload folder using huggingface_hub
Browse files- README.md +65 -0
- data/hiv_vl_cd4_no_vl_access.csv +0 -0
- data/hiv_vl_cd4_vl_accessible.csv +0 -0
- data/hiv_vl_cd4_vl_limited.csv +0 -0
- generate_dataset.py +176 -0
- requirements.txt +3 -0
- validate_dataset.py +83 -0
- validation_report.png +3 -0
README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
task_categories:
|
| 4 |
+
- tabular-classification
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
tags:
|
| 8 |
+
- laboratory
|
| 9 |
+
- HIV
|
| 10 |
+
- viral-load
|
| 11 |
+
- CD4
|
| 12 |
+
- ART-monitoring
|
| 13 |
+
- synthetic
|
| 14 |
+
- sub-saharan-africa
|
| 15 |
+
pretty_name: HIV Viral Load & CD4 Testing
|
| 16 |
+
size_categories:
|
| 17 |
+
- 10K<n<100K
|
| 18 |
+
configs:
|
| 19 |
+
- config_name: vl_accessible
|
| 20 |
+
data_files: data/hiv_vl_cd4_vl_accessible.csv
|
| 21 |
+
- config_name: vl_limited
|
| 22 |
+
data_files: data/hiv_vl_cd4_vl_limited.csv
|
| 23 |
+
default: true
|
| 24 |
+
- config_name: no_vl_access
|
| 25 |
+
data_files: data/hiv_vl_cd4_no_vl_access.csv
|
| 26 |
+
---
|
| 27 |
+
|
| 28 |
+
# HIV Viral Load & CD4 Testing
|
| 29 |
+
|
| 30 |
+
## Abstract
|
| 31 |
+
|
| 32 |
+
Synthetic dataset modeling HIV viral load and CD4 laboratory services across three SSA scenarios. Captures VL/CD4 test availability, platforms (conventional/POC/DBS), results, turnaround times, clinical actions (EAC, regimen switch), and quality indicators. Parameterized from WHO/UNAIDS guidelines and SSA implementation research.
|
| 33 |
+
|
| 34 |
+
## Parameterization Evidence
|
| 35 |
+
|
| 36 |
+
| Parameter | Value | Source | Year |
|
| 37 |
+
| --- | --- | --- | --- |
|
| 38 |
+
| VL coverage SSA | 17% to 71% (2015-2019) | Lecher et al. MMWR | 2021 |
|
| 39 |
+
| VL suppression on ART | 76% SSA | UNAIDS | 2023 |
|
| 40 |
+
| Conventional VL TAT | 2-6 weeks | Jani et al. Lancet HIV | 2016 |
|
| 41 |
+
| POC VL TAT | 1-3 hours | Jani et al. | 2016 |
|
| 42 |
+
| SSA PLHIV on ART | 21M / 25.6M | UNAIDS | 2023 |
|
| 43 |
+
|
| 44 |
+
## Validation
|
| 45 |
+
|
| 46 |
+

|
| 47 |
+
|
| 48 |
+
## Usage
|
| 49 |
+
|
| 50 |
+
```python
|
| 51 |
+
from datasets import load_dataset
|
| 52 |
+
ds = load_dataset("electricsheepafrica/hiv-viral-load-cd4", name="vl_limited")
|
| 53 |
+
df = ds['train'].to_pandas()
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## References
|
| 57 |
+
|
| 58 |
+
1. WHO (2023). HIV treatment guidelines
|
| 59 |
+
2. UNAIDS (2023). Global HIV statistics
|
| 60 |
+
3. Lecher SL et al. (2021). VL monitoring scale-up. *MMWR*. DOI: 10.15585/mmwr.mm7034a2
|
| 61 |
+
4. Jani IV et al. (2016). POC CD4 and VL. *Lancet HIV*. DOI: 10.1016/S2352-3018(15)00236-X
|
| 62 |
+
|
| 63 |
+
## License
|
| 64 |
+
|
| 65 |
+
CC-BY-4.0
|
data/hiv_vl_cd4_no_vl_access.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/hiv_vl_cd4_vl_accessible.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/hiv_vl_cd4_vl_limited.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
generate_dataset.py
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
HIV Viral Load & CD4 Testing Dataset
|
| 4 |
+
========================================
|
| 5 |
+
Each record = ONE HIV viral load or CD4 test request/result.
|
| 6 |
+
|
| 7 |
+
Literature-Grounded Parameterization:
|
| 8 |
+
[1] WHO (2023). HIV treatment guidelines.
|
| 9 |
+
- VL preferred monitoring; target <1000 copies/mL
|
| 10 |
+
- CD4 for staging and OI prophylaxis
|
| 11 |
+
- VL coverage SSA: ~70% of ART patients
|
| 12 |
+
|
| 13 |
+
[2] UNAIDS (2023). Global HIV statistics.
|
| 14 |
+
- SSA: 25.6M PLHIV, 21M on ART
|
| 15 |
+
- VL suppression: 76% of those on ART
|
| 16 |
+
|
| 17 |
+
[3] Lecher SL et al. (2021). Scale-up HIV VL monitoring.
|
| 18 |
+
MMWR. DOI: 10.15585/mmwr.mm7034a2
|
| 19 |
+
- VL coverage 17% to 71% (2015-2019)
|
| 20 |
+
- Centralized testing: TAT weeks
|
| 21 |
+
|
| 22 |
+
[4] Jani IV et al. (2016). POC CD4 and VL testing.
|
| 23 |
+
Lancet HIV. DOI: 10.1016/S2352-3018(15)00236-X
|
| 24 |
+
- POC reduces loss to follow-up
|
| 25 |
+
- Conventional VL TAT: 2-6 weeks
|
| 26 |
+
- POC VL TAT: 1-3 hours
|
| 27 |
+
- DBS for sample transport
|
| 28 |
+
"""
|
| 29 |
+
import numpy as np, pandas as pd, argparse, os
|
| 30 |
+
|
| 31 |
+
SCENARIOS = {
|
| 32 |
+
'vl_accessible': {
|
| 33 |
+
'exemplar': 'South Africa/Botswana/Kenya (urban)',
|
| 34 |
+
'vl_coverage': 0.75,
|
| 35 |
+
'cd4_available': 0.85,
|
| 36 |
+
'poc_vl_available': 0.20,
|
| 37 |
+
'dbs_used': 0.15,
|
| 38 |
+
'conventional_vl': 0.65,
|
| 39 |
+
'vl_suppression_rate': 0.80,
|
| 40 |
+
'cd4_median_on_art': 450,
|
| 41 |
+
'tat_vl_days': 7,
|
| 42 |
+
'tat_cd4_days': 1,
|
| 43 |
+
'eac_for_unsuppressed': 0.60,
|
| 44 |
+
'result_returned_patient': 0.70,
|
| 45 |
+
'reagent_stockout': 0.10,
|
| 46 |
+
},
|
| 47 |
+
'vl_limited': {
|
| 48 |
+
'exemplar': 'Kenya (district)/Ghana/Tanzania/Ethiopia',
|
| 49 |
+
'vl_coverage': 0.35,
|
| 50 |
+
'cd4_available': 0.50,
|
| 51 |
+
'poc_vl_available': 0.05,
|
| 52 |
+
'dbs_used': 0.30,
|
| 53 |
+
'conventional_vl': 0.25,
|
| 54 |
+
'vl_suppression_rate': 0.72,
|
| 55 |
+
'cd4_median_on_art': 380,
|
| 56 |
+
'tat_vl_days': 21,
|
| 57 |
+
'tat_cd4_days': 3,
|
| 58 |
+
'eac_for_unsuppressed': 0.30,
|
| 59 |
+
'result_returned_patient': 0.40,
|
| 60 |
+
'reagent_stockout': 0.30,
|
| 61 |
+
},
|
| 62 |
+
'no_vl_access': {
|
| 63 |
+
'exemplar': 'DRC/CAR/Sierra Leone/Niger (rural)',
|
| 64 |
+
'vl_coverage': 0.08,
|
| 65 |
+
'cd4_available': 0.15,
|
| 66 |
+
'poc_vl_available': 0.01,
|
| 67 |
+
'dbs_used': 0.05,
|
| 68 |
+
'conventional_vl': 0.05,
|
| 69 |
+
'vl_suppression_rate': 0.60,
|
| 70 |
+
'cd4_median_on_art': 300,
|
| 71 |
+
'tat_vl_days': 45,
|
| 72 |
+
'tat_cd4_days': 14,
|
| 73 |
+
'eac_for_unsuppressed': 0.10,
|
| 74 |
+
'result_returned_patient': 0.15,
|
| 75 |
+
'reagent_stockout': 0.55,
|
| 76 |
+
},
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
def generate_dataset(n=10000, seed=42, scenario='vl_limited'):
|
| 80 |
+
rng = np.random.default_rng(seed)
|
| 81 |
+
sc = SCENARIOS[scenario]
|
| 82 |
+
records = []
|
| 83 |
+
for idx in range(n):
|
| 84 |
+
rec = {'id': idx + 1}
|
| 85 |
+
rec['age'] = int(np.clip(rng.normal(38, 12), 1, 80))
|
| 86 |
+
rec['sex'] = rng.choice(['male','female'], p=[0.38, 0.62])
|
| 87 |
+
rec['pregnant'] = 1 if (rec['sex']=='female' and 15<=rec['age']<=45 and rng.random()<0.08) else 0
|
| 88 |
+
rec['facility_level'] = rng.choice(['tertiary','district','health_centre','clinic'],
|
| 89 |
+
p=[0.10, 0.25, 0.35, 0.30])
|
| 90 |
+
rec['on_art'] = 1 if rng.random() < 0.85 else 0
|
| 91 |
+
rec['art_duration_months'] = int(rng.exponential(36)) if rec['on_art'] else 0
|
| 92 |
+
rec['art_regimen'] = rng.choice(['TLD','TLE','AZT_based','PI_based','other'],
|
| 93 |
+
p=[0.40, 0.25, 0.15, 0.10, 0.10]) if rec['on_art'] else 'none'
|
| 94 |
+
|
| 95 |
+
# Test type ordered
|
| 96 |
+
rec['vl_ordered'] = 1 if rng.random() < sc['vl_coverage'] else 0
|
| 97 |
+
rec['cd4_ordered'] = 1 if rng.random() < sc['cd4_available'] else 0
|
| 98 |
+
|
| 99 |
+
# VL testing
|
| 100 |
+
tier = 1.3 if rec['facility_level'] in ['tertiary','district'] else 0.7
|
| 101 |
+
if rec['vl_ordered']:
|
| 102 |
+
rec['vl_platform'] = rng.choice(['conventional_central','poc_vl','dbs_referred'],
|
| 103 |
+
p=[sc['conventional_vl']*tier/(sc['conventional_vl']*tier+sc['poc_vl_available']+sc['dbs_used']+0.01),
|
| 104 |
+
sc['poc_vl_available']/(sc['conventional_vl']*tier+sc['poc_vl_available']+sc['dbs_used']+0.01),
|
| 105 |
+
(sc['dbs_used']+0.01)/(sc['conventional_vl']*tier+sc['poc_vl_available']+sc['dbs_used']+0.01)])
|
| 106 |
+
if rec['on_art']:
|
| 107 |
+
suppressed = rng.random() < sc['vl_suppression_rate']
|
| 108 |
+
if suppressed:
|
| 109 |
+
rec['vl_result'] = int(np.clip(rng.exponential(50), 0, 999))
|
| 110 |
+
else:
|
| 111 |
+
rec['vl_result'] = int(np.clip(rng.lognormal(np.log(5000), 1.5), 1000, 500000))
|
| 112 |
+
else:
|
| 113 |
+
rec['vl_result'] = int(np.clip(rng.lognormal(np.log(50000), 1.2), 1000, 1000000))
|
| 114 |
+
rec['vl_suppressed'] = 1 if rec['vl_result'] < 1000 else 0
|
| 115 |
+
rec['vl_tat_days'] = round(max(0.1, rng.lognormal(
|
| 116 |
+
np.log(0.1 if rec['vl_platform']=='poc_vl' else sc['tat_vl_days']), 0.5)), 1)
|
| 117 |
+
else:
|
| 118 |
+
rec['vl_platform'] = 'not_done'
|
| 119 |
+
rec['vl_result'] = np.nan
|
| 120 |
+
rec['vl_suppressed'] = np.nan
|
| 121 |
+
rec['vl_tat_days'] = np.nan
|
| 122 |
+
|
| 123 |
+
# CD4 testing
|
| 124 |
+
if rec['cd4_ordered']:
|
| 125 |
+
rec['cd4_platform'] = rng.choice(['flow_cytometry','poc_cd4','manual'],
|
| 126 |
+
p=[0.40, 0.30, 0.30] if sc['cd4_available']>0.5 else [0.15, 0.25, 0.60])
|
| 127 |
+
if rec['on_art']:
|
| 128 |
+
rec['cd4_result'] = int(np.clip(rng.normal(sc['cd4_median_on_art'], 180), 10, 1500))
|
| 129 |
+
else:
|
| 130 |
+
rec['cd4_result'] = int(np.clip(rng.lognormal(np.log(200), 0.7), 5, 800))
|
| 131 |
+
rec['cd4_below_200'] = 1 if rec['cd4_result'] < 200 else 0
|
| 132 |
+
rec['cd4_tat_days'] = round(max(0.1, rng.lognormal(np.log(sc['tat_cd4_days']), 0.5)), 1)
|
| 133 |
+
else:
|
| 134 |
+
rec['cd4_platform'] = 'not_done'
|
| 135 |
+
rec['cd4_result'] = np.nan
|
| 136 |
+
rec['cd4_below_200'] = np.nan
|
| 137 |
+
rec['cd4_tat_days'] = np.nan
|
| 138 |
+
|
| 139 |
+
# Clinical actions
|
| 140 |
+
rec['result_returned'] = 1 if rng.random() < sc['result_returned_patient'] else 0
|
| 141 |
+
rec['eac_provided'] = 1 if (rec['vl_ordered'] and rec.get('vl_suppressed')==0 and rng.random() < sc['eac_for_unsuppressed']) else 0
|
| 142 |
+
rec['regimen_switch'] = 1 if (rec['vl_ordered'] and rec.get('vl_suppressed')==0 and rng.random() < 0.15) else 0
|
| 143 |
+
rec['oi_prophylaxis'] = 1 if (rec['cd4_ordered'] and rec.get('cd4_below_200')==1 and rng.random() < 0.65) else 0
|
| 144 |
+
|
| 145 |
+
# Quality
|
| 146 |
+
rec['reagent_stockout'] = 1 if rng.random() < sc['reagent_stockout'] else 0
|
| 147 |
+
rec['sample_rejected'] = 1 if rng.random() < 0.04 else 0
|
| 148 |
+
rec['test_not_done_stockout'] = 1 if (rec['reagent_stockout'] and rng.random() < 0.40) else 0
|
| 149 |
+
rec['specimen_transport_issue'] = 1 if (rec.get('vl_platform') in ['dbs_referred','conventional_central'] and rng.random() < 0.12) else 0
|
| 150 |
+
|
| 151 |
+
rec['year'] = rng.choice([2019,2020,2021,2022,2023], p=[0.12,0.18,0.20,0.25,0.25])
|
| 152 |
+
records.append(rec)
|
| 153 |
+
|
| 154 |
+
df = pd.DataFrame(records)
|
| 155 |
+
print(f"\n{'='*60}\nHIV Viral Load & CD4 — {scenario} ({sc['exemplar']})")
|
| 156 |
+
print(f" VL ordered: {df['vl_ordered'].mean()*100:.1f}% | CD4 ordered: {df['cd4_ordered'].mean()*100:.1f}%")
|
| 157 |
+
vl_done = df[df['vl_ordered']==1]
|
| 158 |
+
if len(vl_done)>0: print(f" VL suppressed: {vl_done['vl_suppressed'].mean()*100:.1f}% | VL TAT median: {vl_done['vl_tat_days'].median():.1f}d")
|
| 159 |
+
print(f" Result returned: {df['result_returned'].mean()*100:.1f}% | Stockout: {df['reagent_stockout'].mean()*100:.1f}%")
|
| 160 |
+
return df
|
| 161 |
+
|
| 162 |
+
if __name__ == '__main__':
|
| 163 |
+
parser = argparse.ArgumentParser()
|
| 164 |
+
parser.add_argument('--all-scenarios', action='store_true')
|
| 165 |
+
parser.add_argument('--n', type=int, default=10000)
|
| 166 |
+
parser.add_argument('--seed', type=int, default=42)
|
| 167 |
+
args = parser.parse_args()
|
| 168 |
+
os.makedirs('data', exist_ok=True)
|
| 169 |
+
if args.all_scenarios:
|
| 170 |
+
for sc in SCENARIOS:
|
| 171 |
+
df = generate_dataset(n=args.n, seed=args.seed, scenario=sc)
|
| 172 |
+
df.to_csv(os.path.join('data', f'hiv_vl_cd4_{sc}.csv'), index=False)
|
| 173 |
+
print(f" -> Saved\n")
|
| 174 |
+
else:
|
| 175 |
+
df = generate_dataset(n=args.n, seed=args.seed)
|
| 176 |
+
df.to_csv(os.path.join('data', 'hiv_vl_cd4_vl_limited.csv'), index=False)
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy>=1.24
|
| 2 |
+
pandas>=2.0
|
| 3 |
+
matplotlib>=3.7
|
validate_dataset.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Validation for HIV Viral Load & CD4 Testing Dataset."""
|
| 3 |
+
import pandas as pd, numpy as np, matplotlib.pyplot as plt, os, glob
|
| 4 |
+
|
| 5 |
+
def load_scenarios(data_dir='data'):
|
| 6 |
+
dfs = {}
|
| 7 |
+
for f in sorted(glob.glob(os.path.join(data_dir, 'hiv_vl_cd4_*.csv'))):
|
| 8 |
+
name = os.path.basename(f).replace('.csv', '')[11:]
|
| 9 |
+
dfs[name] = pd.read_csv(f)
|
| 10 |
+
return dfs
|
| 11 |
+
|
| 12 |
+
def main():
|
| 13 |
+
dfs = load_scenarios()
|
| 14 |
+
if not dfs: return
|
| 15 |
+
all_df = pd.concat([df.assign(scenario=n) for n, df in dfs.items()], ignore_index=True)
|
| 16 |
+
fig, axes = plt.subplots(4, 2, figsize=(16, 20))
|
| 17 |
+
fig.suptitle('HIV Viral Load & CD4 Testing — Validation Report', fontsize=14, fontweight='bold', y=0.98)
|
| 18 |
+
colors = {'vl_accessible': '#2ecc71', 'vl_limited': '#f39c12', 'no_vl_access': '#e74c3c'}
|
| 19 |
+
labels = {'vl_accessible': 'VL Access (SA/BW)', 'vl_limited': 'Limited (KE/GH/TZ)', 'no_vl_access': 'None (DRC/SLE)'}
|
| 20 |
+
scenarios = list(dfs.keys())
|
| 21 |
+
|
| 22 |
+
ax = axes[0, 0]
|
| 23 |
+
metrics = ['VL Ordered %', 'CD4 Ordered %', 'Result\nReturned %', 'EAC %', 'Stockout %']
|
| 24 |
+
for i, s in enumerate(scenarios):
|
| 25 |
+
d = dfs[s]; vals = [d['vl_ordered'].mean()*100, d['cd4_ordered'].mean()*100, d['result_returned'].mean()*100, d['eac_provided'].mean()*100, d['reagent_stockout'].mean()*100]
|
| 26 |
+
ax.bar(np.arange(len(metrics))+i*0.25, vals, 0.25, label=labels.get(s,s), color=colors[s], alpha=0.8)
|
| 27 |
+
ax.set_xticks(np.arange(len(metrics))+0.25); ax.set_xticklabels(metrics, fontsize=6); ax.set_ylabel('%'); ax.set_title('Panel 1: Key Metrics'); ax.legend(fontsize=6)
|
| 28 |
+
|
| 29 |
+
ax = axes[0, 1]
|
| 30 |
+
for s in scenarios:
|
| 31 |
+
vl = dfs[s][dfs[s]['vl_ordered']==1]['vl_result'].dropna()
|
| 32 |
+
if len(vl) > 0: ax.hist(np.log10(vl.clip(lower=1)), bins=25, alpha=0.5, label=labels.get(s,s), color=colors[s], density=True)
|
| 33 |
+
ax.axvline(3, color='black', linestyle='--', alpha=0.5, label='1000 cp/mL')
|
| 34 |
+
ax.set_xlabel('Log10 VL (copies/mL)'); ax.set_title('Panel 2: Viral Load Distribution'); ax.legend(fontsize=7)
|
| 35 |
+
|
| 36 |
+
ax = axes[1, 0]
|
| 37 |
+
for s in scenarios:
|
| 38 |
+
cd4 = dfs[s][dfs[s]['cd4_ordered']==1]['cd4_result'].dropna()
|
| 39 |
+
if len(cd4) > 0: ax.hist(cd4.clip(upper=1000), bins=25, alpha=0.5, label=labels.get(s,s), color=colors[s], density=True)
|
| 40 |
+
ax.axvline(200, color='black', linestyle='--', alpha=0.5, label='200 cells')
|
| 41 |
+
ax.set_xlabel('CD4 (cells/uL)'); ax.set_title('Panel 3: CD4 Distribution'); ax.legend(fontsize=7)
|
| 42 |
+
|
| 43 |
+
ax = axes[1, 1]
|
| 44 |
+
for s in scenarios:
|
| 45 |
+
vl_tat = dfs[s][dfs[s]['vl_ordered']==1]['vl_tat_days'].dropna()
|
| 46 |
+
if len(vl_tat) > 0: ax.hist(vl_tat.clip(upper=60), bins=25, alpha=0.5, label=labels.get(s,s), color=colors[s], density=True)
|
| 47 |
+
ax.set_xlabel('VL TAT (days)'); ax.set_title('Panel 4: VL Turnaround Time'); ax.legend(fontsize=7)
|
| 48 |
+
|
| 49 |
+
ax = axes[2, 0]
|
| 50 |
+
plats = ['conventional_central','poc_vl','dbs_referred','not_done']
|
| 51 |
+
for i, s in enumerate(scenarios):
|
| 52 |
+
vals = [dfs[s]['vl_platform'].value_counts(normalize=True).get(p,0)*100 for p in plats]
|
| 53 |
+
ax.bar(np.arange(len(plats))+i*0.25, vals, 0.25, label=labels.get(s,s), color=colors[s], alpha=0.8)
|
| 54 |
+
ax.set_xticks(np.arange(len(plats))+0.25); ax.set_xticklabels([p.replace('_','\n') for p in plats], fontsize=5); ax.set_ylabel('%'); ax.set_title('Panel 5: VL Platform'); ax.legend(fontsize=6)
|
| 55 |
+
|
| 56 |
+
ax = axes[2, 1]
|
| 57 |
+
acts = ['EAC', 'Regimen\nSwitch', 'OI\nProphylaxis', 'Transport\nIssue', 'Sample\nRejected']
|
| 58 |
+
for i, s in enumerate(scenarios):
|
| 59 |
+
d = dfs[s]; vals = [d['eac_provided'].mean()*100, d['regimen_switch'].mean()*100, d['oi_prophylaxis'].mean()*100, d['specimen_transport_issue'].mean()*100, d['sample_rejected'].mean()*100]
|
| 60 |
+
ax.bar(np.arange(len(acts))+i*0.25, vals, 0.25, label=labels.get(s,s), color=colors[s], alpha=0.8)
|
| 61 |
+
ax.set_xticks(np.arange(len(acts))+0.25); ax.set_xticklabels(acts, fontsize=5); ax.set_ylabel('%'); ax.set_title('Panel 6: Clinical Actions & Issues'); ax.legend(fontsize=6)
|
| 62 |
+
|
| 63 |
+
ax = axes[3, 0]
|
| 64 |
+
regs = ['TLD','TLE','AZT_based','PI_based','none']
|
| 65 |
+
for i, s in enumerate(scenarios):
|
| 66 |
+
vals = [dfs[s]['art_regimen'].value_counts(normalize=True).get(r,0)*100 for r in regs]
|
| 67 |
+
ax.bar(np.arange(len(regs))+i*0.20, vals, 0.20, label=labels.get(s,s), color=colors[s], alpha=0.8)
|
| 68 |
+
ax.set_xticks(np.arange(len(regs))+0.20); ax.set_xticklabels(regs, fontsize=6); ax.set_ylabel('%'); ax.set_title('Panel 7: ART Regimen'); ax.legend(fontsize=6)
|
| 69 |
+
|
| 70 |
+
ax = axes[3, 1]
|
| 71 |
+
num_cols = ['vl_ordered','cd4_ordered','result_returned','reagent_stockout','eac_provided','on_art']
|
| 72 |
+
corr = all_df[num_cols].corr()
|
| 73 |
+
im = ax.imshow(corr, cmap='RdBu_r', vmin=-1, vmax=1, aspect='auto')
|
| 74 |
+
ax.set_xticks(range(len(num_cols))); ax.set_yticks(range(len(num_cols)))
|
| 75 |
+
ax.set_xticklabels([c.replace('_','\n') for c in num_cols], fontsize=5, rotation=45, ha='right')
|
| 76 |
+
ax.set_yticklabels([c.replace('_','\n') for c in num_cols], fontsize=5)
|
| 77 |
+
ax.set_title('Panel 8: Correlation Heatmap'); fig.colorbar(im, ax=ax, fraction=0.046)
|
| 78 |
+
|
| 79 |
+
plt.tight_layout(rect=[0,0,1,0.96]); plt.savefig('validation_report.png', dpi=150, bbox_inches='tight'); plt.close()
|
| 80 |
+
print("Saved validation_report.png")
|
| 81 |
+
|
| 82 |
+
if __name__ == '__main__':
|
| 83 |
+
main()
|
validation_report.png
ADDED
|
Git LFS Details
|