Learn R Programming

apcluster (version 1.0.2)

plot-methods: Plot APResult objects

Description

Plotting functions for S4 class APResult

Usage

## S3 method for class 'APResult,missing':
plot(x,
             type=c("netsim", "dpsim", "expref"),
             xlab="# Iterations",
             ylab="Similarity", ...)
## S3 method for class 'APResult,matrix':
plot(x, y,
              connect=TRUE, xlab="", ylab="", ...)

Arguments

x
an APResult object created by affinity propagation clustering
y
a matrix with the original data (must be 2D to work)
type
a string or array of strings indicating which performance measures should be plotted; valid values are "netsim", "dpsim", and "expref" which can be used in any combination or
xlab
label for x axis of plot
ylab
label for y axis of plot
connect
if TRUE, lines are drawn that connect every exemplar with all its cluster members
...
all other arguments are passed to the standard plot command that is called internally to display the graphics window

Value

  • both variants of plot return an invisible NULL

Details

Provided that apcluster was called with details=TRUE, plot without a y argument displays graphs of performance measures over execution time.

If plot is called with the second argument, y, being the original data matrix, a plot of clustering results superimposed on the original data set is created. This only works for 2D data, i.e. if y has 2 columns.

References

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

Frey, B. J. and Dueck, D. (2007) Clustering by passing messages between data points. Science 315, 972-976.

See Also

APResult-class, apcluster

Examples

Run this code
## create two Gaussian clouds
cl1 <- cbind(rnorm(100,0.2,0.05),rnorm(100,0.8,0.06))
cl2 <- cbind(rnorm(50,0.7,0.08),rnorm(50,0.3,0.05))
x <- rbind(cl1,cl2)

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

## run affinity propagation
apres <- apcluster(sim, details=TRUE)

## plot information about clustering run
plot(apres)

## plot clustering result
plot(apres, x)

Run the code above in your browser using DataLab