plot_matrix: Visualize a matrix with one or two-way color scale.

Description Usage Arguments Value Author(s) References Examples

View source: R/plot_matrix.R

Description

Fast investigation of matrix objects; standard visualization choices are made automatically; fast and easy-to-use but does not necessarily provide optimal visualization.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
plot_matrix(
  mat,
  type = "twoway",
  midpoint = 0,
  palette = NULL,
  colors = NULL,
  col.breaks = NULL,
  interval = 0.1,
  plot_axes = "both",
  row.tick = 1,
  col.tick = 1,
  cex.xlab = 0.9,
  cex.ylab = 0.9,
  xlab = NULL,
  ylab = NULL,
  limit.trunc = 0,
  mar = c(5, 4, 4, 2),
  ...
)

Arguments

mat

matrix

type

String. Specifies visualization type. Options: 'oneway' (color scale ranges from white to dark red; the color can be changed if needed); 'twoway' (color scale ranges from dark blue through white to dark red; colors can be changed if needed)

midpoint

middle point for the color plot: smaller values are shown with blue, larger are shown with red in type = 'twoway'

palette

Optional. Color palette.

colors

Optional. Colors.

col.breaks

breakpoints for the color palette

interval

interval for palette color switches

plot_axes

String. Indicates whether to plot x-axis ('x'), y-axis ('y'), or both ('both').

row.tick

interval for plotting row axis texts

col.tick

interval for plotting column axis texts

cex.xlab

use this to specify distinct font size for the x axis

cex.ylab

use this to specify distinct font size for the y axis

xlab

optional x axis labels

ylab

optional y axis labels

limit.trunc

color scale limit breakpoint

mar

image margins

...

optional parameters to be passed to function 'image', see help(image) for further details

Value

A list with the color palette (colors), color breakpoints (breaks), and palette function (palette.function)

Author(s)

Leo Lahti microbiome-admin@googlegroups.com

References

See citation('microbiome')

Examples

1
2
  mat <- rbind(c(1,2,3,4,5), c(1, 3, 1), c(4,2,2))
  plot_matrix(mat, 'twoway', midpoint = 3) 

Example output

Loading required package: Rgraphviz
Loading required package: graph
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Loading required package: grid
Loading required package: minet
Loading required package: mclust
Package 'mclust' version 5.4.2
Type 'citation("mclust")' for citing this R package in publications.
Loading required package: reshape2

netresponse (C) 2008-2016 Leo Lahti et al.

https://github.com/antagomir/netresponse
Warning message:
In .Method(..., deparse.level = deparse.level) :
  number of columns of result is not a multiple of vector length (arg 2)
$colors
 [1] "#0000FF" "#0C0CFF" "#1919FF" "#2626FF" "#3333FF" "#3F3FFF" "#4C4CFF"
 [8] "#5959FF" "#6666FF" "#7272FF" "#7F7FFF" "#8C8CFF" "#9999FF" "#A5A5FF"
[15] "#B2B2FF" "#BFBFFF" "#CCCCFF" "#D8D8FF" "#E5E5FF" "#F2F2FF" "#FFFFFF"
[22] "#FFF2F2" "#FFE5E5" "#FFD8D8" "#FFCBCB" "#FFBFBF" "#FFB2B2" "#FFA5A5"
[29] "#FF9898" "#FF8C8C" "#FF7F7F" "#FF7272" "#FF6565" "#FF5959" "#FF4C4C"
[36] "#FF3F3F" "#FF3232" "#FF2626" "#FF1919" "#FF0C0C" "#FF0000"

$breaks
 [1] -999998.90       1.05       1.15       1.25       1.35       1.45
 [7]       1.55       1.65       1.75       1.85       1.95       2.05
[13]       2.15       2.25       2.35       2.45       2.55       2.65
[19]       2.75       2.85       2.95       3.05       3.15       3.25
[25]       3.35       3.45       3.55       3.65       3.75       3.85
[31]       3.95       4.05       4.15       4.25       4.35       4.45
[37]       4.55       4.65       4.75       4.85       4.95 1000004.90

$palette.function
function (n) 
{
    x <- ramp(seq.int(0, 1, length.out = n))
    if (ncol(x) == 4L) 
        rgb(x[, 1L], x[, 2L], x[, 3L], x[, 4L], maxColorValue = 255)
    else rgb(x[, 1L], x[, 2L], x[, 3L], maxColorValue = 255)
}
<bytecode: 0x8038648>
<environment: 0x80392f0>

netresponse documentation built on Nov. 8, 2020, 5:04 p.m.