plotDendrogram,ClusterExperiment-method {clusterExperiment} | R Documentation

## Plot dendrogram of ClusterExperiment object

### Description

Plots the dendrogram saved in a ClusterExperiment object

### Usage

    ## S4 method for signature 'ClusterExperiment'
    plotDendrogram(
      x,
      whichClusters = "dendro",
      leafType = c("samples", "clusters"),
      plotType = c("colorblock", "name", "ids"),
      mergeInfo = "none",
      main,
      sub,
      clusterLabelAngle = 45,
      removeOutbranch = TRUE,
      legend = c("side", "below", "none"),
      nodeColors = NULL,
      colData = NULL,
      clusterLegend = NULL,
      ...
    )

### Arguments

`x` | a `ClusterExperiment` object.
`whichClusters` | argument that can be either numeric or character vector indicating the clusterings to be used. See details of `getClusterIndex`.
`leafType` | if "samples" the dendrogram has one leaf per sample, otherwise it has one per cluster.
`plotType` | one of 'name', 'colorblock' or 'id'. If 'Name' then dendrogram will be plotted, and name of cluster or sample (depending on type of value for `leafType`) will be plotted next to the leaf of the dendrogram. If 'colorblock', rectangular blocks, corresponding to the color of the cluster will be plotted, along with cluster name legend. If 'id' the internal clusterIds value will be plotted (only appropriate if `leafType="clusters"`).
`mergeInfo` | What kind of information about merge to plot on dendrogram. If not equal to "none", will replicate the kind of plot that `mergeClusters` creates, and the input to `mergeInfo` corresponds to that of `plotInfo` in `mergeClusters`.
`main` | passed to the `plot.phylo` function to set main title.
`sub` | passed to the `plot.phylo` function to set subtitle.
`clusterLabelAngle` | angle at which label of cluster will be drawn. Only applicable if `plotType="colorblock"`.
`removeOutbranch` | logical, only applicable if there are missing samples (i.e. equal to -1 or -2), `leafType="samples"` and the dendrogram for the samples was made by putting missing samples in an outbranch. In which case, if this parameter is TRUE, the outbranch will not be plotted, and if FALSE it will be plotted.
`legend` | character, only applicable if `plotType="colorblock"`. Passed to `phydataplot` in `ape` package that is used to draw the color values of the clusters/samples next to the dendrogram. Options are 'none', 'below', or 'side'. (Note 'none' is only available for 'ape' package >= 4.1-0.6).
`nodeColors` | named vector of colors to be plotted on a node in the dendrogram (calls `nodelabels`). Names should match the internal name of the node (the "NodeId" value, see `clusterDendrogram`).
`colData` | index (by integer or name) the sample data stored as a `DataFrame` in `colData` slot of the object. Only discrete valued ("character" or "factor" variables) will be plotted; indexing of continous variables will be ignored. Whether that data is continuous or not will be determined by the properties of `colData` (no user input is needed). This argument is only relevant if `plotType=="colorblock"` and `leafType=="samples"`
`clusterLegend` | Assignment of colors to the clusters or sample data (as designated by `colData` argument) plotted with the dendrogram . If `NULL` or a particular variable/cluster are not assigned a color, colors will be assigned internally for sample data and pull from the `clusterLegend` slot of the x for the clusters.
`...` | arguments passed to the `plot.phylo` function of `ape` that plots the dendrogram.

### Details

If `leafType="clusters"`, the plotting function will work best if the clusters in the dendrogram correspond to the primary cluster. This is because the function colors the cluster labels based on the colors of the clusterIds of the primaryCluster

### Value

A dendrogram is plotted. Returns (invisibly) a list with elements

- `plottedObject` the `phylo` object that is plotted.

- `originalObject` the `phylo` object before adjusting the node/tip labels.

### See Also

`mergeClusters`,`plot.phylo`, `nodelabels`,`tiplabels`

### Examples

    data(simData)

    #create a clustering, for 8 clusters (truth was 3)
    cl <-clusterSingle(simData, subsample=FALSE,
    sequential=FALSE,
    mainClusterArgs=list(clusterFunction="pam", clusterArgs=list(k=8)))

    #create dendrogram of clusters and then
    # merge clusters based ondendrogram:
    cl <- makeDendrogram(cl)
    cl <- mergeClusters(cl,mergeMethod="adjP",DEMethod="limma",
       cutoff=0.1,plot=FALSE)
    plotDendrogram(cl)
    plotDendrogram(cl,leafType="samples",whichClusters="all",plotType="colorblock")

[Package clusterExperiment version 2.14.0 Index]