plotClustersTable {clusterExperiment}R Documentation

Plot heatmap of cross-tabs of 2 clusterings

Description

Plot heatmap of cross-tabulations of two clusterings

Usage

## S4 method for signature 'ClusterExperiment'
plotClustersTable(object, whichClusters,
  ignoreUnassigned = FALSE, margin = NA, ...)

## S4 method for signature 'table'
plotClustersTable(object, clusterLegend = NULL,
  cluster = FALSE, plotType = c("heatmap", "bubble"), sizeTable = object,
  ...)

## S4 method for signature 'ClusterExperiment,character'
tableClusters(object, whichClusters,
  ...)

## S4 method for signature 'ClusterExperiment,missing'
tableClusters(object, whichClusters, ...)

## S4 method for signature 'ClusterExperiment,numeric'
tableClusters(object, whichClusters,
  useNames = TRUE, tableMethod = c("intersect", "union"), ...)

## S4 method for signature 'table,table'
bubblePlot(propTable, sizeTable, gridColor = rgb(0, 0,
  0, 0.05), maxCex = 8, cexFactor, ylab, xlab, legend = TRUE, las = 2,
  colorScale = RColorBrewer::brewer.pal(11, "Spectral")[-6])

Arguments

object

ClusterExperiment object (or matrix with table result)

whichClusters

argument that can be either numeric or character value indicating the clusters to be used. If numeric, gives the indices of the clusterMatrix to return; this can also be used to defined an ordering for the clusterings (as relevant). 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' or 'primary' to indicate choosing all clusterings or choosing all workflowClusters clusterings or choosing the 'primary' clustering, respectively. If missing, the entire matrix of all clusterings is returned.

ignoreUnassigned

logical as to whether to ignore unassigned clusters in the plotting. This means they will also be ignored in the calculations of the proportions (if margin not NA).

margin

if NA, the counts from tableClusters will be plotted. Otherwise, prop.table will be called and the argument margin will be passed to prop.table to determine whether proportions should be calculated. If '1', then the proportions in the rows sum to 1, if '2' the proportions in the columns sum to 1. If 'NULL' then the proportion across the entire matrix will sum to 1. For a symmetric version, you can set margin=0, and the entry displayed in each cell will be the proportion equal to the size of the intersection over the size of the union of the clusters (a Jaccard similarity between the clusters), in which case each entry is a proportion but no combination of the entries sum to 1.

...

arguments passed on to plotHeatmap or bubblePlot depending on choice of plotType

clusterLegend

list in clusterLegend format that gives colors for the clusters tabulated.

cluster

logical, whether to cluster the rows and columns of the table. Passed to arguments clusterFeatures AND clusterSamples of plotHeatmap.

plotType

type of plot. If "heatmap", then a heatmap will be created of the values of the contingency table of the two clusters (calculated as determined by the argument "margin") using plotHeatmap. If "bubble", then a plot will be created using bubblePlot, which will create circles for each cell of the contingencey table whose size corresponds to the number of samples shared and the color based on the value of the proportion (as chosen by the argument margin).

sizeTable

table of sizes

useNames

for tableClusters, whether the output should be tabled with names (useNames=TRUE) or ids (useNames=FALSE)

tableMethod

the type of table calculation to perform. "intersect" refers to the standard contingency table (table), where each entry of the resulting table is the number of objects in both clusters. "union" instead gives for each entry the number of objects that are in the union of both clusters.

propTable

table of proportions

gridColor

color for grid lines

maxCex

largest value of cex for any point (others will scale proportionally smaller).

cexFactor

factor to multiple by to get values of circles. If missing, finds value automatically, namely by using the maxCex value default. Overrides value of maxCex.

ylab

label for y-axis. If missing, uses the name for rows in sizeTable. If set to NULL no y-axis label will be plotted.

xlab

label for x-axis. If missing, uses the name for columns in sizeTable. If set to NULL no y-axis label will be plotted.

legend

whether to draw legend along top

las

the value for the las value in the call to axis in labeling the clusters in the bubble plot. Determines whether parallel or perpindicular labels to the axis (see par).

colorScale

the color scale for the values of the proportion table

Details

For plotClustersTable whichClusters should define 2 clusters, for tableClusters can indicate arbitrary number.

Note that the cluster labels in plotClustersTable and tableClusters are converted to "proper" R names via make.names. This is because tableClusters calls the R function table, which makes this conversion

bubblePlot is mainly used internally by plotClustersTable but is made public for users who want more control and to allow documentation of the arguments. bubblePlot plots a circle for each intersection of two clusters, where the color of the circle is based on the value in propTable and the size of the circle is based on the value in sizeTable. The size is determined by setting the cex value of the point as $sqrt(sizeTable[i,j])/sqrt(max(sizeTable))*cexFactor$.

See Also

prop.table

plotHeatmap

table

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))
#give arbitrary names to clusters for demonstration
cl<-renameClusters(cl,value=letters[1:nClusters(cl)[1]],whichCluster=1)
tableClusters(cl,whichClusters=1:2)
#heatmap of the counts in each entry of table:
plotClustersTable(cl,whichClusters=1:2, ignoreUnassigned=TRUE)

[Package clusterExperiment version 2.3.0 Index]