plotClustersTable | R Documentation |
Plot heatmap of cross-tabulations of two clusterings
## S4 method for signature 'ClusterExperiment'
plotClustersTable(
object,
whichClusters,
ignoreUnassigned = FALSE,
margin = NA,
...
)
## S4 method for signature 'table'
plotClustersTable(
object,
plotType = c("heatmap", "bubble"),
main = "",
xlab = NULL,
ylab = NULL,
legend = TRUE,
cluster = FALSE,
clusterLegend = NULL,
sizeTable = NULL,
...
)
## S4 method for signature 'ClusterExperiment'
tableClusters(
object,
whichClusters = "primary",
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,
propLabel = "Value of %",
legend = TRUE,
las = 2,
colorScale = RColorBrewer::brewer.pal(11, "Spectral")[-6]
)
object |
ClusterExperiment object (or matrix with table result) |
whichClusters |
argument that can be either numeric or character vector
indicating the clusterings to be used. See details of |
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 |
if NA, the actual counts from |
... |
arguments passed on to |
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 |
main |
title of plot, passed to |
xlab |
label for labeling clustering on the x-axis. If NULL, will
determine names. If set to |
ylab |
label for labeling clustering on the y-axis. If NULL, will
determine names. If set to |
legend |
whether to draw legend along top (bubble plot) or the color legend (heatmap) |
cluster |
logical, whether to cluster the rows and columns of the table.
Passed to arguments |
clusterLegend |
list in |
sizeTable |
table of sizes (only for use in |
useNames |
for |
tableMethod |
the type of table calculation to perform. "intersect"
refers to the standard contingency table ( |
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. ( |
propLabel |
the label to go with the legend of the color of the bubbles/circles |
las |
the value for the las value in the call to |
colorScale |
the color scale for the values of the proportion table |
For plotClustersTable
applied to the class table
,
sizeTable
is passed to bubblePlot
to indicate the size of the
circle. If sizeTable=NULL
, then it is assumed that the object
argument is the table of counts and both the propTable
and
sizeTable
are set to the same value (hence turning off the coloring
of the circle/bubbles). This is equivalent effect to the margin=NA
option of plotClustersTable
applied to the ClusterExperiment
class.
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
For plotClustersTable
, whichClusters
should define 2
clusters, while for tableClusters
it can indicate arbitrary number.
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
. If propTable
is equal to sizeTable
, then the propTable
is ignored and the
coloring of the circles is not performed, only the adjusting of the
size of the circles based on the total size. The size is determined by
setting the cex
value of the point as
$sqrt(sizeTable[i,j])/sqrt(max(sizeTable))*cexFactor$.
tableClusters
returns an object of class table
(see
table
).
plotClustersTables
returns invisibly the plotted proportion
table. In particular, this is the result of applying
prop.table
to the results of tableClusters
(after removing unclustered samples if ignoreUnassigned=TRUE
).
Kelly Street, Elizabeth Purdom
plotHeatmap
table
prop.table
#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), makeMissingDiss=TRUE)
#give arbitrary names to clusters for demonstration
cl<-renameClusters(cl,value=letters[1:nClusters(cl)[1]],whichCluster=1)
tableClusters(cl,whichClusters=1:2)
#show options of margin in heatmap format:
par(mfrow=c(2,3))
plotClustersTable(cl,whichClusters=1:2, margin=NA, legend=FALSE,
ignoreUnassigned=TRUE)
plotClustersTable(cl,whichClusters=1:2, margin=0, legend=FALSE,
ignoreUnassigned=TRUE)
plotClustersTable(cl,whichClusters=1:2, margin=1, legend=FALSE,
ignoreUnassigned=TRUE)
plotClustersTable(cl,whichClusters=1:2, margin=2, legend=FALSE,
ignoreUnassigned=TRUE)
plotClustersTable(cl,whichClusters=1:2, margin=NULL, legend=FALSE,
ignoreUnassigned=TRUE)
#show options of margin in bubble format:
par(mfrow=c(2,3))
plotClustersTable(cl,whichClusters=1:2, margin=NA,
ignoreUnassigned=TRUE, plotType="bubble")
plotClustersTable(cl,whichClusters=1:2, margin=0,
ignoreUnassigned=TRUE, plotType="bubble")
plotClustersTable(cl,whichClusters=1:2, margin=1,
ignoreUnassigned=TRUE, plotType="bubble")
plotClustersTable(cl,whichClusters=1:2, margin=2,
ignoreUnassigned=TRUE, plotType="bubble")
plotClustersTable(cl,whichClusters=1:2, margin=NULL,
ignoreUnassigned=TRUE, plotType="bubble")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.