ggheatmap | R Documentation |
Given a data frame, a matrix or a list of matrices this function visualizes the given data by a heatmap utilizing ggplot2.
ggheatmap(x, id.vars = c("Var1", "Var2"), value.name = "value", show.diag = TRUE, type = "complete", range = NULL, show.values = FALSE, value.size = 1.5, value.color = "white", digits = 1L)
x |
[ |
id.vars |
[ |
value.name |
[ |
show.diag |
[ |
type |
[ |
range |
[ |
show.values |
[ |
value.size |
[ |
value.color |
[ |
digits |
[ |
If a data.frame is passed it needs to be in long format as expected by ggplot2. If a matrix is passed it is transformed internally into long format. In case a list of matrices is passed all those matrices are converted into long format and distinguished by the names of the list components. In the latter case a single ggplot object is produced adopting facets to split by matrix.
[ggplot
] ggplot object.
# simulate two (correlation) matrizes x = matrix(runif(100), ncol = 10) y = matrix(runif(100), ncol = 10) # matrix x in ggplot2-friendly long format x.df = reshape2::melt(x) ## Not run: # Single heatmap with default settings pl = plotHeatmap(x.df) # Show values and display lower triangular matrix only pl = plotHeatmap(x, show.values = TRUE, type = "lower.tri", show.diag = FALSE) # Now we omit value outside the interval [10, 80] pl = plotHeatmap(x, range = c(10, 80)) # Two heatmaps side by side pl = plotHeatmap(list(x, y), value.name = "Similarity") # Same as above with custom names pl = plotHeatmap(list(MatrixX = x, MatrixY = y), value.name = "Similarity") ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.