TL;DR
Electronic health records (EHRs) are a treasure trove of health data, but analyzing them is hindered by their heterogeneity and complexity. This paper introduces ehrapy, a new open-source Python framework that provides a standardized, modular, and extensible pipeline for end-to-end exploratory analysis of EHR data, making it easier to uncover insights and build foundational models in biomedical research.
What Problem Does This Paper Address?
The increasing digitalization of healthcare systems has led to the massive collection of electronic health records (EHRs). However, analyzing this data is a significant challenge due to its inherent heterogeneity. EHRs come in various formats, contain diverse data types (demographics, lab results, imaging, notes, etc.), and suffer from issues like missing data, inconsistencies, and biases. Existing analysis pipelines are often fragmented, vendor-specific, or lack comprehensive features for exploratory analysis. This gap prevents researchers from fully leveraging EHR data for comprehensive insights, leading to underexplored datasets and potentially biased or inaccurate findings. The authors aim to bridge this gap by providing a unified, open-source framework that addresses these challenges.
Methods
ehrapy is built as a modular Python framework designed for exploratory EHR data analysis. Its core components include:
- Data Ingestion and Preparation: It can read various data formats (CSV, OMOP, SQL) and stores them in the
AnnDataobject, a standard for single-cell omics data, ensuring compatibility with existing tools. It includes modules for quality control, imputation (e.g., KNN, MissForest), and data encoding (One-Hot, Label Encoding). - Dimensionality Reduction and Visualization:
ehrapyleverages established methods like PCA, t-SNE, and UMAP for creating lower-dimensional representations of complex data, enabling visualization of patient landscapes. - Statistical Analysis Modules: It offers a rich set of statistical tools for differential comparisons between patient clusters, survival analysis (Kaplan-Meier, Cox Hazard Models), and causal inference (based on the
dowhylibrary). - Ontology Integration:
ehrapycan map data against ontologies and extract key terms from free text notes, facilitating semantic understanding. - Extensibility: The modular design allows for easy integration of community software packages and extension for new challenges, such as training deep learning models.
What's new is the integration of these diverse functionalities into a single, cohesive, and user-friendly framework specifically tailored for the complexities of EHR data, building upon established omics data standards.
Datasets
The framework was developed and demonstrated using several publicly available datasets:
- Pediatric Intensive Care (PIC) database: Used for stratifying pneumonia patients and analyzing medication effects.
- UK Biobank (UKB): A large population-scale cohort used for analyzing cardiovascular risks across multiple data modalities (genomics, metabolomics, imaging).
- BrixIA dataset: Used for analyzing COVID-19 chest X-ray images and reconstructing disease trajectories.
- Diabetes 130-US Hospitals dataset: Used to demonstrate bias detection and mitigation in EHR data.
- MIMIC-II: Mentioned as an additional use case.
Key Insights and Ideas
- Standardization is Key: The
AnnDataobject, commonly used in single-cell genomics, provides a robust and versatile structure for handling heterogeneous EHR data, enabling seamless integration with existing omics analysis tools. - Bias is Pervasive: EHR data is rife with various biases (selection, surveillance, information, etc.) that can significantly skew results.
ehrapyprovides tools to detect and, in some cases, mitigate these biases. - Multimodality is Powerful: Combining data from different sources (clinical, imaging, genomics, metabolomics) significantly improves predictive performance for complex diseases.
- Trajectory Inference for Disease Progression: Advanced methods like pseudotime ordering can be adapted from omics to reconstruct and understand disease progression from sequential EHR data, even from imaging.
- Causal Inference for Treatment Effects:
ehrapyfacilitates moving beyond associations to quantify the causal effects of interventions (like medication classes) on outcomes (like length of stay).
Key Results
- Pneumonia Phenotyping:
ehrapysuccessfully stratified patients with "unspecified pneumonia" into four distinct clinically relevant groups ('sepsis-like', 'severe pneumonia with co-infection', 'viral pneumonia', 'mild pneumonia'), revealing associated biomarkers and survival differences. - Medication Effects: Quantified medication-class effects on length of stay, finding that corticosteroids, antivirals, and carbapenems were associated with shorter ICU stays, while penicillins and cephalosporins were associated with longer stays.
- Cardiovascular Risk Prediction: In the UK Biobank, combining multiple modalities (genetics, clinical data, imaging) improved the predictive performance for myocardial infarction, achieving a C-index of 0.81.
- COVID-19 Severity Trajectories: Disease severity trajectories were successfully reconstructed from chest X-ray images, demonstrating the ability to order cases from mild to critical.
- Bias Detection: Identified and demonstrated mitigation of selection and surveillance biases in the Diabetes 130-US Hospitals dataset, and showed how normalization strategies can mask or reveal important differences.
Limitations and Future Work
- Data Quality and Completeness: Limitations include the lack of control for informative missingness, potential information loss from translation (PIC database), incompleteness of certain data types (e.g., radiology images in PIC), and underrepresentation of certain demographic groups.
- Generalizability: The generalizability of findings is limited by the specific datasets used and potential biases inherent in population-based cohorts (e.g., UK Biobank).
- Causal Inference Constraints: The causal inference use case was limited by missing variables (e.g., SOFA scores) and potential dataset constraints.
- Future Work: The authors envision
ehrapyevolving to support joint analysis of EHR, genetics, and molecular data, develop EHR-specific reference datasets, and incorporate more advanced modules for time-series data and natural language processing. They also aim to improve out-of-core computation for large datasets and support the development of foundational models for medical AI.
Summary updated