Type: | Package |
Title: | Colorful Hierarchical Clustering Dendrograms |
Version: | 1.5.1 |
Date: | 2025-06-02 |
Encoding: | UTF-8 |
Maintainer: | Damiano Fantini <damiano.fantini@gmail.com> |
Description: | Build dendrograms with sample groups highlighted by different colors. Visualize results of hierarchical clustering analyses as dendrograms whose leaves and labels are colored according to sample grouping. Assess whether data point grouping aligns to naturally occurring clusters. |
Depends: | R (≥ 3.0) |
Imports: | graphics, methods |
Suggests: | stats, grDevices, rmarkdown, knitr |
VignetteBuilder: | knitr |
License: | GPL-3 |
RoxygenNote: | 7.3.2 |
NeedsCompilation: | no |
Packaged: | 2025-06-03 13:19:44 UTC; dami |
Author: | Damiano Fantini [aut, cre] |
Repository: | CRAN |
Date/Publication: | 2025-06-04 12:00:11 UTC |
Introduction to the colorhcplot Package
Description
This is a simple one-function package. Please, refer to the colorhcplot() function manual to check how the function works.
Details
This package contains the function colorhcplot. This function generates simple colorful dendrograms and requires only 2 mandatory arguments: hc and fac. The argument hc is the result of a hclust() call, while fac is a factor defining the groups. Therefore, the number of leaves of the dendrogram has to be identical to the length of fac (i.e., length(hc$labels) == length(fac) has to be TRUE). The function colorhcplot() employs a custom color palette. However, users can specify a custom list of colors.
Author(s)
Damiano Fantini [aut, cre]
See Also
Colorful Hierarchical Clustering Dendrograms
Description
Build colorful dendrograms based on a "hclust-class" object and a factor describing the sample groups. Leaves belonging to different groups are identified by colors, and the resulting plot enables detection of pure clusters where all leaves belong to the same group.
Usage
colorhcplot(
hc,
fac,
hang = 0.1,
main = "Cluster Dendrogram",
colors = NULL,
lab.cex = 1,
ylim = NULL,
lwd = 3,
las = 1,
lab.mar = 0.55
)
Arguments
hc |
hclust-class object, typically the result of a 'hclust()' function call. |
fac |
factor that defines the grouping. |
hang |
hang value, as in |
main |
string, title of the dendrogram plot. |
colors |
NULL or a character vector of length 1 or having the same length as the number of levels in fac. This argument defines the palette for the plot. |
lab.cex |
numeric value for adjusting the font size of the leaf labels (and legend text). |
ylim |
numeric, defines the minimum and maximum value of the y-axis of the plot. |
lwd |
numeric value that defines the width (in points) of the lines of the dendogram. |
las |
numeric value, graphic parameter for the orientation of the y-axis tick labels. |
lab.mar |
numeric value, fraction of the plot area that is reserved for the labels (at the bottom of the plot). |
Details
In order to generate a colorful dendrogram, the colorhcplot() function requires 2 mandatory arguments: hc and fac. hc is the result of a hclust() call, while fac is a factor defining the groups. The number of leaves of the dendrogram has to be identical to the length of fac.
Value
Calling colorhcplot() returns a colorful dendrogram plot.
Note
Online colorhcplot() function reference at: http://www.biotechworld.it/bioinf/2015/09/30/colorful-hierarchical-clustering-dendrograms-with-r/
Author(s)
Damiano Fantini <damiano.fantini@gmail.com>
See Also
Examples
### Example 1, using the USArrests dataset
data(USArrests)
hc <- hclust(dist(USArrests), "ave")
fac <- as.factor(c(rep("group 1", 10),
rep("group 2", 10),
rep("unknown", 30)))
plot(hc)
colorhcplot(hc, fac)
colorhcplot(hc, fac, hang = -1, lab.cex = 0.8)
### Example 2: use the "ward.D2" algorithm and
### the UScitiesD dataset
data(UScitiesD)
hcity.D2 <- hclust(UScitiesD, "ward.D2")
fac.D2 <-as.factor(c(rep("group1", 3),
rep("group2", 7)))
plot(hcity.D2, hang=-1)
colorhcplot(hcity.D2, fac.D2, color = c("chartreuse2", "orange2"))
colorhcplot(hcity.D2, fac.D2, color = "gray30",
lab.cex = 1.2, lab.mar = 0.75)
### Example 3: use gene expression data
data(geneData, package="colorhcplot")
exprs <- geneData$exprs
fac <- geneData$fac
hc <- hclust(dist(t(exprs)))
colorhcplot(hc, fac, main ="default", col = "gray10")
colorhcplot(hc, fac, main="Control vs. Tumor Samples")
Example Gene Expression Dataset
Description
This is a gene expression dataset simulating information about 499 gene probes and 13 samples, from an Affymetrix U95v2 chip. Data are made up, as well as sample labels. This dataset is adapted from the Biobase-package, version 2.32.0.
Usage
data("geneData")
Format
A list with 2 elements:
- exprs
A matrix with 499 rows (genes) and 13 columns (samples) containing normalized gene expression values.
- fac
A factor including the grouping for each sample.
Source
Data were adapted from the Biobase package version 2.32.0, and prepared by the J. Ritz Laboratory (S. Chiaretti).
Examples
data(geneData)
print(geneData[[1]][1:10, 1:6])