Текст сохранён. Часть иллюстраций пока доступна только в первоисточнике; загрузка будет проверена повторно.
Introduction
Multiple Sclerosis (MS) is a chronic autoimmune disease characterized by inflammatory demyelination and progressive neurodegeneration in the central nervous system, leading to neurological impairments [ 1 ]. Affecting millions of people worldwide, MS diminishes individual quality of life and creates disproportionately high societal healthcare burdens [ 2 ], partly driven by the cost of disease-modifying therapies (DMTs). Given the wide range of DMT options and variability in clinical practices, robust methods for examining long-term DMT prescription trends are essential. Such approaches can evaluate real-world adoption of clinical guidelines, identify gaps in patient access to DMTs, inform clinicians of emerging therapeutic patterns across demographic or clinical subgroups, guide healthcare systems in resource planning ( e.g., building infusion centers), assist payers in coverage decisions for expanding DMT options, and ultimately contribute to the long-term real-world evidence for DMT effectiveness, safety, and adherence.
Accurate classification of MS cases through robust phenotyping using routine clinical data from electronic health records (EHR) is essential for generating large-scale real-world evidence, given the spectrum of MS presentation and variability in clinical documentation. Traditional rule-based algorithms often rely on limited structured data, such as diagnostic codes or medication history, which can result in misclassification and reduced generalizability across healthcare systems [ 3 – 6 ]. KOMAP (Knowledge-driven Online Multimodal Automated Phenotyping) addresses these limitations by integrating codified data ( e.g. , ICD codes, medication records) with unstructured data ( e.g. , clinical notes) through ontological mapping (to common features) and machine learning [ 7 ]. By leveraging multimodal features and preserving clinical context, KOMAP enables robust and scalable MS phenotyping across diverse EHR systems, facilitating accurate identification of patient cohorts for observational research and precision medicine efforts.
Over the years, the MS treatment landscape has evolved significantly, with new drugs being introduced and their effectiveness re-evaluated as more clinical data become available [ 8 – 11 ]. The relationships between drugs and MS are dynamic, shaped by factors such as drug development, regulatory approvals, clinical guidelines, and emerging evidence from clinical trials and observational studies. This temporal variability highlights the importance of examining how these relationships change over time. A comprehensive, time-varying knowledge graph (KG) can support the systematic analysis of these evolving connections, offering a powerful tool to map MS profiles alongside the corresponding therapeutic landscape [ 12 , 13 ]. Such a KG can not only reveal historical trends but also support predictive modeling of future drug–disease interactions, ultimately contributing to a more informed and adaptive approach to MS management. While several studies have focused on constructing temporal KGs for EHR data applications, these works primarily emphasize tracking the dynamic progression of individual patients rather than capturing broader population-level developments [ 14 ].
In this study, we aim to construct a temporal KG of MS-related DMT usage among KOMAP-identified MS patients from two independent cohorts, capturing shifts in drug–disease relationships over the years. By analyzing these temporal patterns, we seek to uncover the underlying trends, thereby informing future investigations into the factors driving the evolving treatment paradigms for MS and supporting the development of targeted therapeutic interventions to advance precision medicine.
Methods
Ethics approval
The institutional review boards of the University of Pittsburgh (STUDY20070274 and STUDY21030127) approved the study protocols. The use of de-identified clinical data was deemed exempt.
Study design and datasets
Fig 1 illustrates the overall study design. We obtained EHR data from two large independent healthcare systems, UPMC (Pittsburgh, PA) and Mass General Brigham (MGB; Boston, MA), each comprising both academic and community practices as well as inpatient and outpatient records from multiple EHR platforms ( e.g. , Epic, Cerner) [ 15 – 19 ]. Both healthcare systems provided codified data from 2004–2022, encompassing demographics ( e.g. , age, sex, race, ethnicity), diagnosis and procedure codes ( e.g. , International Classification of Diseases [ICD] codes, Current Procedural Terminology [CPT] codes), healthcare utilization metrics ( e.g. , total number of ICD codes and encounter notes), medication history (e.g., RxNorm electronic prescriptions), and laboratory results ( e.g. , Logical Observation Identifiers Names and Codes [LOINC]). Furthermore, narrative text data from 2011–2022 were available, comprising free-text documentation from clinical encounters ( e.g. , physician office visit notes, discharge summaries), which were transformed into structured data using natural language processing (NLP). We constructed an MS data mart within each healthcare system consisting of patients with at least one ICD diagnosis code for MS as an initial step to enhance sensitivity.
Иллюстрация — в первоисточнике ↗
Dimensionality reduction of codified and narrative features
We standardized the codified data to ensure consistent representation of clinical concepts. Specifically, we mapped all ICD-9 and ICD-10 diagnosis codes to PheCodes [ 20 ], laboratory tests to LOINC [ 21 ], and prescriptions to ingredient-level RxNorm codes [ 22 ]. Procedure codes (CPT) were grouped using the Clinical Classifications Software for Services and Procedures. To extract standardized concepts from narrative clinical text, we applied a previously validated NLP pipeline, Narrative Information Linear Extraction (NILE) [ 23 ]. This pipeline generates concept unique identifiers (CUIs) based on the Unified Medical Language System (UMLS) [ 24 ].
Assigning and validating MS diagnosis
We applied a novel phenotyping algorithm, KOMAP, to determine MS diagnosis status (MS vs. non-MS) for all patients in the initial MS data mart [ 7 ]. KOMAP is an unsupervised, two-step algorithm designed to extract accurate diagnostic labels from EHR data. In the first step, KOMAP uses the Online Narrative and Codified feature Search engine ( i.e., ONCE), powered by multi-source KG representation learning, to identify informative codified and narrative features related to MS. In the second step, the algorithm is trained using the features selected by ONCE. These features include strong surrogate indicators of MS diagnosis ( e.g. , the primary MS PheCode from structured data and the main MS CUI from narrative data) along with a measure of healthcare utilization defined by the total number of ICD codes and clinical encounters. To evaluate model performance, we randomly split each cohort (UPMC and MGB) into 80% training and 20% test sets. Within the training set, we performed internal 5-fold cross-validation to tune hyperparameters and assess model stability. We reported performance metrics on the held-out test sets. We further validated KOMAP-assigned MS diagnoses against gold-standard chart-reviewed labels annotated by trained domain experts in randomly selected subsets of patients (n = 200 at UPMC; n = 100 at MGB).
We evaluated the performance of different feature sets ( i.e., main MS PheCode, main MS CUI, codified features alone [“codified”], and combined codified plus NLP-derived features [“both”]) across two healthcare systems, using models with main PheCode and main CUI as benchmarks. Performance was assessed using area under the receiver operating characteristic curve (AUROC), area under the precision-recall curve (AUPRC), and threshold-based sensitivity, positive predictive value (PPV), and negative predictive value (NPV) at predefined specificity levels (0.97, 0.95, and 0.90).
Temporal KG of MS-specific DMT usage
To enhance the generalizability and statistical power of our findings, we combined codified EHR data from UPMC and MGB. Merging these cohorts enabled the inclusion of a broader and more diverse patient population across geographic regions, demographic groups, and clinical practice patterns. This integration minimized site-specific biases and strengthened the robustness of identified trends and associations. Further, leveraging data from two distinct healthcare systems allowed for cross-system validation, increasing confidence in the reproducibility and external validity of our results.
Knowledge graph construction and sensitivity analysis
To construct the temporal KGs, we began by dividing the codified EHR data of KOMAP-classified MS patients from UPMC and MGB according to the calendar year in which each record was documented. For each year, a KG was created using the EHR data recorded during that period. A widely used approach for constructing KGs involves analyzing the occurrence and co-occurrence patterns of EHR codes. To extract meaningful relationships from the co-occurrence matrix, we applied the Shifted Positive Pointwise Mutual Information transformation and singular value decomposition (SPPMI-SVD) algorithm [ 25 ].
Specifically, for a given year t , we constructed the co-occurrence matrix of codes, denoted as C t = [ C t ( i , j ) ] = [ ∑ k C t . k ( i , j ) ] , where C t , k ( i , j ) represented the total co-occurrence of the i th and j th codes within 3 0 -day moving windows in the k th patient’s health record during calendar year t . The ( i , j ) th entry of the Shifted Positive Pointwise Mutual Information (SPPMI) matrix for calendar year t was then calculated as SPPM I t ( i , j ) = max { 0 , C t ( i , j ) C t ( · , · ) C t ( i , · ) C t ( j , · ) } , where C t ( i , · ) was the row sum of C t and C t ( · , · ) was the total sum of all entries in C t .
The SPPMI-SVD algorithm generated embeddings for the t th calendar year by performing singular value decomposition (SVD) on the SPPMI matrix, represented as SPPM I t = U t diag ( λ t , 1 , λ t , 2 , … , λ t , d ) U t T . We then obtained the embedding for each node in year t as V t = R ( U t diag ( λ t , 1 1 / 2 , λ t , 2 1 / 2 , … , λ t , p 1 / 2 ) ) , where p was the embedding dimension and R was the unit-length normalization operator that standardized each row to unit length. Using these embeddings, we computed the cosine similarity matrix for year t as V t V t T . To analyze temporal trends, we fit a Locally Estimated Scatterplot Smoothing (LOESS) function for each feature pair ( i , j ) , producing a smoothed estimator.
To construct confidence intervals for these estimators, we replicated the above method for each individual patient. Instead of using C t ( i , j ) , we used C t , k ( i , j ) to compute the patient-specific cosine similarity matrix as V k t V k t T for the k th patient. Finally, for each calendar year, we aggregated the patient-wise cosine similarity values to construct confidence intervals based on the standard error across patients. Mathematically, cosine similarity measures how closely two vectors point in the same direction. In practice, two medications may be prescribed at different rates but still have high cosine similarity if clinicians tend to prescribe them to patients with similar diagnoses and document them in similar clinical notes. In our study, a high cosine similarity between a DMT and the MS diagnosis reflects MS‑specific clinical use, which is more informative than simple prescribing frequency.
We assessed the robustness of temporal patterns to the choice of smoothing parameter by conducting sensitivity analyses using alternative LOESS span values (0.3 and 0.7), in addition to the primary specification (span = 0.5).
Change-point detection
After computing the yearly cosine similarity for each feature pair ( i , j ) , we fit a piecewise (segmented) regression model to characterize the temporal trend in their relationship [ 26 ]. Specifically, the model assumed that the cosine similarity over time could be described by a single linear regression model or two linear segments joined at an unknown breakpoint. For a model with a single breakpoint at year 𝜏, the cosine similarity was modeled as: y t = β 0 + β 1 t + ϵ t when t ≤ τ , and y t = β 0 + β 1 τ + β 2 ( t − τ ) + ϵ t when t > τ . The breakpoint 𝜏 and parameters ( β 0 , β 1 , β 2 ) were estimated by minimizing the residual sum of squares. By applying this model to each feature pair, we captured both the overall direction of the trend and any structural shifts over time. Based on the fitted models, we categorized the feature pairs (DMT-MS) into four groups: (1) pairs with no significant trend changes, (2) pairs exhibiting a significantly increasing trend, (3) pairs exhibiting a significantly decreasing trend, and (4) pairs with a significant change point indicating a shift in the trend.
Results
Patient characteristics
The study cohort included a total of 29,169 patients, comprising 10,301 from UPMC and 18,868 from MGB ( Table 1 ). The overall median age at diagnosis was 45.9 years (IQR: 36.4–56.8), with a higher median age in the UPMC cohort (47.4 years) compared to MGB (44.8 years). The median disease duration was 12.4 years (IQR: 7.0–12.7), shorter in UPMC (11.8 years) and longer in MGB (12.8 years). The majority of the cohort were women (74.3%), with similar sex distributions across sites. Most patients identified as White (89.4%), followed by Black (6.5%) and Asian (1.2%), with racial composition relatively consistent across sites. Overall, 54.5% of patients had ever received a DMT, with a higher proportion in UPMC (69.4%) than in MGB (47.3%), which is largely consistent with patterns reported across several independent real-world MS cohorts worldwide [ 2 , 27 , 28 ].
Table 1
Cohort Characteristics of KOMAP-identified MS Patients.
| All | UPMC | MGB | |
| N | 29,169 | 10,301 | 18,868 |
| Age at Diagnosis [Years, Median (IQR)] | 45.9 (36.4-56.8) | 47.4 (37.4-56.5) | 44.8 (34.7-54.9) |
| Disease Duration [Years, Median (IQR)] | 12.4 (7.0-12.7) | 11.8 (8.2-12.5) | 12.8 (6.8-19.3) |
| Gender [n (%)] | |||
| Women | 21,671 (74.3) | 7,676 (74.5) | 13,995 (74.2) |
| Men | 7,497 (25.7) | 2,625 (25.5) | 4,872 (25.8) |
| Unknown | 1 (0.0) | 0 (0.0) | 1 (0.0) |
| Race [n (%)] | |||
| American Indian or Alaska Native | 66 (0.2) | 14 (0.1) | 52 (0.3) |
| Asian | 341 (1.2) | 42 (0.4) | 299 (1.6) |
| Black | 1,893 (6.5) | 821 (8.0) | 1,072 (5.7) |
| Native Hawaiian or Other Pacific Islander | 5 (0.0) | 2 (0.0) | 3 (0.0) |
| White | 26,072 (89.4) | 9,271 (90.0) | 16,801 (89.1) |
| Unknown | 792 (2.7) | 151 (1.5) | 641 (3.4) |
| Ethnicity [n (%)] | |||
| Hispanic or Latino | 424 (1.5) | 55 (0.5) | 369 (2.0) |
| Not Hispanic or Latino | 28,309 (97.1) | 9,811 (95.2) | 18,498 (98.0) |
| Unknown | 436 (1.4) | 435 (4.3) | 1 (0.0) |
| Ever on DMT [n (%)] | |||
| Yes | 15,905 (54.5) | 7,114 (69.4) | 8,791 (47.3) |
| No | 13,264 (45.5) | 3,187 (30.6) | 10,077 (52.7) |
MS diagnosis phenotyping algorithm performance
At UPMC, the combined codified plus NLP-derived narrative feature set achieved the best performance, with an AUROC of 0.922 and an AUPRC of 0.966. It outperformed both benchmark models (main MS PheCodes: AUROC 0.854, AUPRC 0.941; main MS CUI: AUROC 0.798, AUPRC 0.898) as well as the codified-only feature set (AUROC 0.912, AUPRC 0.963). Similarly, at MGB, the combined feature set yielded the best performance, with an AUROC of 0.994 and an AUPRC of 0.940 ( Fig 2A , S2 Table ). Across all specificity thresholds, the combined feature set consistently achieved the highest sensitivity and NPV, while PPV remained high across all models and healthcare systems, mostly exceeding 0.950 ( S2 Table ). Accordingly, we deployed the model using the combined feature set at a 0.900 specificity threshold to phenotype MS diagnosis and classify patients with MS in both the UPMC and MGB cohorts ( Figs 2B and 2C ).
Иллюстрация — в первоисточнике ↗
Time-varying relationships between DMTs and MS
We next assessed temporal trends in MS therapies among KOMAP-classified MS patients using the temporal KG, highlighting dynamic shifts in the cosine similarity between DMTs and MS diagnosis ( i.e., MS-specific therapies) as well as changes in DMT prescription frequency ( Fig 3 and Table 2 ). It is important to note that prescription frequency does not necessarily indicate that the drug is primarily used to treat MS. Rather, cosine similarity between a drug and MS provides a more direct measure of how specifically and frequently a drug is associated with MS treatment. This distinction underscores the value of cosine similarity as a focused metric for understanding the drug’s relationship to the disease.
Table 2
Trends of common MS-related DMT classes between 2004 and 2022.
1 Trend : the pattern of MS-related DMT prescription over time assessed using cosine similarity. I-D, increasing trend before the change point, followed by a decreasing trend; I-I, increasing throughout, at different rate before and after the change point; D-I, decreasing trend, followed by an increasing trend; D-NA, decreasing trend with no significant trend after the change point; NA-D, no significant trend before the change point, followed by a decreasing trend. 2 Change point : the year during which a statistically significant shift in the MS-related DMT prescription trend occurred.
| DMT Class | Follow-up Period | Trend 1 | Change Point 2 | Before Change Point | After Change Point | ||
| β (95% CI) | p | β (95% CI) | p | ||||
| Alpha4-integrin blocker | 2004–2022 | I-D | 2011 | 0.063 (0.050, 0.077) | <0.001 | -0.027 (-0.035, -0.019) | <0.001 |
| B cell depletion | 2002–2022 | I-I | 2014 | 0.022 (0.009, 0.035) | 0.002 | 0.051 (0.023, 0.078) | 0.001 |
| Fumarate | 2013–2022 | D-NA | 2020 | -0.028 (-0.042, -0.013) | 0.004 | -0.097 (-0.234, 0.041) | 0.135 |
| Glatiramer | 2000–2022 | I-D | 2011 | 0.022 (0.012, 0.032) | <0.001 | -0.013 (-0.025, -0.002) | 0.026 |
| Interferon-beta | 2000–2022 | NA-D | 2011 | -0.007 (-0.017, -0.002) | 0.124 | -0.019 (-0.030, -0.008) | 0.002 |
| S1P-R modulator. | 2010–2022 | NA-D | 2014 | 0.022 (-0.011, 0.055) | 0.166 | -0.026 (-0.043, -0.010) | 0.005 |
| Steroid | 2000–2022 | D-I | 2013 | -0.027 (-0.037, -0.018) | <0.001 | 0.029 (0.011, 0.048) | 0.003 |
Иллюстрация — в первоисточнике ↗
We examined the major DMT mechanistic classes. For the alpha4-integrin blocker ( i.e., natalizumab), cosine similarity increased steadily from 2004 [β (95% CI) = 0.063 (0.050, 0.077), p < .001], peaked around 2011, and then gradually declined [β (95% CI) = -0.027 (-0.035, -0.019), p < .001], mirroring its prescription frequency trend, which also peaked around 2011–2012 ( Fig 3A ). Glatiramer acetate initially showed a moderate, stable increase in cosine similarity [β (95% CI) = 0.022 (0.012, 0.032), p < .001] until 2011, followed by a decline [β (95% CI) = -0.013 (-0.025, -0.002), p < .001], with frequency peaking in 2015 before decreasing ( Fig 3B ). B-cell depletion therapies ( i.e., ocrelizumab, ofatumumab, and rituximab) exhibited a sharp increase in cosine similarity beginning around 2014 [β (95% CI) = 0.051 (0.023, 0.078), p = .001], which accelerated following the introduction of ocrelizumab post-2017, paralleled by a continuous rise in prescription frequency ( Fig 3C ). In contrast, fumarates ( i.e., dimethyl fumarate, diroximel fumarate, and monomethyl fumarate) showed a modest downward trend in cosine similarity following the introduction of dimethyl fumarate in 2013 [β (95% CI) = -0.028 (-0.042, -0.013), p = .001], but exhibited a relatively flat trend after the introduction of diroximel fumarate and monomethyl fumarate around 2020, which matched the prescription frequency pattern ( Fig 3D ). Interferon-beta therapies ( i.e., interferon beta-1a and interferon beta-1b) demonstrated a long-term decline in both cosine similarity and prescription frequency, becoming statistically significant after 2011 [β (95% CI) = -0.019 (-0.030, -0.008), p = .002] ( Fig 3E ). S1P receptor modulators ( i.e., fingolimod, siponimod, ozanimod, and ponesimod) showed a non-significant increase in cosine similarity up to 2014 [β (95% CI) = 0.022 (-0.011, 0.055), p = .166], followed by a gradual decline [β (95% CI) = -0.026 (-0.043, -0.010), p = .005], while prescription frequency rose until around 2015 before decreasing ( Fig 3F ). Finally, steroids ( e.g., cortisone, methylprednisolone, and prednisolone) were frequently used in the management of acute MS relapses and were included as references. Steroids showed a statistically significant decline in cosine similarity prior to 2013 [β (95% CI) = -0.027 (-0.037, -0.018), p < .001], followed by a gradual increase [β (95% CI) = 0.029 (0.011, 0.048), p = .003], while the prescription frequency consistently increased throughout the follow-up period ( Fig 3G ).
For completeness, we further examined temporal trends of individual DMT usage among KOMAP-classified MS patients ( S1 Fig , S2 Fig , and S3 Table ). Among commonly prescribed DMTs, glatiramer acetate and natalizumab exhibited an increasing-to-decreasing pattern, with usage declining after 2011 ( p < .001 for both). Fingolimod, interferon beta-1a, and interferon beta-1b showed no significant trend before 2012 but declined significantly afterward ( p < .005). Dimethyl fumarate showed a decreasing trend until 2020, while the post-2020 trend was not statistically significant. Ocrelizumab and rituximab displayed increasing trends, with ocrelizumab usage significantly rising after 2018 ( p = .032), and rituximab significantly increased throughout the follow-up period. In contrast, teriflunomide declined consistently over the follow-up period ( p = .006). As a reference, methylprednisolone showed a reversal from decreasing to increasing usage after 2014 ( p = .003). Among less frequently prescribed DMTs ( S2 Fig and S3 Table ), cladribine showed an increasing trend until 2019, followed by a non-significant decline. Mitoxantrone consistently decreased in use ( p = 0.013), while alemtuzumab, daclizumab, and peginterferon beta-1a showed no statistically significant trends. Several newer agents ( e.g., diroximel fumarate, monomethyl fumarate, ofatumumab, ozanimod, and others) lacked sufficient longitudinal data to evaluate trends.
In sensitivity analyses to assess the robustness of the temporal patterns to the choice of smoothing parameter (alternative LOESS span values of 0.3 and 0.7, in addition to the primary specification of span = 0.5), the smoothed trajectories were largely consistent across span values for representative DMT classes with increasing, decreasing, and change-point patterns ( S3 Fig ). The direction of long-term trends (increasing or decreasing) was preserved, and the timing of visually apparent inflection points differed by at most one calendar year across smoothing choices. These findings indicate that the inferred temporal shifts in MS-specific DMTs are robust to reasonable variations in smoothing parameters. We used LOESS curves for visualization only and performed change-point detection analyses on the yearly cosine similarity estimates rather than on the smoothed curves, ensuring that statistical inference was not driven by the smoothing procedure.
Discussion
In this study, we utilized a large, multicenter EHR dataset from two major healthcare systems (UPMC and MGB) spanning both academic and community care settings to evaluate MS diagnosis phenotyping performance using a novel algorithm ( i.e., KOMAP) and to examine longitudinal trends in MS therapies through a temporal KG approach. Our findings demonstrate that KOMAP achieved strong performance in identifying MS patients across both cohorts, with higher accuracy observed when using combined codified and NLP-derived feature sets. Notably, our analysis of time-varying relationships between DMTs and MS reveals how clinical practice has shifted over the past two decades in response to emerging therapies and evolving treatment strategies, offering new insights into the dynamics of MS care.
Since the introduction of the first DMT, MS management has evolved substantially over the past three decades. Our EHR-based findings from KOMAP-identified MS patients align with these shifting treatment paradigms. Early injectable therapies, such as interferon-beta and glatiramer acetate, were among the first approved DMTs. While moderately effective in reducing relapses, the requirement for frequent injections made long-term adherence challenging [ 29 , 30 ]. In our study, interferon use remained steady until 2011, then declined significantly. Glatiramer acetate followed a similar trajectory, with a modest increase before 2011 and a subsequent decline, likely due to the emergence of oral therapies [ 31 ]. Oral DMTs, first introduced in the early 2010s, improved convenience and adherence [ 32 ]. Fingolimod and dimethyl fumarate were initially widely adopted, but their use declined over time, possibly due to side effects and the availability of newer options. Teriflunomide also showed a consistent decline, suggesting that many early-generation oral agents were eventually supplanted by higher-efficacy treatments. Monoclonal antibodies, such as natalizumab, were initially used for patients with more aggressive disease. Our data showed increased natalizumab use from 2004 to 2011, followed by a gradual decline, though its use continued in clinical practice, consistent with concerns about progressive multifocal leukoencephalopathy (PML) [ 33 ]. The most significant shift in MS treatment has been the rise of B-cell depletion therapies, including ocrelizumab, rituximab, and ofatumumab. These therapies have demonstrated strong efficacy in trials and effectiveness in real-world data and are increasingly used as first-line options [ 34 ]. In our analysis, their use began rising around 2014 and accelerated following the approval of ocrelizumab in 2017, reflecting a broader trend toward early, high-efficacy treatment strategies in MS care.
Our study offers several methodological advantages. First, many existing approaches ( e.g., calculating feature frequencies across calendar years) fail to capture nuanced relationships between DMT prescriptions and disease ( i.e. , MS). For instance, a high frequency of steroid prescriptions in MS patients does not necessarily indicate their primary use for MS treatment, as steroids are also commonly prescribed for various other indications ( e.g., allergic reactions, other inflammatory conditions). In contrast, cosine similarity measures the co-occurrence of clinical features, providing a more accurate representation of their relationships. Our embedding approach uses cosine similarity to capture contextual proximity to MS rather than raw frequency. This explains why certain lower-frequency features improved classification, since they appear in clinical contexts that resemble MS care. This property helps reduce confounding from highly prevalent but non-specific codes and orders, which often dilute rule-based definitions that rely on counts alone.
Second, our method accounts for temporal changes in feature relationships, specifically MS-related DMT prescriptions. The observed prescription trends of MS-related DMTs over time based on the EHR data align with domain knowledge and clinical experience. For instance, the association between natalizumab and MS strengthened after its FDA approval in 2004, peaked several years later, and then gradually declined. Assuming static relationships over time can lead to misleading conclusions, while analyzing the dataset without considering temporal dynamics risks obscuring important trends.
Third, our approach relies solely on summary data ( e.g., co-occurrence matrices) to compute cosine similarities and assess relationship trends. This eliminates the need for patient-level data, facilitating cross-institution collaborations while adhering to privacy regulations. By enabling data sharing, our method expands the scalability of the dataset and enhances the generalizability of findings.
Finally, the novel MS diagnosis algorithm ( i.e., KOMAP) enables accurate and efficient identification of MS cases for downstream analyses. The AUROC and AUPRC of MS phenotyping exceeded 0.90 in two large, independent healthcare systems. This unsupervised algorithm leverages a publicly available, pre-trained KG of interconnected EHR concepts to efficiently identify informative EHR features, overcoming limitations of expert-selected or less specific feature selection steps. Although the algorithm does not require expert adjudication, the performance metrics reported in this study were validated through manual chart review. To compare KOMAP with published MS diagnosis algorithms, we benchmarked its performance against a well-cited claims-based rule that classifies MS using three or more MS-related claims across any combination of inpatient, outpatient, or DMT claims within a two-year window [ 3 ]. Using EHR data, KOMAP achieved comparable or higher accuracy and superior negative predictive values at a specificity of 0.900 across two independent clinic-based cohorts (UPMC and MGB) ( S4 Table ). Translating claims algorithms to EHR settings, however, involves practical limitations. First, EHR systems do not consistently encode a single primary diagnosis across inpatient and outpatient encounters, and coding hierarchies vary by institution, complicating the direct transfer of claims rules to EHR data. Second, claims‑based algorithms depend on adjudicated pharmacy fills for DMTs, [ 35 ] whereas EHRs capture medication orders or administrations, making one‑to‑one substitution problematic without additional data linkage. Third, claims datasets cannot be readily linked to research registries to obtain gold‑standard labels for validation, whereas registry-linked EHR datasets support chart‑verified labels and model calibration. Taken together, these findings demonstrate that KOMAP not only performs favorably relative to simpler rule‑based methods but is better suited for MS phenotyping in EHR settings.
The study also has limitations. First, cosine similarity estimation does not yield a smooth trajectory across calendar years. To address this, we applied curve smoothing to the estimated cosine similarities, which could introduce a discrepancy between the smoothed curve and the constructed confidence intervals. Second, relationships between clinical features may vary not only over time but also with disease progression. For example, the associations between DMT use and MS symptoms may differ depending on whether the patient is in the early or advanced stage of MS. Incorporating disease stages into the analysis ( e.g., clustering the EHR data by RRMS and SPMS) could yield more detailed and accurate measurements of feature relationships over time. Third, although the combined dataset includes two large, independent healthcare systems encompassing both academic and community practices, racial and ethnic minorities remain underrepresented. The approach is readily applicable to healthcare systems with more diverse patient populations ( e.g., the Veterans Affairs Healthcare System) in future studies.
Conclusion
In summary, our study demonstrates the effectiveness of the advanced phenotyping algorithm KOMAP for accurately and efficiently identifying MS patients from EHR data across two large healthcare systems, and highlights the value of the temporal knowledge graph approach in capturing the complex real-world treatment dynamics of a chronic neurological condition.
Supporting information
MS phenotyping model (KOMAP) features and coefficients.
(PDF)
MS phenotyping model (KOMAP) performance with different feature sets.
(PDF)
Trends of individual MS-related DMT between 2004 and 2022.
(PDF)
Performance of the final KOMAP MS phenotyping algorithm against a benchmark algorithm.
(PDF)
Trends of commonly prescribed MS-related DMTs (2004–2022).
(PDF)
Trends of less commonly prescribed MS-related DMTs (2004 and 2022).
(PDF)
Sensitivity of Temporal MS-DMT Cosine Similarity Trends to Alternative LOESS Smoothing Parameters (2004–2022).
(PDF)
The authors thank all research participants and the clinicians from UPMC and MGB.
References
1 Jakimovski D , Bittner S , Zivadinov R , Morrow SA , Benedict RH , Zipp F , et al . Multiple sclerosis . Lancet . 2024 ; 403 ( 10422 ): 183 – 202 . doi: 10.1016/S0140-6736(23)01473-3 37949093
2 Zhu W , Tang X , Heyman RA , Cai T , Suh K , Seeger JD , et al . Patterns of Utilization and Expenditure Across Multiple Sclerosis Disease-Modifying Therapies: A Retrospective Cohort Study Using Claims Data from a Commercially Insured Population in the United States, 2010-2019 . Neurol Ther . 2022 ; 11 ( 3 ): 1147 – 65 . doi: 10.1007/s40120-022-00358-4 35598225 PMC9338211
3 Culpepper WJ , Marrie RA , Langer-Gould A , Wallin MT , Campbell JD , Nelson LM , et al . Validation of an algorithm for identifying MS cases in administrative health claims datasets . Neurology . 2019 ; 92 ( 10 ):e1016– 28 . doi: 10.1212/WNL.0000000000007043 30770432 PMC6442008
4 Alzoubi H , Alzubi R , Ramzan N , West D , Al-Hadhrami T , Alazab M . A Review of Automatic Phenotyping Approaches using Electronic Health Records . Electronics . 2019 ; 8 ( 11 ): 1235 . doi: 10.3390/electronics8111235
5 Goldstein ND , Kahal D , Testa K , Gracely EJ , Burstyn I . Data Quality in Electronic Health Record Research: An Approach for Validation and Quantitative Bias Analysis for Imperfectly Ascertained Health Outcomes Via Diagnostic Codes . Harv Data Sci Rev . 2022 ; 4 ( 2 ). doi: 10.1162/99608f92.cbe67e91 36324333 PMC9624477
6 Yang S , Varghese P , Stephenson E , Tu K , Gronsbell J . Machine learning approaches for electronic health records phenotyping: a methodical review . J Am Med Inform Assoc . 2023 ; 30 ( 2 ): 367 – 81 . doi: 10.1093/jamia/ocac216 36413056 PMC9846699
7 Xiong X , Sweet SM , Liu M . Knowledge-Driven Online Multimodal Automated Phenotyping System. medRxiv . 2023 .
8 Cree BAC , Mares J , Hartung H-P . Current therapeutic landscape in multiple sclerosis: an evolving treatment paradigm . Curr Opin Neurol . 2019 ; 32 ( 3 ): 365 – 77 . doi: 10.1097/WCO.0000000000000700 30985372
9 Trojano M , Iaffaldano P . Assessing long-term effectiveness of MS treatment - a matter of debate . Nat Rev Neurol . 2021 ; 17 ( 4 ): 197 – 8 . doi: 10.1038/s41582-021-00476-x 33633380
10 Selmaj K , Cree BAC , Barnett M , Thompson A , Hartung H-P . Multiple sclerosis: time for early treatment with high-efficacy drugs . J Neurol . 2024 ; 271 ( 1 ): 105 – 15 . doi: 10.1007/s00415-023-11969-8 37851189 PMC10769939
11 McGinley MP , Goldschmidt CH , Rae-Grant AD . Diagnosis and Treatment of Multiple Sclerosis: A Review . JAMA . 2021 ; 325 ( 8 ): 765 – 79 . doi: 10.1001/jama.2020.26858 33620411
12 Ageno A , Català N , Pons M . Acquisition of temporal patterns from electronic health records: an application to multimorbid patients . BMC Med Inform Decis Mak . 2023 ; 23 ( 1 ): 189 . doi: 10.1186/s12911-023-02287-0 37726756 PMC10510308
13 Cui H , Lu J , Xu R , Wang S , Ma W , Yu Y , et al . A review on knowledge graphs for healthcare: Resources, applications, and promises . J Biomed Inform . 2025 ; 169 : 104861 . doi: 10.1016/j.jbi.2025.104861 40712809 PMC12995551
14 Chaturvedi R. Temporal Knowledge Graph Extraction and Modeling across Multiple Documents for Health Risk Prediction. In: Companion Proceedings of the ACM Web Conference 2024, 2024. 1182–5. 10.1145/3589335.3651256
15 Xia Z , Zhan W , Secor E , Chibnik LB , Bove RM , Cheng S , et al . Modeling Disease Severity in Multiple Sclerosis Using Electronic Health Records. PLoS ONE. 2013 ; 8 ( 11 ):e78927. doi: 10.1371/journal.pone.0078927 PMC3823928 24244385
16 Zhang T , Goodman M , Zhu F , Healy B , Carruthers R , Chitnis T , et al . Phenome-wide examination of comorbidity burden and multiple sclerosis disease severity. Neurology Neuroimmunology & Neuroinflammation. 2020 ; 7 ( 6 ). doi: 10.1212/NXI.0000000000000864 PMC7673286 32817202
17 Ahuja Y , Kim N , Liang L , Cai T , Dahal K , Seyok T , et al . Leveraging electronic health records data to predict multiple sclerosis disease activity. Annals of Clinical and Translational Neurology. 2021 ; 8 ( 4 ): 800 – 10 . doi: 10.1002/acn3.51324 33626237 PMC8045951
18 Hou J , Kim N , Cai T , Dahal K , Weiner H , Chitnis T , et al . Comparison of Dimethyl Fumarate vs Fingolimod and Rituximab vs Natalizumab for Treatment of Multiple Sclerosis. JAMA Network Open. 2021 ; 4 ( 11 ):e2134627. doi: 10.1001/jamanetworkopen.2021.34627 PMC8596196 34783826
19 Liang L , Kim N , Hou J , Cai T , Dahal K , Lin C , et al . Temporal trends of multiple sclerosis disease activity: Electronic health records indicators. Multiple Sclerosis and Related Disorders. 2021 ; 57 : 103333 . doi: 10.1016/j.msard.2021.103333 35158446 PMC8849591
20 Zhang Y , Cai T , Yu S , Cho K , Hong C , Sun J , et al . High-throughput phenotyping with electronic medical record data using a common semi-supervised approach (PheCAP) . Nat Protoc . 2019 ; 14 ( 12 ): 3426 – 44 . doi: 10.1038/s41596-019-0227-6 31748751 PMC7323894
21 McDonald CJ , Huff SM , Suico JG , Hill G , Leavelle D , Aller R , et al . LOINC, a universal standard for identifying laboratory observations: a 5-year update . Clin Chem . 2003 ; 49 ( 4 ): 624 – 33 . doi: 10.1373/49.4.624 12651816
22 Liu S , Ma W , Moore R , et al . RxNorm: prescription for electronic drug information exchange . Prof . 2005 ; 7 : 17 – 23 .
23 Yu S , Cai T , Cai T . NILE: Fast Natural Language Processing for Electronic Health Records . arXiv . 2013 . doi: 10.48550/arxiv.1311.6063
24 Humphreys BL , Lindberg DA . The UMLS project: making the conceptual connection between users and the information they need . Bull Med Libr Assoc . 1993 ; 81 ( 2 ): 170 – 7 . 8472002 PMC225759
25 Hong C , Rush E , Liu M , Zhou D , Sun J , Sonabend A , et al . Clinical knowledge extraction via sparse embedding regression (KESER) with multi-center large scale electronic health record data . NPJ Digit Med . 2021 ; 4 ( 1 ): 151 . doi: 10.1038/s41746-021-00519-z 34707226 PMC8551205
26 Muggeo VMR . Estimating regression models with unknown break-points . Stat Med . 2003 ; 22 ( 19 ): 3055 – 71 . doi: 10.1002/sim.1545 12973787
27 Stanikić M , Salmen A , Kamm CP , Roth P , Calabrese P , Zecca C , et al . Real-world use of disease-modifying therapy in persons with multiple sclerosis aged 55 and over . BMJ Neurol Open . 2025 ; 7 ( 2 ):e001108. doi: 10.1136/bmjno-2025-001108 41000459 PMC12458763
28 McDonald M , Macleod AD , Gallagher P . Evaluation of Early Initiation of Disease-Modifying Treatment for Patients with Multiple Sclerosis Within a Real-World Population for Long-Term Outcomes . Sclerosis . 2025 ; 3 ( 4 ): 35 . doi: 10.3390/sclerosis3040035
29 Mirabella M , Annovazzi P , Brownlee W , et al . Treatment Challenges in Multiple Sclerosis – A Continued Role for Glatiramer Acetate? Front Neurol . 2022 ; 13 :844873. 10.3389/fneur.2022.844873 PMC9051342 35493825
30 Bartolomé-García E , Usarralde-Pérez Á , Sanmartín-Fenollera P , Pérez-Encinas M . Persistence and adherence to interferon and glatiramer acetate in patients with multiple sclerosis . Eur J Hosp Pharm . 2019 ; 26 ( 1 ): 23 – 8 . doi: 10.1136/ejhpharm-2017-001286 31157091 PMC6362766
31 Healy BC , Glanz BI , Zurawski JD , Mazzola M , Chitnis T , Weiner HL . Long-term follow-up for multiple sclerosis patients initially treated with interferon-beta and glatiramer acetate . J Neurol Sci . 2018 ; 394 : 127 – 31 . doi: 10.1016/j.jns.2018.09.020 30248571
32 Faissner S , Gold R . Oral Therapies for Multiple Sclerosis . Cold Spring Harb Perspect Med . 2019 ; 9 ( 1 ):a032011. doi: 10.1101/cshperspect.a032011 29500302 PMC6314072
33 Vukusic S , Rollot F , Casey R , et al . Progressive Multifocal Leukoencephalopathy Incidence and Risk Stratification Among Natalizumab Users in France . JAMA Neurol 2020 ; 77 : 94 – 102 . 31479149 10.1001/jamaneurol.2019.2670 PMC6724170
34 Oommen L , Krieger S . New Approaches to Challenge Old Assumptions-B-Cell Depletion in Multiple Sclerosis . JAMA Neurol . 2023 ; 80 ( 8 ): 775 – 7 . doi: 10.1001/jamaneurol.2023.1079 37306978
35 Zhu W , Tang X , Heyman RA , Cai T , Suh K , Seeger JD , et al . Patterns of Utilization and Expenditure Across Multiple Sclerosis Disease-Modifying Therapies: A Retrospective Cohort Study Using Claims Data from a Commercially Insured Population in the United States, 2010–2019. Neurology and Therapy. 2022 ; 11 ( 3 ): 1147 – 65 . doi: 10.1007/s40120-022-00358-4 35598225 PMC9338211