renameClusters: Change assigned names or colors of clusters

renameClustersR Documentation

Change assigned names or colors of clusters

Description

Change the assigned names or colors of the clusters in a clustering stored in the clusterLegend slot of the object.

Usage

## S4 method for signature 'ClusterExperiment,character'
renameClusters(
  object,
  value,
  whichCluster = "primary",
  matchTo = c("name", "clusterIds")
)

## S4 method for signature 'ClusterExperiment,character'
recolorClusters(
  object,
  value,
  whichCluster = "primary",
  matchTo = c("name", "clusterIds")
)

Arguments

value

The value to be substituted in the corresponding slot. See the slot descriptions in ClusterExperiment for details on what objects may be passed to these functions.

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.

matchTo

whether to match to the cluster name ("name") or internal cluster id ("clusterIds")

Value

renameClusters changes the names assigned to clusters within a clustering

recolorClusters changes the colors assigned to clusters within a clustering

Examples

#create CE object
data(simData)
cl1 <- clusterSingle(simData, subsample=FALSE,
sequential=FALSE, mainClusterArgs=list(clusterArgs=list(k=3), 
clusterFunction="pam"))
#Give names to the clusters
clusterLegend(cl1)
cl1<-renameClusters(cl1, c("1"="A","2"="B","3"="C"), matchTo="clusterIds")
clusterLegend(cl1)
# Change name of single one
cl1<-renameClusters(cl1, c("1"="D"), matchTo="clusterIds")
clusterLegend(cl1)
# Match to existing name, rather than clusterId
cl1<-renameClusters(cl1, c("B"="N"), matchTo="name")
clusterLegend(cl1)
# Change colors in similar way
cl1<-recolorClusters(cl1, c("N"="red"),matchTo=c("name"))
clusterLegend(cl1)

epurdom/clusterCells documentation built on April 28, 2024, 8:14 p.m.