ClusterExperiment-class {clusterExperiment} | R Documentation

## Class ClusterExperiment

### Description

`ClusterExperiment` is a class that extends `SingleCellExperiment` and is used to store the data and clustering information.

In addition to the slots of the `SingleCellExperiment` class, the `ClusterExperiment` object has the additional slots described in the Slots section.

There are several methods implemented for this class. The most important methods (e.g., `clusterMany`, `makeConsensus`, ...) have their own help page. Simple helper methods are described in the Methods section. For a comprehensive list of methods specific to this class see the Reference Manual.

The constructor `ClusterExperiment` creates an object of the class `ClusterExperiment`. However, the typical way of creating these objects is the result of a call to `clusterMany` or `clusterSingle`.

Note that when subsetting the data, the co-clustering and dendrogram information are lost.

### Usage

    ClusterExperiment(object, clusters, ...)

    ## S4 method for signature 'matrixOrHDF5,ANY'
    ClusterExperiment(object, clusters, ...)

    ## S4 method for signature 'SummarizedExperiment,ANY'
    ClusterExperiment(object, clusters, ...)

    ## S4 method for signature 'SingleCellExperiment,numeric'
    ClusterExperiment(object, clusters, ...)

    ## S4 method for signature 'SingleCellExperiment,character'
    ClusterExperiment(object, clusters, ...)

    ## S4 method for signature 'SingleCellExperiment,factor'
    ClusterExperiment(object, clusters, ...)

    ## S4 method for signature 'SingleCellExperiment,matrix'
    ClusterExperiment(
      object,
      clusters,
      transformation = function(x) {     x },
      primaryIndex = 1,
      clusterTypes = "User",
      clusterInfo = NULL,
      orderSamples = seq_len(ncol(object)),
      dendro_samples = NULL,
      dendro_index = NA_real_,
      dendro_clusters = NULL,
      coClustering = NULL,
      merge_index = NA_real_,
      merge_cutoff = NA_real_,
      merge_dendrocluster_index = NA_real_,
      merge_nodeProp = NULL,
      merge_nodeMerge = NULL,
      merge_method = NA_character_,
      merge_demethod = NA_character_,
      clusterLegend = NULL,
      checkTransformAndAssay = TRUE
    )

### Arguments

`object` | a matrix or `SummarizedExperiment` or `SingleCellExperiment` containing the data that was clustered.
`clusters` | can be either a numeric or character vector, a factor, or a numeric matrix, containing the cluster labels.
`...` | The arguments `transformation`, `clusterTypes` and `clusterInfo` to be passed to the constructor for signature `SingleCellExperiment,matrix`.
`transformation` | function. A function to transform the data before performing steps that assume normal-like data (i.e. constant variance), such as the log.
`primaryIndex` | integer. Sets the 'primaryIndex' slot (see Slots).
`clusterTypes` | a string describing the nature of the clustering. The values 'clusterSingle', 'clusterMany', 'mergeClusters', 'makeConsensus' are reserved for the clustering coming from the package workflow and should not be used when creating a new object with the constructor.
`clusterInfo` | a list with information on the clustering (see Slots).
`orderSamples` | a vector of integers. Sets the 'orderSamples' slot (see Slots).
`dendro_samples` | phylo4 object. Sets the 'dendro_samples' slot (see Slots).
`dendro_index` | numeric. Sets the `dendro_index` slot (see Slots).
`dendro_clusters` | phylo4 object. Sets the 'dendro_clusters' slot (see Slots).
`coClustering` | matrix. Sets the `coClustering` slot (see Slots).
`merge_index` | integer. Sets the `merge_index` slot (see Slots)
`merge_cutoff` | numeric. Sets the `merge_cutoff` slot (see Slots)
`merge_dendrocluster_index` | integer. Sets the `merge_dendrocluster_index` slot (see Slots)
`merge_nodeProp` | data.frame. Sets the `merge_nodeProp` slot (see Slots)
`merge_nodeMerge` | data.frame. Sets the `merge_nodeMerge` slot (see Slots)
`merge_method` | character, Sets the `merge_method` slot (see Slots)
`merge_demethod` | character, Sets the `merge_demethod` slot (see Slots)
`clusterLegend` | list, Sets the `clusterLegend` slot (see details).
`checkTransformAndAssay` | logical. Whether to check the content of the assay and given transformation function for whether they are valid.

### Details

The `clusterLegend` argument to `ClusterExperiment` must be a valid clusterLegend format and match the values in `clusters`, in that the "clusterIds" column must matches the value in the clustering matrix `clusters`. If `names(clusterLegend)==NULL`, it is assumed that the entries of `clusterLegend` are in the same order as the columns of `clusters`. Generally, this is not a good way for users to set the clusterLegend slot.

The `ClusterExperiment` constructor function gives clusterLabels based on the column names of the input matrix/SingleCellExperiment. If missing, will assign labels "cluster1","cluster2", etc.

Note that the validity check when creating a new `ClusterExperiment` object with `new` is less extensive than when using `ClusterExperiment` function with `checkTransformAndAssay=TRUE` (the default). Users are advised to use `ClusterExperiment` to create new `ClusterExperiment` objects.

### Value

A `ClusterExperiment` object.

### Slots

`transformation`

  function. Function to transform the data by when methods that assume normal-like data (e.g. log)

`clusterMatrix`

  matrix. A matrix giving the integer-valued cluster ids for each sample. The rows of the matrix correspond to clusterings and columns to samples. The integer values are assigned in the order that the clusters were found, if found by setting sequential=TRUE in clusterSingle. "-1" indicates the sample was not clustered.

`primaryIndex`

  numeric. An index that specifies the primary set of labels.

`clusterInfo`

  list. A list with info about the clustering. If created from `clusterSingle`, clusterInfo will include the parameter used for the call, and the call itself. If `sequential = TRUE` it will also include the following components.

  - `clusterInfo`if sequential=TRUE and clusters were successfully found, a matrix of information regarding the algorithm behavior for each cluster (the starting and stopping K for each cluster, and the number of iterations for each cluster).

  - `whyStop`if sequential=TRUE and clusters were successfully found, a character string explaining what triggered the algorithm to stop.

`merge_index`

  index of the current merged cluster

`merge_cutoff`

  value for the cutoff used to determine whether to merge clusters

`merge_dendrocluster_index`

  index of the cluster merged with the current merge

`merge_nodeMerge`

  data.frame of information about nodes merged in the current merge. See `mergeClusters`

`merge_nodeProp`

  data.frame of information of proportion estimated non-null at each node of dendrogram. See `mergeClusters`

`merge_method`

  character indicating method used for merging. See `mergeClusters`

`merge_demethod`

  character indicating the DE method used for merging. See `mergeClusters`

`clusterTypes`

  character vector with the origin of each column of clusterMatrix.

`dendro_samples`

  `phylo4d` object. A dendrogram containing the cluster relationship (leaves are samples; see `clusterDendrogram` for details).

`dendro_clusters`

  `phylo4d` object. A dendrogram containing the cluster relationship (leaves are clusters; see see `sampleDendrogram` for details).

`dendro_index`

  numeric. An integer giving the cluster that was used to make the dendrograms. NA_real_ value if no dendrograms are saved.

`coClustering`

  One of

  - `NULL`, i.e. empty

  - a numeric vector, signifying the indices of the clusterings in the clusterMatrix that were used for `makeConsensus`. This allows for the recreation of the distance matrix (using hamming distance) if needed for function `plotClusters` but doesn't require storage of full NxN matrix.

  - a `sparseMatrix` object – a sparse representation of the NxN matrix with the cluster co-occurrence information; this can either be based on subsampling or on co-clustering across parameter sets (see `clusterMany`). The matrix is a square matrix with number of rows/columns equal to the number of samples.

`clusterLegend`

  a list, one per cluster in `clusterMatrix`. Each element of the list is a matrix with nrows equal to the number of different clusters in the clustering, and consisting of at least two columns with the following column names: "clusterId" and "color".

`orderSamples`

  a numeric vector (of integers) defining the order of samples to be used for plotting of samples. Usually set internally by other functions.

### See Also

`sparseMatrix` `phylo4d`

### Examples

    sce <- matrix(data=rnorm(200), ncol=10)
    labels <- gl(5, 2)

    cc <- ClusterExperiment(sce, as.numeric(labels), transformation =
    function(x){x})

[Package clusterExperiment version 2.14.0 Index]