violin.electrophoresis: Violin plots of electrophoresis data

violin.electrophoresisR Documentation

Violin plots of electrophoresis data

Description

This function creates a violin plot from a electrophoresis object using geom_violin.

Usage

violin.electrophoresis(
  electrophoresis,
  x = "sample.name",
  y = "length",
  weight = "molarity",
  ...,
  flip = F,
  normalize = T,
  include.ladder = FALSE,
  include.markers = FALSE,
  lower.marker.spread = 10,
  ylim = c(NA, NA),
  adjust = 0.05,
  title = NULL,
  xlab = NULL,
  ylab = NULL
)

Arguments

electrophoresis

An electrophoresis object.

x

The name of the variable to use as the x-position of each violin as a character vector. Replicates with the same value of x will be grouped together with a single label. Probably "sample.name" unless you have added another sample annotation.

y

The name of the variable to use as the y-axis of the violins, as a character vector. Usually one of "time", "aligned.time", "distance", "relative.distance", or "length".

weight

The name of the variable to use for the width of a violin at any given point on the y-axis, as a character vector. Usually one of "fluorescence", "concentration", or "molarity".

...

Additional aesthetics passed to geom_violin. Unlike the previous variables that are specified by character vectors, these use the normal aesthetic syntax, e.g. fill = sample.name.

flip

Flip the axes so the violins are horizontal.

normalize

Normalize the violins (or sets of violins) to the same area (within the y-limits), i.e. scale = "area" in geom_violin. If false, each violin (or set) will have the same maximum width as the others (scale = "width"). Making the total area or width proportional to the total molarity/concentration/fluorescence of a sample is not really in the spirit of violin plots and not currently supported.

include.ladder

If FALSE, graph only the actual samples and not the ladder well(s).

include.markers

If FALSE, graph only data between the marker peaks.

lower.marker.spread

If normalizing the totals or excluding marker peaks, extend the lower marker peak by this amount (via between.markers).

ylim

Limits of y-axis.

adjust

Bandwidth adjustment for the kernel smoothing in geom_violin. Higher values will eliminate spikey noise but may also wipe out narrow peaks of interest, so this may require manual tuning depending on your data.

title, xlab, ylab

Plot title, x-axis label, and y-axis label.

Details

Violin plots are essentially smoothened histograms, a box plot for the computer age. Here the symmetric "violins" are arrrayed along a common axis of molecule length, or raw migration time or distance, and the weight (width) of each violin at a given position represents the relative density of molecules there, which may be molarity, concentration, or raw fluorescence; the weight metric is not specified on the plot itself so you may want to mention it in a figure caption. This is a compact plot for comparing normalized samples side-by-side. Traditionally violin plots are vertical, like box plots, and like the (simulated) gel images provided by Agilent software; however, an option is provided to flip the coordinates to horizontal if that seems more intuitive (q.v. sparkline.electrophoresis).

The main functional difference between this and qplot.electrophoresis is that the sample names (or some other annotation) are used directly as the x-variable for side-by-side plotting, rather than as a faceting variable. One consequence is that replicates with an identical x-value will have their violins plotted together in a set with a single x-axis label (by position_dodge). However, the underlying geom_violin also allocates its area or width normalizations to these sets, not to the individual violins within a set, so if the numbers of samples per replicate set are imbalanced then the individual violins will also have imbalanced widths, keeping the set widths constant instead.

Value

A ggplot object containing several layers. You can draw it directly or customize it like any other ggplot object by adding more layers.

See Also

qplot.electrophoresis


jwfoley/bioanalyzeR documentation built on Aug. 1, 2023, 4:46 a.m.