Learn R Programming

svdvis (version 0.1)

svd.heatmap: Visualizing Singular Vectors or Principal Components by Heatmaps

Description

Creates a heatmap from selected singular vectors or principal components. Principal components can be plotted by setting weights = "sv". Colors for heatmap can be specified by optional arguments low and high colors.

Usage

svd.heatmap(svd.obj, r = NULL, group = NULL, weights = NULL, alpha = 0.7, low = "#FFFFFF", high = "#9E0142")

Arguments

svd.obj
A list, resulted from applying svd to a dataset, with u, d, and v corresponding to left singular vector, singular values, and right singular vectors, respectively. Alternatively, supply singular vectors, v.
r
A positive integer to use only the first r vectors in visualization. If not specified, all vectors available in svd.obj$v are visualized.
group
A vector of length n, specifying groups (e.g., phenotypes or conditions for n samples).
weights
A vector of length r. If "sv", singular values contained in svd.obj$d[1:r] are used.
alpha
A numeric value for transparency.
low
A hex color code to color the lowest value.
high
A hex color code to color the highest value.

Value

svd.heatmap creates and draws a figure, which is a ggplot object.

Examples

Run this code
set.seed(1234)
dat = matrix(rnorm(1000), 100, 10)
svd.obj = svd(dat)
colnames(svd.obj$v) = paste0("V",1:10)
rownames(svd.obj$v) = paste0("Sample",1:10)
svd.heatmap(svd.obj, r=5)

Run the code above in your browser using DataLab