Article Text

Multilevel clustering approach driven by continuous glucose monitoring data for further classification of type 2 diabetes
  1. Rui Tao1,
  2. Xia Yu1,
  3. Jingyi Lu2,
  4. Yun Shen2,
  5. Wei Lu2,
  6. Wei Zhu2,
  7. Yuqian Bao2,
  8. Hongru Li1,
  9. Jian Zhou2
  1. 1College of Information Science and Engineering, Northeastern University, Shenyang, Liaoning, China
  2. 2Department of Endocrinology and Metabolism, Shanghai Jiao Tong University Affilated Sixth People’s Hospital, Shanghai Clinical Center for Diabetes, Shanghai, China
  1. Correspondence to Professor Jian Zhou; zhoujian{at}


Introduction Mining knowledge from continuous glucose monitoring (CGM) data to classify highly heterogeneous patients with type 2 diabetes according to their characteristics remains unaddressed. A refined clustering method that retrieves hidden information from CGM data could provide a viable method to identify patients with different degrees of dysglycemia and clinical phenotypes.

Research design and methods From Shanghai Jiao Tong University Affiliated Sixth People’s Hospital, we selected 908 patients with type 2 diabetes (18–83 years) who wore blinded CGM sensors (iPro2, Medtronic, California, USA). Participants were clustered based on CGM data during a 24-hour period by our method. The first level extracted the knowledge-based and statistics-based features to describe CGM signals from multiple perspectives. The Fisher score and variables cluster analysis were applied to fuse features into low dimensions at the second level. The third level divided subjects into subgroups with different clinical phenotypes. The four subgroups of patients were determined by clinical phenotypes.

Results Four subgroups of patients with type 2 diabetes with significantly different statistical features and clinical phenotypes were identified by our method. In particular, individuals in cluster 1 were characterized by the lowest glucose level factor and glucose fluctuation factor, and the highest negative glucose factor and C peptide index. By contrast, cluster 2 had the highest glucose level factor and the lowest C peptide index. Cluster 4 was characterized by the greatest degree of glucose fluctuation factor, was the most insulin-sensitive, and had the lowest insulin resistance. Cluster 3 ranked in the middle concerning the CGM-derived metrics and clinical phenotypes compared with those of the other three groups.

Conclusion A novel multilevel clustering approach for knowledge mining from CGM data in type 2 diabetes is presented. The results demonstrate that subgroups are adequately distinguished with notable statistical and clinical differences.

  • classification
  • diabetes mellitus
  • type 2 diabetes
  • disease management

This is an open access article distributed in accordance with the Creative Commons Attribution Non Commercial (CC BY-NC 4.0) license, which permits others to distribute, remix, adapt, build upon this work non-commercially, and license their derivative works on different terms, provided the original work is properly cited, appropriate credit is given, any changes made indicated, and the use is non-commercial. See:

Statistics from

Request Permissions

If you wish to reuse any or all of this article please use the link below which will take you to the Copyright Clearance Center’s RightsLink service. You will be able to get a quick price and instant permission to reuse the content in many different ways.

Significance of this study

What is already known about this subject?

  • A refined clustering method that retrieves hidden information from continuous glucose monitoring (CGM) data could provide a viable method to identify patients with different features of diabetes.

  • Type 2 diabetes mellitus is highly heterogeneous and traditional classification method may be too crude to meet the needs of personalized medicine.

What are the new findings?

  • Our study shows that it is feasible to implement the data-driven method of artificial intelligence in diabetes research.

  • It is a novel research that uses multilevel clustering method for mining knowledge from original high-dimensional CGM data to further classify patients with type 2 diabetes, which is difficult for clinicians.

  • In particular, the results showed that the four novel subgroups of patients with type 2 diabetes had distinct clinical phenotypes.

How might these results change the focus of research or clinical practice?

  • By the new classification of type 2 diabetes, personalized strategies of diabetes management may be developed, which may lead to better health outcomes in diabetes.

  • Artificial intelligence could be an effective tool for precision medicine in diabetes.


Diabetes and its complications can substantially impair the human body. Its treatment has always been a long-standing dilemma worldwide.1 2 Type 2 diabetes not only comprises 90% of all diabetes, but also has considerable heterogeneity in genes and clinical phenotypes.3 4 It is generally believed that further classification of type 2 diabetes will provide more personalized and precise treatments for patients.3

Cluster analysis, a data-mining technique that helps reveal hidden structures, has been widely used in the medical field.5 6 Previous works using cluster analyses to distinguish patients with type 2 diabetes have largely concentrated on medical check-up data and genetic data.3 4 7 8 For instance, five subgroups of adult-onset diabetes were obtained by six check-up variables by Ahlqvist et al.3 Further analyses have proven that the risk of diabetes complications among these five subgroups was different. On the other hand, continuous glucose monitoring (CGM) is a method of continuously measuring glucose levels over a number of days. Previous studies have shown that the use of CGM improves glucose control in patients with diabetes.9–11 There are several ways in which CGM functions. The glucose values obtained from CGM can be blinded to the user (blinded/retrospective CGM) or viewed in real time (real-time CGM). Importantly, the wealth of information on glucose profile generated by CGM provides an opportunity to discover latent structures within type 2 diabetes.

To the best of our knowledge, empirical research on classification of patients with type 2 diabetes from CGM data is limited.12 13 By dividing the complete CGM curve into segments, Hall and colleagues12 found three different fluctuation modes of CGM, and the frequencies of the three modes in individuals without diabetes, patients with pre-diabetes and patients with diabetes were finally found to be different. Kahkoska and colleagues13 used eight CGM features to identify new subgroups of type 1 diabetes. Three subgroups showed significant differences in glycated hemoglobin A1c (HbA1c).13 The problem of using CGM indices to stratify patients with type 2 diabetes among different categories needs to be discussed further.

As a result, examining patients with type 2 diabetes by CGM data and clustering these patients into specific groups may provide useful information for decision-making. In this study, we proposed a new data-driven method to further classify patients with type 2 diabetes into different subgroups from the original CGM data. We attempt to identify these distinct subgroups and to look at the clinical phenotypes of this clustering.


Study population

Patients who were admitted to the Department of Endocrinology and Metabolism, Shanghai Jiao Tong University Affiliated Sixth People’s Hospital from January 2018 to the end of December 2018 were consecutively enrolled. They were diagnosed with type 2 diabetes according to the 2010 American Diabetes Association standards.14 This study was a secondary analysis of the CGM and clinical data. For cluster analysis of patients with type 2, a blinded CGM system (iPro2, Medtronic, California, USA) was used in this study. The sensor of the CGM system was inserted on day 0 and removed after 72 hours. The CGM data were calibrated by the fingerstick blood glucose readings no more than every 12 hours. Each participant wore the CGM system for 3 days, and complete data for each participant were extracted on the second day (0:00–24:00). Patients met the following study inclusion criteria: hospitalized patients, age ≥18 years, presence of type 2 diabetes, stable glucose-lowering regimen over the previous 3 months and no data missing in CGM on day 2 and clinical phenotypes data. Exclusion criteria included diabetic ketoacidosis; hyperglycemic hyperosmolar state or severe and recurrent events within the previous 3 months; and history of malignancy or mental disorders. Finally, we succeeded in obtaining complete data for 908 participants. All patients provided written informed consent.

Clinical phenotypes

In our study, each patient underwent physical examination that included measurements of height, weight, and blood pressure. Body mass index (BMI) was calculated as weight (kilograms) divided by squared height (meters). One day before the CGM monitoring period, a venous blood sample was drawn at 06:00 after a 10-hour overnight fast. Fasting C peptide (FCP), HbA1c, high-density lipoprotein cholesterol and low-density lipoprotein cholesterol were determined as previously reported.15 In addition to FCP, C peptide at 120 min (CP2h) during a standard meal following overnight fast was assayed. The increments of C peptide in plasma levels at 120 min (ΔCP2h=CP2h−FCP) showed the ratio of C peptide response. Homeostasis model assessment (HOMA) indices were added to analyze each cluster according to the HOMA V.2.2.3 calculator.16

Multilevel clustering method

The multilevel clustering system was designed as a four-step data-mining cluster model. The first level, features extraction, aimed to extract knowledge-based and statistical-based features from CGM traces. Then Fisher score and variables cluster analyses were applied in the features selection at the second level, aiming at further dimension reduction and obtaining better clustering effect. The three factors from features clustering were put into the third level. The third level, subject clustering, clustered all subjects into different subgroups. The detailed multilevel cluster method follows an iterative procedure, as shown in online supplemental materials section 1.

Supplemental material

Features extraction

The 908 CGM traces were first processed to extract the set of well-established indices already considered in the recent research by Weiping et al.17 As a result, mean sensor glucose (MSG), SD of the sensor glucose (SDSG), coefficient of variation (CV), mean amplitude of glycemic excursions (MAGE), and the largest amplitude of glycemic excursions (LAGE) were calculated into the statistical-based features pool. The knowledge-based features pool had the following features: mean postprandial sensor glucose (MPSG), which means the average sensor value of postprandial glucose 3 hours after three meals; J index and M value; indices based on the permanence in the target glucose range, that is, percentages of values within the target range (TIR; 3.9–10 mmol/L) and percentages of values out of the target range (TOR; <3.9 mmol/L or >10 mmol/L); and indices based on glucose risk, that is, low and high blood glucose indices (LBGI, HBGI) and glycemic risk assessment diabetes equation (GRADE) score. In addition, average daily risk range (ADRR) and liability index (LI) were calculated as the feature indices according to the definitions. The ideal blood glucose level in the M value function was set as 5.8 mmol/L.

Through this operation, we reduce the 288-dimensional data of the CGM to a lower dimension of 15. Before the CGM traces were fed into the multilevel clustering, Z-score normalization was used to solve the problem of amplitude scaling and eliminate the offset effect.

Features selection

In the second step, an effective features selection method based on Fisher score18 and feature clustering were applied. These steps help to find the pattern similarities of CGM features from feature extraction and reducing features for clustering (online supplemental materials section 2). First, the CGM features that have more discrimination information based on Fisher score were selected. Then the agglomerative hierarchical clustering method was adopted for feature fusion. Irrelevant and redundant features were removed. The average of elements in every cluster was calculated and used as a representative value of each cluster in further analysis. Finally, a simpler feature matrix of CGM data was generated.

Subject clustering

In the third step, we applied K-means++ algorithm to the simple features’ matrix from feature selection in order to obtain the subtypes of patients with type 2 diabetes.19 As an improvement version of K-means, K-means++ is more suitable for large amounts of patient data and its results were more meaningful and easier to interpret.20–22 Moreover, the stability and efficiency of the K-means++ method were better than the traditional K-means method by improving the choice of clustering center.20 21

The K-means++ solution with Euclidean distance23 was designed to identify potential groups among type 2 diabetes based on the simple features’ matrix. We choose the optimal cluster number on the basis of the elbow method.24 The K-means++ clustering was performed using the cluster function (runs=100) in the scikit-learn package in PYTHON V.3.7. Cluster stability was assessed by resampling the data set 2000 times by the Jaccard bootstrap method. A stable cluster generally yields Jaccard similarity index of greater than 0.75.25

Statistical analysis

Data were analyzed with PYTHON V.3.7 and PASW Statistics V.25 (SPSS, Chicago, Illinois). To determine the clinical significance of the clustering results, this paper compared the four clusters with the CGM feature matrix and clinical phenotypes. Kruskal-Wallis test was used for non-normally distributed data to determine differences between the four subgroups. A two-tailed p value of <0.05 was considered statistically significant.


Participant characteristics

The clinical characteristics are shown in table 1. A total of 908 patients (565 men and 343 women) had a median age of 61 (53–67) years and BMI of 24.89±3.62. Two-sample Kolmogorov-Smirnov test indicated that there was no significant difference between sex and all clinical phenotype indices. Therefore, the next step in the subjects’ cluster should not consider sex (online supplemental table S3).

Table 1

Clinical characteristics of participants with type 2 diabetes

Features cluster

The LBGI was excluded after counting Fisher score. Then the CGM variables were classified into three clusters (figure 1). The first cluster, which was composed of MSG, M value, GRADE, J index, MPSG, HBGI, and TOR, had a high correlation with MSG and HBGI. The second cluster, which was composed of SDSG, CV, LAGE, MAGE, and LI, had the highest correlation with CV. The third cluster was composed of ADRR and TIR. It had a negative correlation with the first and second clusters (online supplemental table S4). Therefore, this study defined the first cluster as the glycemic level factor, the second cluster as the glycemic fluctuation factor and the third cluster as the negative glucose factor.

Figure 1

Dendrogram of hierarchical cluster analysis of continuous glucose monitoring variables. Height indicates the distance of correlation method between substructures. ADRR, average daily risk range; CV, coefficient of variation; GRADE, glycemic risk assessment diabetes equation score; HBGI, high blood glucose indices; J, J index; LAGE, largest amplitude of glycemic excursions; LI, liability index; M, M value; MAGE, mean amplitude of glycemic excursions; MPSG, mean postprandial sensor glucose; MSG, mean sensor glucose; SDSG, SD of the sensor glucose; TIR, percentages of values within the target range (3.9–10 mmol/L); TOR, percentages of values out of the target range (<3.9 mmol/L or >10 mmol/L).

Subjects cluster

By elbow method, the cluster number of subjects at four would be the most appropriate value (online supplemental materials section 3). Each subgroup has different characteristics on CGM traces throughout follow-up (figure 2). We compared the differences between the clustering factors and selected CGM parameters of the four subgroups (figure 3). Cluster 1, which included 338 (37.22%) patients, was characterized by the lowest glucose level factor and glucose fluctuation factor and highest negative glucose factor, and was labeled as low-level and low-fluctuation diabetes (LLLFD). Cluster 2, which included 174 (19.16%) patients and was labeled as high-level and high-fluctuation diabetes (HLHFD), was different from cluster 1; specifically, it had the highest glucose level factor, relatively high glucose fluctuation factor and lowest negative glucose factor. Cluster 3, labeled as the moderate-level and moderate-fluctuation diabetes (MLMFD), included 227 (25.00%) patients. It was characterized by reasonably low glucose fluctuation factor and high glucose level factor, but otherwise was similar to cluster 1. Overall, 169 (18.61%) patients in cluster 4 (labeled as moderate-level and high-fluctuation diabetes, MLHFD) showed a higher glucose fluctuation factor than those in the other three groups.

Figure 2

Continuous glucose monitoring curve of each subgroup: (A) cluster 1, (B) cluster 2, (C) cluster 3 and (D) cluster 4. The solid line is the median. The dark blue bar means the 25th–75th percentiles and the light blue bar means the 10th–90th percentiles. The mean sensor glucose is given at the top left corner.

Figure 3

Box plot of cluster factors in patients. Adjusted p value was used. **Adjusted p values were under 0.01; ***adjusted p values were under 0.001. HLHFD, high-level and high-fluctuation diabetes; LLLFD, low-level and low-fluctuation diabetes; MLHFD, moderate-level and high-fluctuation diabetes; MLMFD, moderate-level and moderate-fluctuation diabetes.

To be effective clinically, the study compared the clusters regarding clinical phenotypes and antidiabetes agents, as shown in table 2. Cluster 1 (LLLFD) was characterized by the lowest HbA1c (7.2%, 6.5%–8.3%) and highest beta-cell capacity as assessed by C peptide and HOMA-2%β. In contrast, cluster 2 (HLHFD) had the highest HbA1c (10.2%, 9.1%–11.3%) and the most severely impaired beta-cell function. Cluster 3 (MLMFD) had a relatively low HbA1c (8.6%, 7.7%–10.0%) and preserved C peptide indices. Additionally, cluster 3 (MLMFD) and cluster 4 (MLHFD) were comparable (p=0.795) in terms of HbA1c. Cluster 4 showed relatively low levels of beta-cell function indices and a modest level of HbA1c (8.9, 7.5–10.1). However, individuals in cluster 4 (MLHFD) were most sensitive to insulin as reflected by the highest HOMA-2%Sensitivity (31.90, 20.50–53.55) and the lowest HOMA-2%Insulin resistance (3.10, 1.90–4.90). Concerning the treatment received, cluster 1 had the lowest percentage of insulin use (54.4%), while cluster 2 had the highest propensity (93.1%) to receive insulin. Moreover, cluster 4, which is the most insulin-sensitive, had the lowest use of metformin (30.2%) and α-glucosidase inhibitors.

Table 2

Clinical characteristics of the various clusters of type 2 diabetes


This study used a data-driven clustering approach to extract implicit information from extensive high-dimensional CGM data. Distinct from previous efforts,12 13 this is a method that could not only provide us with those knowledge-based and statistics-based CGM indices, but also offer features selection to improve the clustering results of subjects. It may provide new insights into the clustering of type 2 diabetes and more tailored diabetes management. The results demonstrate that this multilevel clustering approach could identify patients with type 2 diabetes with diverse clinical phenotypes, such as beta-cell function. Some medical check-ups like C peptide testing is not routinely measured, and glucose pattern represents the most obvious phenotypes of diabetes and may reveal the inherent nature of the disease. Furthermore, the method can be applied to CGM sensors for the convenience of patients with type 2 diabetes at home.

The robustness of the clustering was confirmed by the distinct characteristics of clinical phenotypes, particularly for insulin secretion/sensitivity indices, among the four subgroups. In short, cluster 1 (LLLFD) and cluster 2 (HLHFD) were related to the best and the worst beta-cell function, respectively. Intriguingly, while beta-cell function was modestly impaired, patients in cluster 4 (MLHFD), which was characterized by unstable glucose levels, had the highest level of insulin sensitivity, highlighting the role of insulin sensitivity in glucose homeostasis. Consistent with our study, a positive relationship between insulin sensitivity and glycemic variability was reported in 366 insulin-treated hospitalized patients with type 2 diabetes.26 Indeed, from the clinical perspective, those who are more insulin-sensitive may be more prone to glycemic excursions after dose adjustment. Given the distinct clinical features among the four clusters, different strategies of glucose-lowering treatment may be considered. For instance, for cluster 2, with the most impaired beta-cell function, insulin therapy should be initiated at the early stage of the disease to achieve glycemic targets. For patients in cluster 4, antidiabetic agents that alleviate glucose fluctuations, such as glucagon-like peptide 1 receptor agonists, should be preferentially considered.

Another aspect of clinical significance is the presumed differential risk for chronic diabetic complications across the four clusters. Cluster 2 (HLHFD) and cluster 4 (MLHFD) are more associated with hyperglycemia because their glucose fluctuated wildly.27 In addition, the high degree of glycemic fluctuation factor noted in these two clusters may confer additional risk for microvascular and macrovascular complications.28 Cluster 3 (MLMFD), with relatively higher insulin resistance, may have a high risk of kidney disease due to the correlation between insulin resistance and glomerular hypertension and hyperfiltration.29 It may help doctors to choose precise treatment more quickly according to cluster phenotypes.

The limitations of this study are worth noting. First, the abnormal samples in the database were not removed by our approach. This may reduce the stability of clustering results. In future studies, the method should be improved to exclude outlier subjects. Second, our study only included hospitalized patients with type 2 diabetes in China. The generalizability of the study results is uncertain and needs to be tested in other populations. Third, it is notable that some factors could affect the stability of glucose profile over time within individuals, such as diet, exercise, stress and treatment regimen. In addition, only 1-day CGM data were used in our study, while two previous studies suggested that 14 days of CGM may be needed for reliable estimation of overall glucose control.30 31 Therefore, the results of CGM clustering should be interpreted with caution. Finally, whether the new method of clustering translates into improved glycemic control and subsequent diabetes-related outcomes remains unknown. Further studies are warranted to validate the clinical significance of this method.

In summary, a multilevel clustering method driven by CGM data was designed to divide patients with type 2 diabetes into subgroups with distinct clinical phenotypes. This method has implications for big data from CGM systems and for digital precision in diabetes research. Furthermore, the results of the study show the promise of developing personalized medicine and intelligent healthcare for type 2 diabetes.


We would like to thank all the involved clinicians, nurses, and technicians in Shanghai Clinical Center for Diabetes for dedicating their time and skills to the completion of this study.


Supplementary materials

  • Supplementary Data

    This web only file has been produced by the BMJ Publishing Group from an electronic file supplied by the author(s) and has not been edited for content.


  • RT, XY and JL contributed equally.

  • Contributors RT, XY and JZ designed the study. RT was responsible for data analysis and overall design of the algorithm. XY was responsible for design and analysis of the algorithm. JZ and JL were responsible for clinical phenotypes analysis. JL, YS, WL, WZ and YB assisted in data collection and offered suggestion for the study. HL and JZ funded the study. All authors read and approved the final manuscript.

  • Funding This work was funded by the National Key R&D Program of China (2018YFC2001004), the Shanghai Municipal Education Commission-Gaofeng Clinical Medicine Grant Support (20161430) and the National Natural Science Foundation of China (61903071, 61973067).

  • Competing interests None declared.

  • Patient consent for publication Not required.

  • Ethics approval The study was approved by the Ethics Committee of Shanghai Jiao Tong University Affiliated Sixth People’s Hospital (2020-KY-024) and complied with the principles of the Helsinki Declaration.

  • Provenance and peer review Not commissioned; externally peer reviewed.

  • Data availability statement Data are available upon reasonable request.

  • Supplemental material This content has been supplied by the author(s). It has not been vetted by BMJ Publishing Group Limited (BMJ) and may not have been peer-reviewed. Any opinions or recommendations discussed are solely those of the author(s) and are not endorsed by BMJ. BMJ disclaims all liability and responsibility arising from any reliance placed on the content. Where the content includes any translated material, BMJ does not warrant the accuracy and reliability of the translations (including but not limited to local regulations, clinical guidelines, terminology, drug names and drug dosages), and is not responsible for any error and/or omissions arising from translation and adaptation or otherwise.