plotReducedDims {clusterExperiment} | R Documentation

## Plot 2-dimensionsal representation with clusters

### Description

Plot a 2-dimensional representation of the data, color-code by a clustering.

### Usage

    ## S4 method for signature 'ClusterExperiment'
    plotReducedDims(
      object,
      whichCluster = "primary",
      reducedDim = "PCA",
      whichDims = c(1, 2),
      plotUnassigned = TRUE,
      legend = TRUE,
      legendTitle = "",
      nColLegend = 6,
      clusterLegend = NULL,
      unassignedColor = NULL,
      missingColor = NULL,
      pch = 19,
      xlab = NULL,
      ylab = NULL,
      ...
    )

### Arguments

`object` | a ClusterExperiment object
`whichCluster` | argument that can be a single numeric or character value indicating the single clustering to be used. Giving values that result in more than one clustering will result in an error. See details of `getClusterIndex`.
`reducedDim` | What dimensionality reduction method to use. Should match either a value in `reducedDimNames(object)` or one of the built-in functions of `listBuiltInReducedDims()`
`whichDims` | vector of length 2 giving the indices of which dimensions to show. The first value goes on the x-axis and the second on the y-axis.
`plotUnassigned` | logical as to whether unassigned (either -1 or -2 cluster values) should be plotted.
`legend` | either logical, indicating whether to plot legend, or character giving the location of the legend (passed to `legend`)
`legendTitle` | character value giving title for the legend. If NULL, uses the clusterLabels value for clustering.
`nColLegend` | The number of columns in legend. If missing, picks number of columns internally.
`clusterLegend` | matrix with three columns and colnames 'clusterIds','name', and 'color' that give the color and name of the clusters in whichCluster. If NULL, pulls the information from `object`.
`unassignedColor` | If not NULL, should be character value giving the color for unassigned (-1) samples (overrides `clusterLegend`) default.
`missingColor` | If not NULL, should be character value giving the color for missing (-2) samples (overrides `clusterLegend`) default.
`pch` | the point type, passed to `plot.default`
`xlab` | Label for x axis
`ylab` | Label for y axis
`...` | arguments passed to `plot.default`

### Details

If `plotUnassigned=TRUE`, and the color for -1 or -2 is set to "white", will be coerced to "lightgrey" regardless of user input to `missingColor` and `unassignedColor`. If `plotUnassigned=FALSE`, the samples with -1/-2 will not be plotted, nor will the category show up in the legend.

If the requested `reducedDim` method has not been created yet, the function will call `makeReducedDims` on the FIRST assay of `x`. The results of this method will be saved as part of the object and returned INVISIBLY (meaning if you don't save the output of the plotting command, the results will vanish). To pick another assay, you should call 'makeReducedDims' directly and specify the assay.

### Value

A plot is created. Nothing is returned.

### See Also

`plot.default`, `makeReducedDims`, `listBuiltInReducedDims()`

### Examples

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

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

    plotReducedDims(cl,legend="bottomright")

[Package clusterExperiment version 2.12.0 Index]