plot_som | R Documentation |
This function plots the output of a self-organizing map.
plot_som( dat, type = "model", design = NULL, coef = NULL, stat = "lfc", sample = 1L, top = 0.5, grid_dims = NULL, topo = "hexagonal", neighb = "gaussian", rlen = 1000L, parallel = TRUE, pal_tiles = NULL, title = NULL, legend = "right", hover = FALSE, export = TRUE, ... )
dat |
Either a probe by sample omic data matrix or an object of class
|
type |
What should the plot visualize? Options include |
design |
Design matrix for linear model with rows corresponding to
samples and columns to model coefficients. Only relevant if |
coef |
Column number or name specifying which coefficient or contrast
of the linear model is of interest. Only relevant if |
stat |
Which nodewise summary statistic should be plotted in the SOM?
Options are |
sample |
Column number or name specifying which sample should be
plotted. Only relevant if |
top |
Optional number (if > 1) or proportion (if < 1) of most variable probes to be used for SOM. |
grid_dims |
Vector of length two specifying x- and y-axis dimensions for
the SOM grid. If |
topo |
Train SOM using |
neighb |
Train SOM using a |
rlen |
Run length for SOM training. |
parallel |
Allow for parallel computation of SOM? |
pal_tiles |
String specifying the color palette to use for heatmap
nodes. Defaults vary by |
title |
Optional plot title. |
legend |
Legend position. Must be one of |
hover |
Show constituent probes by hovering mouse over module tile? If
|
export |
Return fitted SOM model? |
... |
Additional arguments to be passed to |
A self-organizing map (SOM) is a type of neural network used for dimensionality reduction and data visualization. SOMs come in many flavors, but the kind used here clusters probes together in an unsupervised manner to identify functionally relevant gene sets, examine patterns across samples, and explore hypotheses. See the references below for more details on SOM algorithms and their applications for omic research.
If type = "model"
, then a linear model is fit to the codebook vectors.
Units are colored either by each node's log fold change (if stat =
"lfc"
) or moderated t-statistic as calculated by limma
(if
stat = "t"
) for a given model coefficient. Default color palette is
"Spectral"
.
If type = "sample"
, then the plot depicts that sample's expression
profile across the SOM. Default color palette is "Spectral"
.
If type = "distance"
, then the figure renders the SOM's U-matrix,
which represents the Euclidean distance between codebook vectors for
neighboring units. This can be used to inspect for clusters and borders
in the SOM space. Default color palette is "Greys"
.
If type = "counts"
, then units are colored by each node's probe
count. This distribution should ideally be nearly uniform. A large number of
empty units suggests that grid_dim
s should be reduced; an uneven
spread across the units suggests that grid_dim
s should be increased.
Default color palette is "Blues"
.
If type = "quality"
, then nodes are colored by the mean distance of
intra-unit probes from one another. Very large values or uneven distributions
suggest the SOM may need more training iterations to reach a stable solution.
Default color palette is "Reds"
.
If type = "train"
, then the plot displays the SOM's learning curve
over its rlen
training iterations.
Depending on the data's size, the model's parameters, and your computational
resources, it may take a considerable amount of time to fit a SOM to an
omic matrix. That is why plot_som
returns the SOM object by default,
which may in turn be reused in subsequent calls to the function to explore
alternative aspects of the map. SOMs are trained using the batch algorithm
of kohonen::som
. This may be executed in parallel for
faster mapping. See the package documentation for more details.
If dat
is an omic data matrix or matrix-like object and export
= TRUE
, then plot_som
returns an object of class kohonen
. This
is a fitted SOM as generated by the kohonen
package. See
som
for more details.
Kohonen, T. (1995). Self-Organizing Maps. Berlin: Springer-Verlag.
Nikkilä, J., Törönen, P., Kaski, S., Venna, J., Castrén, E., & Wong, G. (2002). Analysis and visualization of gene expression data using Self-Organizing Maps. Neural Networks, 15(8-9): 953-966.
Wehrens, R. & Buydens, L.M.C. (2007). Self- and Super-organizing Maps in R: The kohonen Package J. Stat. Softw., 21(5).
Wirth, H. (2012). Analysis of large-scale molecular biological data using self-organizing maps. Dissertation thesis, University of Leipzig.
som
mat <- matrix(rnorm(1000 * 5), nrow = 1000, ncol = 5) plot_som(mat, type = "sample", sample = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.