plotClusters: plots cluster averages

Description Usage Arguments

View source: R/clusterTools.R

Description

plots average time series of clusters as calculated by clusterAverages, including variations around the average as transparent areas, or all individual data. The function is quite flexible and allows to normalize the data and set automatic y-limit selections.

Usage

1
2
3
4
5
6
7
8
plotClusters(x, cls, k, each = TRUE, type = "rng", time, time.at,
  avg = "median", q = 0.9, norm, cls.col, cls.srt, xlab, xlim, ylab,
  ylim = ifelse(each, "avg", "rng"), ylim.scale = 0.1,
  avg.col = "#000000", avg.lwd = 3, avg.cex = 1, avg.pch = 1,
  lwd = 0.5, use.lty = FALSE, alpha = 0.2, embed = FALSE,
  plot.legend = FALSE, leg.xy = "topleft", leg.ids, vline = "",
  vl_col = 0, vl_lwd = 3, vl_lty = 1, ref.xy, ref.col = "#C0C0C080",
  ref.ylab = "", ...)

Arguments

x

either a simple data matrix with time points (x-axis) in columns, or a processed time-series as provided by processTimeseries

cls

eiter a vector (length(cls)==nrow(x)) or a structure of class 'clustering' as returned by segmenTier's clusterTimeseries

k

integer or string specifiying the clustering (k: cluster numbers) to be used if cls is of class 'clustering'; if missing (default) the ‘selected’ clustering from cls is chosen (see selected).

each

logical value indicating whether to plot all cluster averages on one panel (FALSE) or each cluster on a separate panel (TRUE)

type

string specifying the type of plot: "rng" for plotting only data ranges (see argument q) or "all" to plot each individual time-course (as thin lines)

time

optional numeric vector specifiying x-axis time coordinates

time.at

argument at for the x-axis (axis(1, at=time.at))

avg

a function (or the name of a function as a string) for calculating an ‘average’ value for each cluster; default is the median

q

the fraction of data to be shown in the ranges plots: either numeric 0-1, or a function name for calculating variance (eg. "sd", "var"). Note that this parameter can also influence ylim, the limits of the y axis

norm

normalization of the time-series data, must be a function that transforms the data, available via segmenTools are lg2r, ash, log_1, meanzero normalizations

cls.col

optional named cluster color vector, where names indicate the clusters (as.caracter(cls)); if cls is of class 'clustering' it is taken from there

cls.srt

optional cluster sorting, can be used for selection of subsets of clusters; if cls is of class 'clustering' it is taken from there

xlab

x-axis label (auto-selected if missing)

xlim

xlim parameter for plot

ylab

y-axis label (only used if each==FALSE)

ylim

either conventional range of the y-axis, or a string specifying whether ylim should be calculated from the average (ylim="avg"), for all data (ylim="all"), or from the lower/upper ranges (ylim="rng"); in the latter case the y-axis depends on argument q

ylim.scale

if ylim=="avg", the calculated ylim will be extended by this fraction of the total range on both sides

avg.col

color for average line; used only if type="all"

avg.lwd

line width for average plots (if type=="all")

avg.cex

point size for average plots

avg.pch

point symbol for average plots

lwd

line width for indidiual time series plots (if type=="all")

use.lty

use individual line types (if type=="all"); this is only useful for very small clusters and is mainly used in the plotSingles wrapper

alpha

set alpha value of range or individual time series colors (color opaqueness)

embed

logical, if TRUE and argument each=TRUE (one plot for each cluster), the automatic is suppressed allowing to embed multiple plots (for each cluster) into external layout or par(mfcol/mfrow) setups

plot.legend

add a legend, useful for very small clusters and mainly used in the plotSingles wrapper

leg.xy

position of the legend, see legend

leg.ids

a named vector providing alternative IDs for legends; the names should correspond to the rownames of clusterings in cls

vline

adds a vertical line at position x[i]

vl_col

color for vertical line (default to cluster colour)

vl_lwd

vertical line width

vl_lty

vertical line type

ref.xy

reference data (either x or xy coordinates, see xy.coords) for reference data to be plotted in the background, e.g. light/dark phases or dissolved oxygen traces

ref.col

color for reference data plot

ref.ylab

y-axis label (right y-axis) for reference data

...

further arguments to the basic setup call to plot


raim/segmenTools documentation built on Nov. 9, 2018, 5:38 p.m.