
K-means Clustering for Glycomics and Glycoproteomics Data
gly_kmeans.RdPerform k-means clustering on the expression data.
The function uses stats::kmeans() to perform clustering and provides
tidy results with cluster assignments.
Arguments
- exp
A
glyexp::GlycomicSE()orglyexp::GlycoproteomicSE()object, or anotherSummarizedExperimentcontaining an expression matrix and sample information.- on
A character string specifying what to cluster. Either "variable" (default) to cluster variables/features, or "sample" to cluster samples/observations.
- centers
Either the number of clusters (integer) or a set of initial cluster centers. Default is 3.
- scale
A logical indicating whether to scale the data before clustering. Default is TRUE.
- add_info
A logical value. If TRUE (default), sample information from the experiment will be added to the result tibbles. If FALSE, only the clustering results are returned.
- ...
Additional arguments passed to
stats::kmeans().
Value
A list with three elements:
tidy_result: A tibble with cluster assignments containing the following columns:variableorsample: Variable or sample name (depending ononparameter)cluster: Cluster assignment
raw_result: The raw kmeans object fromstats::kmeans().meta_data: A list containing metadata from the input experiment
Details
The function performs log2 transformation on the expression data (log2(x + 1e-6)) before
clustering. When on = "variable" (default), variables are clustered based on their
expression patterns across samples. When on = "sample", samples are clustered based
on their expression profiles across variables.
Data Preparation: Data is log2-transformed and optionally scaled before clustering.
Clustering Method:
K-means clustering is performed using stats::kmeans() with the specified parameters.
Required packages
This function only uses base R packages and does not require additional dependencies.