Skip to contents

Generates the response profile of one or more observations i.e. plots of one or more rows of the outcomes matrix on the y-axis against the \(m\) response variables on the x-axis. Depending on the response type (spectra, gene expression...), point, line or segment plots can be used.

Usage

plotLine(
  Y = NULL,
  lmpDataList = NULL,
  rows = 1,
  type = c("l", "p", "s"),
  title = "Line plot",
  xlab = NULL,
  ylab = NULL,
  xaxis_type = c("numeric", "character"),
  stacked = FALSE,
  ncol = 1,
  nrow = NULL,
  facet_label = NULL,
  hline = 0,
  size = 0.5,
  color = NULL,
  shape = 1,
  theme = theme_bw(),
  ang_x_axis = NULL
)

Arguments

Y

A numerical matrix containing the rows to be drawn. Can be NULL if lmpDataList is defined.

lmpDataList

If not NULL, a list with outcomes, design and formula, as outputted by data2LmpDataList.

rows

A vector with either the row name(s) of the \(Y\) matrix to plot (character) or the row index position(s) (integer). Default to 1.

type

Type of graph to be drawn: "p" for point, "l" for line (default) or "s" for segment.

title

Plot title.

xlab

If not NULL, label for the x-axis.

ylab

If not NULL, label for the y-axis.

xaxis_type

The data type of the x-axis: either "numeric" (default) or "character".

stacked

Logical. If TRUE, will draw stacked plots, otherwise will draw separate plots.

ncol

If stacked is FALSE, the number of columns to represent the separate plots. Default to 1.

nrow

If stacked is FALSE, the number of rows to represent the separate plots.

facet_label

If stacked is FALSE, the labels of the separate plots.

hline

If not NULL, draws (a) horizontal line(s), by default at y intercept = 0.

size

Argument of length 1 giving the points size (if type == "p") or the line size (if type == "l" or "s").

color

If not NULL, argument of length 1 with possible values: "rows", a color name (character) or a numeric value representing a color.

shape

The points shape (default = 1) if type == "p".

theme

The ggplot2 theme (default: theme_bw()), see ?ggtheme for more info.

ang_x_axis

If not NULL, rotation angle to rotate the x-axis text (based on the argument axis.text.x from ggplot2::theme())

Value

A ggplot2 line plot.

Details

Either Y or lmpDataList need to be defined. If both are given, the priority goes to Y.

Examples


data("UCH")
plotLine(Y = UCH$outcomes)


plotLine(lmpDataList = UCH)


# separate plots
plotLine(Y = UCH$outcomes, rows = seq(1, 8), hline = NULL)

plotLine(Y = UCH$outcomes, rows = seq(1, 8), color = 2)

plotLine(Y = UCH$outcomes, rows = seq(1, 8), ncol = 2)

plotLine(
  Y = UCH$outcomes, type = "p",
  rows = seq(1, 8), ncol = 2
)


# stacked plots
library(ggplot2)
plotLine(
  Y = UCH$outcomes, rows = seq(1, 1),
  stacked = TRUE, color = "rows"
) +
  scale_color_brewer(palette = "Set1")