plotDistribution {psichomics} | R Documentation

## Plot distribution through a density plot

### Description

The tooltip shows the median, variance, max, min and number of non-NA samples of each data series (if `data` contains names or column names, those will be used as sample names and also appear in the tooltip).

### Usage

    plotDistribution(
      data,
      groups = NULL,
      rug = TRUE,
      vLine = TRUE,
      ...,
      title = NULL,
      psi = NULL,
      rugLabels = FALSE,
      rugLabelsRotation = 0
    )

### Arguments

`data` | Numeric, data frame or matrix: gene expression data or alternative splicing event quantification values (sample names are based on their `names` or `colnames`)
`groups` | List of sample names or vector containing the group name per `data` value (read Details); if `NULL` or a character vector of length 1, `data` values are considered from the same group
`rug` | Boolean: show rug plot?
`vLine` | Boolean: plot vertical lines (including descriptive statistics for each group)?
`...` | Arguments passed on to `stats::density.default` `bw` the smoothing bandwidth to be used. The kernels are scaled such that this is the standard deviation of the smoothing kernel. (Note this differs from the reference books cited below, and from S-PLUS.) `bw` can also be a character string giving a rule to choose the bandwidth. See `bw.nrd`. The default, `"nrd0"`, has remained the default for historical and compatibility reasons, rather than as a general recommendation, where e.g., `"SJ"` would rather fit, see also Venables and Ripley (2002). The specified (or computed) value of `bw` is multiplied by `adjust`. `adjust` the bandwidth used is actually `adjust*bw`. This makes it easy to specify values like ‘half the default’ bandwidth. `kernel` a character string giving the smoothing kernel to be used. This must partially match one of `"gaussian"`, `"rectangular"`, `"triangular"`, `"epanechnikov"`, `"biweight"`, `"cosine"` or `"optcosine"`, with default `"gaussian"`, and may be abbreviated to a unique prefix (single letter). `"cosine"` is smoother than `"optcosine"`, which is the usual ‘cosine’ kernel in the literature and almost MSE-efficient. However, `"cosine"` is the version used by S. `window` a character string giving the smoothing kernel to be used. This must partially match one of `"gaussian"`, `"rectangular"`, `"triangular"`, `"epanechnikov"`, `"biweight"`, `"cosine"` or `"optcosine"`, with default `"gaussian"`, and may be abbreviated to a unique prefix (single letter). `"cosine"` is smoother than `"optcosine"`, which is the usual ‘cosine’ kernel in the literature and almost MSE-efficient. However, `"cosine"` is the version used by S. `weights` numeric vector of non-negative observation weights, hence of same length as `x`. The default `NULL` is equivalent to `weights = rep(1/nx, nx)` where `nx` is the length of (the finite entries of) `x[]`. `width` this exists for compatibility with S; if given, and `bw` is not, will set `bw` to `width` if this is a character string, or to a kernel-dependent multiple of `width` if this is numeric. `give.Rkern` logical; if true, no density is estimated, and the ‘canonical bandwidth’ of the chosen `kernel` is returned instead. `n` the number of equally spaced points at which the density is to be estimated. When `n > 512`, it is rounded up to a power of 2 during the calculations (as `fft` is used) and the final result is interpolated by `approx`. So it almost always makes sense to specify `n` as a power of two. `from` the left and right-most points of the grid at which the density is to be estimated; the defaults are `cut * bw` outside of `range(x)`. `to` the left and right-most points of the grid at which the density is to be estimated; the defaults are `cut * bw` outside of `range(x)`. `cut` by default, the values of `from` and `to` are `cut` bandwidths beyond the extremes of the data. This allows the estimated density to drop to approximately zero at the extremes.
`title` | Character: plot title
`psi` | Boolean: are `data` composed of PSI values? If `NULL`, `psi = TRUE` if all `data` values are between 0 and 1
`rugLabels` | Boolean: plot sample names in the rug?
`rugLabelsRotation` | Numeric: rotation (in degrees) of rug labels; this may present issues at different zoom levels and depending on the proximity of `data` values

### Details

Argument `groups` can be either:

- a list of sample names, e.g. `list("Group 1"=c("Sample A", "Sample B"), "Group 2"=c("Sample C")))`

- a character vector with the same length as `data`, e.g. `c("Sample A", "Sample C", "Sample B")`.

### Value

`highchart` object with density plot

### See Also

Other functions to perform and plot differential analyses: `diffAnalyses()`

### Examples

    data   <- sample(20, rep=TRUE)/20
    groups <- paste("Group", c(rep("A", 10), rep("B", 10)))
    names(data) <- paste("Sample", 1:20)
    plotDistribution(data, groups)

    # Using colours
    attr(groups, "Colour") <- c("Group A"="pink", "Group B"="orange")
    plotDistribution(data, groups)

[Package psichomics version 1.12.1 Index]