plotBarplot,ClusterExperiment-method {clusterExperiment} | R Documentation

## Barplot of 1 or 2 clusterings

### Description

Make a barplot of sample's assignments to clusters for single clustering, or cross comparison for two clusterings.

### Usage

    ## S4 method for signature 'ClusterExperiment'
    plotBarplot(object, whichClusters = "primary", labels = c("names", "ids"), ...)

    ## S4 method for signature 'vector'
    plotBarplot(object, ...)

    ## S4 method for signature 'matrix'
    plotBarplot(
      object,
      xNames = NULL,
      legNames = NULL,
      legend = ifelse(ncol(object) == 2, TRUE, FALSE),
      xlab = NULL,
      legend.title = NULL,
      unassignedColor = "white",
      missingColor = "grey",
      colPalette = NULL,
      ...
    )

### Arguments

`object` | A matrix of with each column corresponding to a clustering and each row a sample or a `ClusterExperiment` object.
`whichClusters` | argument that can be either numeric or character vector indicating the clusterings to be used. See details of `getClusterIndex`.
`labels` | if object is a ClusterExperiment object, then labels defines whether the clusters will be identified by their names values in clusterLegend (labels="names", the default) or by their clusterIds value in clusterLegend (labels="ids").
`...` | for `plotBarplot` arguments passed either to the method of `plotBarplot` for matrices or ultimately to `barplot`.
`xNames` | names for the clusters on x-axis (i.e. clustering given 1st). By default uses names of the 1st column of clusters matrix. See details.
`legNames` | names for the clusters dividing up the 1st clusters (will appear in legend). By default uses names of the 2nd cluster of clusters matrix. If only one clustering, `xNames` and `legNames` refer to the same clustering. See details.
`legend` | whether to plot the legend
`xlab` | label for x-axis. By default or if equal NULL the column name of the 1st cluster of clusters matrix
`legend.title` | label for legend. By default or if equal NULL the column name of the 2st cluster of clusters matrix
`unassignedColor` | If “-1” in `clusters`, will be given this color (meant for samples not assigned to cluster).
`missingColor` | If “-2” in clusters, will be given this color (meant for samples that were missing from the clustering, mainly when comparing clusterings run on different sets of samples)
`colPalette` | a vector of colors used for the different clusters. See details.

### Details

The first column of the cluster matrix will be on the x-axis and the second column (if present) will separate the groups of the first column.

All arguments of the matrix version can be passed to the `ClusterExperiment` version. As noted above, however, some arguments have different interpretations.

If `whichClusters = "workflow"`, then the most recent two clusters of the workflow will be chosen where recent is based on the following order (most recent first): final, mergeClusters, makeConsensus, clusterMany.

`xNames`, `legNames` and `colPalette` should all be named vectors, with the names referring to the clusters they should match to (for `ClusterExperiment` objects, it is determined by the argument `labels` as to whether the names should match the cluster names or the clusterIds). `colPalette` and `legNames` must be same length of the number of clusters found in the second clustering, or if only a single clustering, the same length as the number of clusters in that clustering.

### Value

A plot is produced, nothing is returned

### Author(s)

Elizabeth Purdom

### Examples

    #clustering using pam: try using different dimensions of pca and different k
    data(simData)

    cl <- clusterMany(simData, nReducedDims=c(5, 10, 50), reduceMethod="PCA",
    clusterFunction="pam", ks=2:4, findBestK=c(TRUE,FALSE),
    removeSil=c(TRUE,FALSE), makeMissingDiss=TRUE)

    plotBarplot(cl)
    plotBarplot(cl,whichClusters=1:2)

[Package clusterExperiment version 2.10.1 Index]