library(devtools)
## Loading required package: usethis
#install_github("jokergoo/ComplexHeatmap")
#install_github("cran/hopach")
#install.packages("circlize")
if (!requireNamespace("BiocManager", quietly = TRUE)) {
install.packages("BiocManager")
}
BiocManager::install("hopach", update = FALSE, ask = FALSE)
## Bioconductor version 3.22 (BiocManager 1.30.27), R 4.5.3 (2026-03-11)
## Warning: package(s) not installed when version(s) same as or greater than current; use
## `force = TRUE` to re-install: 'hopach'
library(ComplexHeatmap)
## Loading required package: grid
## ========================================
## ComplexHeatmap version 2.25.3
## Bioconductor page: http://bioconductor.org/packages/ComplexHeatmap/
## Github page: https://github.com/jokergoo/ComplexHeatmap
## Documentation: http://jokergoo.github.io/ComplexHeatmap-reference
##
## If you use it in published research, please cite either one:
## - Gu, Z. Complex Heatmap Visualization. iMeta 2022.
## - Gu, Z. Complex heatmaps reveal patterns and correlations in multidimensional
## genomic data. Bioinformatics 2016.
##
##
## The new InteractiveComplexHeatmap package can directly export static
## complex heatmaps into an interactive Shiny app with zero effort. Have a try!
##
## This message can be suppressed by:
## suppressPackageStartupMessages(library(ComplexHeatmap))
## ========================================
library(circlize)
## ========================================
## circlize version 0.4.18
## CRAN page: https://cran.r-project.org/package=circlize
## Github page: https://github.com/jokergoo/circlize
## Documentation: https://jokergoo.github.io/circlize_book/book/
##
## If you use it in published research, please cite:
## Gu, Z. circlize implements and enhances circular visualization
## in R. Bioinformatics 2014.
##
## This message can be suppressed by:
## suppressPackageStartupMessages(library(circlize))
## ========================================
library(hopach)
## Loading required package: cluster
## Loading required package: Biobase
## Loading required package: BiocGenerics
## Loading required package: generics
##
## Attaching package: 'generics'
## The following objects are masked from 'package:base':
##
## as.difftime, as.factor, as.ordered, intersect, is.element, setdiff,
## setequal, union
##
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:stats':
##
## IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
##
## anyDuplicated, aperm, append, as.data.frame, basename, cbind,
## colnames, dirname, do.call, duplicated, eval, evalq, Filter, Find,
## get, grep, grepl, is.unsorted, lapply, Map, mapply, match, mget,
## order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
## rbind, Reduce, rownames, sapply, saveRDS, table, tapply, unique,
## unsplit, which.max, which.min
## Welcome to Bioconductor
##
## Vignettes contain introductory material; view with
## 'browseVignettes()'. To cite Bioconductor, see
## 'citation("Biobase")', and for packages 'citation("pkgname")'.
##
## Attaching package: 'hopach'
## The following object is masked from 'package:generics':
##
## prune
head(mtcars)
## mpg cyl disp hp drat wt qsec vs am gear carb
## Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4
## Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4
## Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1
## Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1
## Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2
## Valiant 18.1 6 225 105 2.76 3.460 20.22 1 0 3 1
data<-mtcars[, c(1:7)]
data.scale<-scale(data)
head(data.scale)
## mpg cyl disp hp drat
## Mazda RX4 0.1508848 -0.1049878 -0.57061982 -0.5350928 0.5675137
## Mazda RX4 Wag 0.1508848 -0.1049878 -0.57061982 -0.5350928 0.5675137
## Datsun 710 0.4495434 -1.2248578 -0.99018209 -0.7830405 0.4739996
## Hornet 4 Drive 0.2172534 -0.1049878 0.22009369 -0.5350928 -0.9661175
## Hornet Sportabout -0.2307345 1.0148821 1.04308123 0.4129422 -0.8351978
## Valiant -0.3302874 -0.1049878 -0.04616698 -0.6080186 -1.5646078
## wt qsec
## Mazda RX4 -0.610399567 -0.7771651
## Mazda RX4 Wag -0.349785269 -0.4637808
## Datsun 710 -0.917004624 0.4260068
## Hornet 4 Drive -0.002299538 0.8904872
## Hornet Sportabout 0.227654255 -0.4637808
## Valiant 0.248094592 1.3269868
Heatmap(data.scale, name = "mtcars heatmap",
cluster_rows=FALSE , cluster_columns = FALSE)
Heatmap(data.scale, name = "mtcars heatmap",
cluster_columns = FALSE)
Heatmap(data.scale, name = "mtcars heatmap")
uncenter.dist<-function(m) {
as.dist(as.matrix(distancematrix(m, d="cosangle")))
}
row.clus<-hclust(uncenter.dist(data.scale), method = "ave")
col.clus<-hclust(uncenter.dist(t(data.scale)), method = "ave")
Heatmap(data.scale, name = "mtcars heatmap",
cluster_rows=row.clus, cluster_columns=col.clus)
ht_inline<-Heatmap(mtcars[, c(8)], name = "Cylinder Config",
col = colorRamp2(c(0,1),c("white", "black")),
heatmap_legend_param = list(at = c(0,1),
labels = c("V-shaped", "Inline")),
width = unit(0.5,"cm"))
ht_manual<-Heatmap(mtcars[, c(9)], name = "Transmission",
col = colorRamp2(c(0,1),c("white", "black")),
heatmap_legend_param = list(at = c(0,1),
labels = c("Automatic", "Manual")),
width = unit(0.5,"cm"))
ht_main = Heatmap(data.scale, name = "cluster rows",
cluster_rows=row.clus, cluster_columns = col.clus)
draw(ht_main+ht_manual+ht_inline, auto_adjust = FALSE)
draw(ht_main+ht_manual+ht_inline)
To make the clusters easier to distinguish, we split the heatmap into two labeled slices using Gestalt principles of proximity and visual grouping, while reducing the font size and tuning the margins to prevent car names from overlapping after setting auto_adjust = FALSE. Also, the title of the heatmap is added. The visualization reveals two distinct vehicle profiles: the “Fuel Efficient” cluster features high gas mileage (mpg), lighter weight (wt), and lower horsepower (hp) with smaller engine displacement, predominantly paired with manual transmissions and straight (in-line) engines; conversely, the “Fuel Inefficient” cluster consists of heavier, high-horsepower vehicles with lower mpg and larger engines, which are mostly equipped with automatic transmissions and V-shaped engines.
library(grid)
ht_main = Heatmap(data.scale, name = "cluster rows",
cluster_rows=row.clus, cluster_columns = col.clus,
row_split = 2,
row_title = c("fuel efficient", "fuel inefficient"),
row_title_rot = 0,
row_names_gp = gpar(fontsize = 6),
column_names_gp = gpar(fontsize = 9),
row_title_gp = gpar(fontsize = 10))
draw(ht_main+ht_manual+ht_inline, auto_adjust = FALSE,
column_title = "Hierarchical Clustering Analysis of mtcars Dataset",
column_title_gp = gpar(fontsize = 12, fontface = "bold"))
Following Approach 1, the top boxplot annotation illustrates the distribution of column values across all 32 car models. Also, the title for the heatmap is added. The median line for each metric (hp, wt, cyl, disp, qsec, mpg, and drat) hovers near 0, with values spanning roughly between -2 and +2, confirming our prior standardization process (Z-score scaling). Additionally, mpg and drat exhibit longer upper whiskers and higher extreme values, highlighting the presence of notable high-end outliers in fuel efficiency and rear-axle gear ratios within the dataset.
anno <- HeatmapAnnotation(
Distribution = anno_boxplot(
data.scale,
height = unit(2, "cm"),
gp = gpar(fill = "#e0e0e0"),
box_width = 0.9,
outline = FALSE
),
annotation_name_side = "left",
annotation_name_gp = gpar(fontsize = 9)
)
ht_main = Heatmap(data.scale, name = "cluster rows",
top_annotation = anno,
cluster_rows=row.clus, cluster_columns = col.clus,
row_split = 2,
row_title = c("fuel efficient", "fuel inefficient"),
row_title_rot = 0,
row_names_gp = gpar(fontsize = 6),
column_names_gp = gpar(fontsize = 9),
row_title_gp = gpar(fontsize = 10))
draw(ht_main+ht_manual+ht_inline, auto_adjust = FALSE,
column_title = "Hierarchical Clustering Analysis of mtcars Dataset",
column_title_gp = gpar(fontsize = 12, fontface = "bold"))
In Approach 3, we implemented k-means clustering by manually defining the cluster count k, in contrast to hierarchical clustering, which partitions data by slicing an existing tree topology via branch cuts (row_split and column_split). Also, the title of the plot is added. Interestingly, while both methods cleanly separated performance and engine metrics (hp, wt, cyl, disp) from efficiency and transmission metrics (mpg, drat, qsec), the cluster index assignment reversed between them: hierarchical clustering grouped the engine power metrics into Cluster 1 and the fuel efficiency metrics into Cluster 2, whereas k-means designated the fuel efficiency metrics as Cluster 1 and the engine power metrics as Cluster 2 due to the arbitrary nature of initial centroid labeling.
ht_main = Heatmap(data.scale, name = "cluster rows",
row_km = 2, row_km_repeats = 100,
column_km = 2, column_km_repeats = 100,
row_title = c("fuel efficient", "fuel inefficient"),
row_names_gp = gpar(fontsize = 6),
column_names_gp = gpar(fontsize = 9),
row_title_gp = gpar(fontsize = 10))
draw(ht_main+ht_manual+ht_inline, auto_adjust = FALSE,
column_title = "K-Means Clustering Analysis (2 Clusters)",
column_title_gp = gpar(fontsize = 14, fontface = "bold"))
A Hierarchical Cluster Analysis of AI-Supported Learning in Higher Education
This study identifies profiles of university students’ perceived experiences with generative AI-supported learning, in which examines how perceived AI benefits occur alongside teacher responsibility, collaboration with fellow students, and psychological well-being. For instance, one student may report strong benefits from AI yet little peer exchange; another may report moderate AI benefits within a supportive, collaborative course. Describing these configurations using the hierarchical cluster analysis (HCA) heatmap helps educators examine the social context of AI-supported learning without reducing learning to grades.
Self-determination theory suggests that learning environments supporting competence, autonomy, and relatedness can shape engagement and well-being (Ryan & Deci, 2020). It provides a rationale for examining AI-supported learning in relation to human support. Supportive relationships can also benefit well-being generally and buffer the harmful effects of stressful experiences when the available support matches a person’s needs (Cohen & Wills, 1985). Applied to education, teacher guidance and peer feedback may provide practical help, reassurance, and a sense of belonging. In a study of 364 university language learners using a GenAI chatbot, Li and Chiu (2025) found that perceived teacher support and need satisfaction were related to several forms of engagement. A separate higher-education study examined teacher responsibility, AI integration, peer collaboration, and well-being together (Li et al., 2025), where their model linked teacher responsibility to well-being indirectly through AI integration, with this indirect association stronger when peer collaboration was higher. These studies explain why the four dimensions belong in the same study, but their variable-centered analyses summarize relationships across students. An average positive association cannot tell us whether some students report strong AI benefits with little peer collaboration while others report the reverse. The gap here is a person-level account of how these experiences occur together, and whether any groups differ in their balance of AI benefit and human support rather than only in their general tendency to agree. There are also some existing studies used the HCA heatmap method. Lee et al. (2016) used hierarchical clustering and heatmaps to reveal different university students’ Canvas activity patterns, where their measures were LMS traces instead of survey perceptions. Reverter et al. (2020) applied hierarchical clustering with heatmaps to student course and teaching evaluations, while their cluster is based on evaluation questions. When exploring the AI topic, Saihi and Ahmed (2026) clustered higher-education users’ survey responses into distinct GenAI-chatbot adoption personas using hierarchical clustering followed by k-means. Together, these studies support using a student-level clustergram to examine whether perceived AI benefit, teacher responsibility, peer collaboration, and well-being form meaningful profiles.
Hierarchical clustering groups students with similar patterns across the 32 survey items without assuming the number of groups in advance. The heatmap displays students as rows, ordered by a dendrogram, and the individual items as columns grouped under teacher-responsibility (TR), AI-supported learning-effectiveness (ASLE), fellow-student-collaboration (FSC), and psychological-well-being (SPW). A fixed diverging color scale shows each original five-point response: dark blue for strongly disagree (1), a neutral color for neither agree nor disagree (3), and dark red for strongly agree (5). The figure therefore shows both student clusters and the item-level answers that characterize them. ComplexHeatmap in R provides the clustered heatmap and construct labels; the full matrix is exported at high resolution, with enlarged excerpts for print. The colors encode responses, while the dendrogram reflects similarity calculated separately from those responses.
The study addresses the following questions: RQ1: To what extent do university students exhibit distinct profiles across perceived AI-supported learning effectiveness, teacher responsibility, and fellow-student collaboration? RQ2: To what extent do the psychological well-being and identified profiles differ in the balance of perceived AI benefit and human support?
This study requires linked, respondent-level answers to all four constructs. Nguyen’s (2026) open survey of 1,558 university students in Vietnam provides a feasible dataset. Its deposited spreadsheet contains 32 five-point items: 13 TR items, four ASLE items, four FSC items, and 11 SPW items, plus five demographic variables (gender, type of university, year of study, major, duration of generative AI use). The cross-sectional survey measures perceptions at one time point. It does not measure actual learning gains or change over time, but it supports an exploratory visualization of response patterns. 6. What data and variables does the study examine?
The study retains each student’s responses to all 32 items. ASLE1–ASLE4 cover perceived learning effectiveness, outcomes or grades, benefits relative to working alone, and academic skills; these are perceptions, not recorded grades. The 13 TR items address teacher responsibility, four FSC items address exchanging ideas, coordinating tasks, discussion, and feedback, and 11 SPW items address psychological well-being. Each heatmap cell shows the original 1-5 Likert scale response. After checking coding and scale reliability, the study summarizes the 11 SPW items as a mean well-being score and displays it as a separate row annotation with its own legend. The similarity calculation weights the four constructs equally so that TR do not dominate merely because they have more items. Demographics and duration of regular AI use appear as separate annotations or describe the resulting clusters after their coding is checked; they do not determine cluster membership.
The study organizes the data as a matrix with one student per row and 21 TR, ASLE, and FSC items as columns. Before clustering, it adjusts the item blocks, so teacher responsibility and well-being do not count more simply because they contain more questions. It then compares each pair of students using uncentered Pearson correlation across their responses. In general terms, student dissimilarity equals 1 minus that correlation. Agglomerative hierarchical clustering then begins with each student separately and uses average linkage. The distance between two clusters is the average dissimilarity across all pairs of students in those clusters. The two closest clusters merge at each step, producing a dendrogram. In R, ComplexHeatmap (Gu et al., 2016) displays that dendrogram alongside the original 1-5 score answers, colored from blue (strongly disagree) to red (strongly agree), with columns grouped by construct. A weighted Euclidean sensitivity analysis repeats the clustering with average linkage and the same construct weights, so that it can. This checks whether broad profiles change when similarity reflects absolute response levels as well as patterns. SPW remains excluded from both clustering analyses. The study compares SPW distributions across the resulting profiles, using the annotation to visualize these comparisons. Because uncentered correlation emphasizes the pattern of answers instead of overall agreement level, the study also checks whether the broad clusters change when a distance that preserves response levels is used.
The study may find differences in the balance among perceived AI benefit, teacher support, peer collaboration, and well-being. For example, some students may report stronger AI benefits than peer collaboration, while others show the opposite pattern. Uncentered correlation can primarily detect relative response patterns, so students whose ratings differ only in overall level may cluster together. The weighted Euclidean sensitivity analysis shows whether a high-versus-low response pattern also matters. If the clusters mainly reflect a general tendency to agree, the study can report that as limitation instead of claiming distinct educational experiences.
References
Cohen, S., & Wills, T. A. (1985). Stress, social support, and the buffering hypothesis. Psychological Bulletin, 98(2), 310–357. https://doi.org/10.1037/0033-2909.98.2.310 Gu, Z., Eils, R., & Schlesner, M. (2016). Complex heatmaps reveal patterns and correlations in multidimensional genomic data. Bioinformatics, 32(18), 2847–2849. https://doi.org/10.1093/bioinformatics/btw313 Lee, J. E., Recker, M., Bowers, A. J., & Yuan, M. (2016). Hierarchical cluster analysis heatmaps and pattern analysis: An approach for visualizing learning management system interaction data. In Proceedings of the 9th International Conference on Educational Data Mining (pp. 603–604). https://files.eric.ed.gov/fulltext/ED592609.pdf Li, H., Zhang, J., Khan, W. A., & Lamsali, H. (2025). Teacher responsibility, AI integration, and student well-being: The role of peer collaboration in higher education. Acta Psychologica, 260, 105532. https://doi.org/10.1016/j.actpsy.2025.105532 Li, Y., & Chiu, T. K. F. (2025). The mediating effects of needs satisfaction on the relationship between teacher support and student engagement with generative artificial intelligence (GenAI) chatbots from a self-determination theory (SDT) perspective. Education and Information Technologies, 30, 20051–20070. https://doi.org/10.1007/s10639-025-13574-w Nguyen, X. (2026). Data on teacher responsibility, generative AI-supported learning effectiveness, fellow student collaboration, and students’ psychological well-being in higher education [Data set, Version 2]. Mendeley Data. https://doi.org/10.17632/zvdf6893rk.2 Reverter, A., Martinez, C., Currey, P., van Bommel, S., & Hudson, N. J. (2020). Unravelling student evaluations of courses and teachers. Cogent Education, 7(1), 1771830. https://doi.org/10.1080/2331186X.2020.1771830 Ryan, R. M., & Deci, E. L. (2020). Intrinsic and extrinsic motivation from a self-determination theory perspective: Definitions, theory, practices, and future directions. Contemporary Educational Psychology, 61, 101860. https://doi.org/10.1016/j.cedpsych.2020.101860 Saihi, A., & Ahmed, V. (2026). Uncovering adoption personas for generative AI in higher education: A clustering-based segmentation approach. International Journal of Educational Technology in Higher Education, 23, 7. https://doi.org/10.1186/s41239-026-00583-z