File: labels-methods.Rd

package info (click to toggle)
r-cran-apcluster 1.4.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,744 kB
  • sloc: cpp: 1,258; ansic: 346; makefile: 2
file content (82 lines) | stat: -rw-r--r-- 2,574 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
\name{labels-methods}
\docType{methods}
\alias{labels}
\alias{labels-methods}
\alias{labels,APResult-method}
\alias{labels,ExClust-method}
\title{Generate label vector from clustering result}
\description{
  Generate a label vector from an clustering result
}
\usage{
\S4method{labels}{ExClust}(object, type="names")
}
\arguments{
  \item{object}{object of class \code{\linkS4class{APResult}}
    or \code{\linkS4class{ExClust}}}
  \item{type}{specifies which kind of label vector should be
    created, see details below}
}
\details{
  The function \code{labels} creates a label vector from a clustering
  result. Which kind of labels are produced is controlled by the
  argument \code{type}:
  \describe{
    \item{\dQuote{names}}{(default) returns the name of the exemplar
    to which each
    data sample belongs to; if no names are available, the function
    stops with an error;}
    \item{\dQuote{enum}}{returns the index of the cluster to which
    each data sample belongs to, where clusters are enumerated
    consecutively from 1 to the number of clusters (analogous to
    other clustering methods like \code{\link{kmeans}});}
    \item{\dQuote{exemplars}}{returns the index of the exemplar to
    which each data sample belongs to, where indices of exemplars are
    within the original data, which is nothing else but the slot
    \code{object@idx} with attributes removed.}}
}
\value{
  returns a label vector as long as the number of samples in the
  original data set
}
\author{Ulrich Bodenhofer and Andreas Kothmeier}
\references{\url{https://github.com/UBod/apcluster}

Bodenhofer, U., Kothmeier, A., and Hochreiter, S. (2011)
APCluster: an R package for affinity propagation clustering.
\emph{Bioinformatics} \bold{27}, 2463-2464.
DOI: \doi{10.1093/bioinformatics/btr406}.
}
\seealso{\code{\linkS4class{APResult}},
  \code{\linkS4class{ExClust}}, \code{\link{cutree}}}
\examples{
## 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))
}
\keyword{cluster}
\keyword{methods}