sort-methods | R Documentation |
Rearrange clusters according to sort criterion
## S4 method for signature 'ExClust'
sort(x, decreasing=FALSE,
sortBy=c("aggExCluster", "size",
"nameExemplar", "noExemplar"), ...)
x |
object of class |
decreasing |
logical indicating if sorting should be done in decreasing order, see details below |
sortBy |
sort criterion, see details below |
... |
further arguments are ignored; only defined for S3 method consistency |
The function sort
takes an APResult
or ExClust
clustering object x
and creates
a new clustering object of the same class, but with clusters arranged
according to the sort criterion passed as argument sortBy
:
(default) order clusters as they
would appear in the dendrogram produced by
aggExCluster
. This is also the same ordering in
which the clusters are arranged by heatmap
.
Note that this only works if the similarity matrix is included
in the input object x
, otherwise an error message is
produced.
sorts clusters according to their size (from small to large).
sorts clusters according to the names of the examplars (if available, otherwise an error is produced).
sorts clusters according to the indices of the examplars.
If decreasing
is TRUE
, the order is reversed and, for
example, sortBy="size"
sorts clusters with such that the larger
clusters come first.
Note that the cluster numbers of x
are not preserved by
sort
, i.e. the cluster no. 1 of the object returned by
sort
is the one that has been ranked first by sort
,
which may not necessarily coincide with cluster no. 1 of the original
clustering object x
.
Note that this is an S3 method (whereas all other methods in this
package are S4 methods). This inconsistency has been introduced in
order to avoid interoperability problems with the BiocGenerics
package which may overwrite the definition of the sort
generic
if it is loaded after the apcluster package.
returns a copy of x
, but with slots exemplars
and
clusters
(see APResult
or ExClust
) reordered.
Ulrich Bodenhofer
https://github.com/UBod/apcluster
Bodenhofer, U., Kothmeier, A., and Hochreiter, S. (2011) APCluster: an R package for affinity propagation clustering. Bioinformatics 27, 2463-2464. DOI: \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/bioinformatics/btr406")}.
APResult
, ExClust
## create two Gaussian clouds
cl1 <- cbind(rnorm(50,0.2,0.05),rnorm(50,0.8,0.06))
cl2 <- cbind(rnorm(50,0.7,0.08),rnorm(50,0.3,0.05))
x <- rbind(cl1,cl2)
## run affinity propagation
apres <- apcluster(negDistMat(r=2), x, q=0.7)
show(apres)
## show dendrogram
plot(aggExCluster(x=apres))
## default sort order: like in heatmap or dendrogram
show(sort(apres))
## show dendrogram (note the different cluster numbers!)
plot(aggExCluster(x=sort(apres)))
## sort by size
show(sort(apres, decreasing=TRUE, sortBy="size"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.