Lab unit harmonization

From XuShuwenn/RedAct · View interactive version

Lab unit harmonization is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Harmonize clinical lab data from multiple sources with different units, handling scientific notation and decimal format issues.

How to use this skill

Skill file

Clinical Lab Unit Harmonization

When to Use

Input Files

Before coding, inspect both files beyond the header. Read enough of ckd_lab_data.csv to see actual numeric encodings/issues, and read ckd_feature_descriptions.csv completely enough to cover every feature you will claim to harmonize. If a view is truncated, keep reading/searching until you confirm the relevant columns, documented units, and ranges. Do not invent dataset-wide conversion rules from partial reference information.

Data Quality Issues

  1. Missing values → remove patient rows
  2. Scientific notation → convert 1.23e2 to 123.00
  3. Decimal commas → 12,34 → 12.34
  4. Mixed units → convert alternative units to standard (e.g., µmol/L → mg/dL)

Harmonization Steps

  1. Inspect the full schema, feature descriptions, and representative raw values before defining cleaning or conversion rules
  2. Normalize raw numeric text first: scientific notation, decimal commas, whitespace, and other non-canonical numeric strings
  3. Convert normalized values to numeric and mark unparsable entries as missing
  4. Remove rows with missing values after parsing/normalization
  5. Detect values that may indicate alternate units using observed distributions plus physiological expectations; do not hard-code thresholds from feature names alone or widen ranges just to silence warnings
  6. Apply conversion factors only when supported by feature metadata, explicit units, or clear dataset-wide evidence; confirm the source→target direction and analyte-specific factor before bulk conversion
  7. Re-check plausibility after conversion using fixed acceptance criteria; if values remain implausible, investigate the logic and drop/flag unresolved cases per task requirements rather than forcing a pass
  8. Round all values to 2 decimal places (X.XX)
  9. Validate the final saved CSV across the entire dataset before declaring success

Output

/root/ckd_lab_data_harmonized.csv:

Verification requirements before finishing:

Output

Validation and Completion

Tips

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.