## S3 method for class 'matrix,missing':
apclusterK(s, x, K, prc=10, bimaxit=20, exact=FALSE,
maxits=1000, convits=100, lam=0.9, includeSim=FALSE, details=FALSE,
nonoise=FALSE, seed=NA, verbose=TRUE)
## S3 method for class 'function,ANY':
apclusterK(s, x, K, prc=10, bimaxit=20, exact=FALSE,
maxits=1000, convits=100, lam=0.9, includeSim=TRUE, details=FALSE,
nonoise=FALSE, seed=NA, verbose=TRUE, ...)
## S3 method for class 'character,ANY':
apclusterK(s, x, K, prc=10, bimaxit=20, exact=FALSE,
maxits=1000, convits=100, lam=0.9, includeSim=TRUE, details=FALSE,
nonoise=FALSE, seed=NA, verbose=TRUE, ...)
x
is a matrix or data
frame, rows are interpreted as samples and columns are
interpreted as features; apart from matrices or data frames,
x
may be any other structurepreferenceRange
)apcluster
should executeapcluster
terminates if the examplars have not
changed for convits
iterationsapcluster
; should be a value in
the range [0.5, 1);
higher values correspond to heavy damping which may be
needed if oscillations occurTRUE
, the similarity matrix (either computed
internally or passed via the s
argument) is stored to the
slot sim
of the returned
APResult
object. The default is <TRUE
, more detailed information about the
algorithm's progress is stored in the output object
(see APResult
)apcluster
adds a small amount of noise to
s
to prevent degenerate cases; if TRUE
,
this is disabledNA
,
the seed remains unchangedAPResult
object.apclusterK
first runs preferenceRange
to determine
the range of meaningful choices of the input preference p
. Then
it decreases p
exponentially for a few iterations to obtain a
good initial guess for p
. If the number of clusters is still
too far from the desired goal, bisection is applied. When called with a similarity matrix as input, the function performs
the procedure described above. When called with the name of a package-provided
similarity function or a user-provided similarity function object and
input data, the function first computes the similarity matrix before
running apclusterK
on this similarity matrix. The similarity
matrix is returned for later use as part of the APResult object
depending on whether includeSim
was set to TRUE
(see
argument description above).
Apart from minor adaptations and optimizations, the implementation is
largely analogous to Frey's and Dueck's Matlab code
(see
Frey, B. J. and Dueck, D. (2007) Clustering by passing messages
between data points. Science 315, 972-976.
DOI:
Bodenhofer, U., Kothmeier, A., and Hochreiter, S. (2011)
APCluster: an R package for affinity propagation clustering.
Bioinformatics 27, 2463-2464.
DOI:
apcluster
, preferenceRange
,
APResult
## create three Gaussian clouds
cl1 <- cbind(rnorm(70, 0.2, 0.05), rnorm(70, 0.8, 0.06))
cl2 <- cbind(rnorm(50, 0.7, 0.08), rnorm(50, 0.3, 0.05))
cl3 <- cbind(rnorm(60, 0.8, 0.04), rnorm(60, 0.8, 0.05))
x <- rbind(cl1, cl2, cl3)
## run affinity propagation such that 3 clusters are obtained
apres <- apclusterK(negDistMat(r=2), x, K=3)
## show details of clustering results
show(apres)
## plot clustering result
plot(apres, x)
Run the code above in your browser using DataLab