Learn R Programming

apcluster (version 1.2.1)

labels-methods: Generate label vector from clustering result

Description

Generate a label vector from an clustering result

Usage

## S3 method for class 'APResult':
labels(object, type="names")
## S3 method for class 'ExClust':
labels(object, type="names")

Arguments

object
object of class APResult or ExClust
type
specifies which kind of label vector should be created, see details below

Value

  • returns a label vector as long as the number of samples in the original data set

Details

The function labels creates a label vector from a clustering result. Which kind of labels are produced is controlled by the argument type: [object Object],[object Object],[object Object]

References

http://www.bioinf.jku.at/software/apcluster

Bodenhofer, U., Kothmeier, A., and Hochreiter, S. (2011) APCluster: an R package for affinity propagation clustering. Bioinformatics 27, 2463-2464. DOI: http://dx.doi.org/10.1093/bioinformatics/btr406{10.1093/bioinformatics/btr406}.

See Also

APResult, ExClust, cutree

Examples

Run this code
## create two simple clusters
x <- c(1, 2, 3, 7, 8, 9)
names(x) <- c("a", "b", "c", "d", "e", "f")

## compute similarity matrix (negative squared distance)
sim <- negDistMat(x, r=2)

## run affinity propagation
apres <- apcluster(sim)

## show details of clustering results
show(apres)

## label vector (names of exemplars)
labels(apres)

## label vector (consecutive index of exemplars)
labels(apres, type="enum")

## label vector (index of exemplars within original data set)
labels(apres, type="exemplars")

## now with agglomerative clustering
aggres <- aggExCluster(sim)

## label (names of exemplars)
labels(cutree(aggres, 2))

Run the code above in your browser using DataLab