addClusterings,ClusterExperiment,matrix-method {clusterExperiment}R Documentation

Functions to add/remove clusters to ClusterExperiment

Description

These functions are used to add or remove clusters to a ClusterExperiment object.

Usage

## S4 method for signature 'ClusterExperiment,matrix'
addClusterings(x, y,
  clusterTypes = "User", clusterLabels = NULL, clusterLegend = NULL)

## S4 method for signature 'ClusterExperiment,ClusterExperiment'
addClusterings(x, y)

## S4 method for signature 'ClusterExperiment,vector'
addClusterings(x, y, makePrimary = FALSE,
  ...)

## S4 method for signature 'ClusterExperiment,character'
removeClusterings(x, whichClusters, ...)

## S4 method for signature 'ClusterExperiment,numeric'
removeClusterings(x, whichClusters)

## S4 method for signature 'ClusterExperiment'
removeUnclustered(x)

## S4 method for signature 'ClusterExperiment,numeric'
removeClusters(x, whichClusters,
  clustersToRemove, clusterLabels = NULL)

## S4 method for signature 'ClusterExperiment,character'
removeClusters(x, whichClusters, ...)

Arguments

x

a ClusterExperiment object.

y

additional clusters to add to x. Can be a ClusterExperiment object or a matrix/vector of clusters.

clusterTypes

a string describing the nature of the clustering. The values 'clusterSingle', 'clusterMany', 'mergeClusters', 'combineMany' are reserved for the clustering coming from the package workflow and should not be used when creating a new object with the constructor.

clusterLabels

label(s) for the clusters being added. If y a matrix, the column names of that matrix will be used by default, if clusterLabels is not given.

clusterLegend

a list giving the cluster legend for the clusters added.

makePrimary

whether to make the added cluster the primary cluster (only relevant if y is a vector)

...

Passed to signature ClusterExperiment,matrix.

whichClusters

optional argument that can be either numeric or character value. If numeric, gives the indices of the clusterMatrix to return; this can also be used to defined an ordering for the clusterings. whichClusters can be a character value identifying the clusterTypes to be used, or if not matching clusterTypes then clusterLabels; alternatively whichClusters can be either 'all' or 'workflow' to indicate choosing all clusters or choosing all workflowClusters. If missing, the entire matrix of all clusterings is returned.

clustersToRemove

numeric vector identifying the clusters to remove (whose samples will be reassigned to -1 value).

Details

addClusterings adds y to x, and is thus not symmetric in the two arguments. In particular, the primaryCluster, all of the dendrogram information, coClustering, and orderSamples are all kept from the x object, even if y is a ClusterExperiment.

removeClusterings removes the clusters given by whichClusters. If the primaryCluster is one of the clusters removed, the primaryClusterIndex is set to 1 and the dendrogram and coclustering matrix are discarded and orderSamples is set to 1:NCOL(x).

removeUnclustered removes all samples that are unclustered (i.e. -1 or -2 assignment) in the primaryCluster of x (so they may be unclustered in other clusters found in clusterMatrix(x)).

removeClusters creates a new cluster that unassigns samples in cluster clustersToRemove (in the clustering defined by whichClusters) and assigns them to -1 (unassigned)

Value

A ClusterExperiment object with the added clusters.

removeClusterings returns a ClusterExperiment object, unless all clusters are removed, in which case it returns a SingleCellExperiment object.

Examples

data(simData)

cl1 <- clusterSingle(simData, subsample=FALSE,
sequential=FALSE, mainClusterArgs=list(clusterArgs=list(k=3), clusterFunction="pam"))
cl2 <- clusterSingle(simData, subsample=FALSE,
sequential=FALSE, mainClusterArgs=list(clusterArgs=list(k=3), clusterFunction="pam"))

addClusterings(cl1, cl2)

[Package clusterExperiment version 2.0.2 Index]