Learn R Programming

mdpeer (version 1.0.1)

vizu.mat.factor: Visualize matrix data in a form of a heatmap, with categorical values legend

Description

Matrix data visualization in a form of a heatmap, with the use of ggplot2 library. Numerical values are represented as categorical. Minimum user input (a matrix object) is needed to produce decent visualization output. Further plot adjustments are available, including tile color change, adding a title, font size change, axis label clearing and others.

Usage

vizu.mat.factor(matrix.object, title = "", base_size = 12,
  scale_fill_manual.values = NULL, geom_tile.colour = "grey90",
  clear.labels = TRUE, clear.x.label = FALSE, clear.y.label = FALSE,
  uniform.labes = FALSE, rotate.x.labels = FALSE, x.lab = "",
  y.lab = "", axis.text.x.size = base_size - 2,
  axis.text.y.size = base_size - 2, axis.title.x.size = base_size - 2,
  axis.title.y.size = base_size - 2, legend.text.size = base_size - 2,
  legend.title.size = base_size - 2, legend.title = "value",
  text.font.family = "Helvetica", remove.legend = FALSE,
  factor.levels = NULL, axis.text.x.breaks.idx = NULL,
  axis.text.y.breaks.idx = NULL)

Arguments

matrix.object
matrix
title
plot title
base_size
base font size
scale_fill_manual.values
vector of legend colors for categorical values
geom_tile.colour
tiles color value
clear.labels
logical whether or not clear both x- and y-axis labels
clear.x.label
logical whether or not clear x-axis labels
clear.y.label
logical whether or not clear y-axis labels
uniform.labes
logical whether or not define generic short column and rows labeling:
  • 'c1','c2',...,'cp' for columns,
  • 'r1','r2',...,'rp' for rows; might be especially useful if the matrix some long colnames and rownames already assigned
rotate.x.labels
logical whether or not rotate x-axis labels by 90 degrees
x.lab
x-axis label
y.lab
y-axis label
axis.text.x.size
font size of x-axis text
axis.text.y.size
font size of y-axis text
axis.title.x.size
font size of x-axis label
axis.title.y.size
font size of y-axis label
legend.text.size
font size of legend text
legend.title.size
font size of legend title
legend.title
legend title
text.font.family
font family
remove.legend
logical whether or not remove legend
factor.levels
vector of values defining levels of factors (might be used to redefine order of variables in the legend)
axis.text.x.breaks.idx
indices of x-axis elements whose thicks are kept and whose numerical labels are kept
axis.text.y.breaks.idx
indices of y-axis elements whose thicks are kept and whose numerical labels are kept

Value

ggplot2 object

Examples

Run this code
mat <- diag(30)
vizu.mat.factor(mat)
vizu.mat.factor(mat, 
                title = "some title",
                scale_fill_manual.values = c("white","red"),
                axis.text.x.breaks.idx = seq(1,30,5),
                axis.text.y.breaks.idx = seq(1,30,5))
vizu.mat.factor(mat, 
                title = "some title: large font, legend: small font",
                base_size = 20, 
                legend.text.size  = 10, 
                legend.title.size = 10)
vizu.mat.factor(mat, 
                scale_fill_manual.values = c("white","red"),
                clear.labels = FALSE) 
colnames(mat) <- paste0("col", 1:30, sample(LETTERS, 30, replace = TRUE))
rownames(mat) <- paste0("row", 1:30, sample(LETTERS, 30, replace = TRUE))
vizu.mat.factor(mat, 
                clear.labels = FALSE,
                rotate.x.labels = TRUE) 

Run the code above in your browser using DataLab