Mercator-class {Mercator} | R Documentation |
The Mercator
Distance Visualization Object
Description
The Mercator
object represents a distance matrix together with
clustering assignments and a set of visualizations. It implements four
visualizations for clusters of large-scale, multi-dimensional data:
hierarchical clustering, multi-dimensional scaling, t-Stochastic
Neighbor Embedding (t-SNE), and iGraph. The default
Mercator
constructor applies one of ten metrics of
binaryDistance
to an object of the
BinaryMatrix
class.
Usage
Mercator(X, metric, method, K, ...)
addVisualization(DV, method, ...)
getClusters(DV)
Arguments
X |
Either a |
metric |
A |
method |
A visualization method, currently limited to
|
K |
An |
DV |
A distance visualization produced as the output of the
|
... |
Additional arguments passed on to the functions that
implement different methods for
|
Value
The Mercator
function constructs and returns a distance
visualization object of the
Mercator
class, including a distance matrix calculated on a
given metric and given visualizations. It is also possible (though not
advisable) to construct a Mercator
object directly using the
new
function. Default clustering in Mercator
is now
performed on the distance matrix using hierarchical clustering
(hclust) with the wardD2
linkage method.
The addVisualizations
function can be used to add additional
visualizations to an existing Mercator
object.
The getClusters
function returns a vector of cluster assignments.
Slots
metric
:Object of class
"character"
; the name of thebinaryDistance
applied to create this object.distance
:Object of class
"dist"
; the distance matrix used and represented by this object.view
:Object of class
"list"
; contains the results of calculations to generate each visualize the object.clusters
:A numeric vector of cluster assignments.
symbols
:A numeric vector of valid plotting characters, as used by
par(pch)
.palette
:A character vector of color names.
Methods
- plot(x, view = NULL, ask = NULL, ...):
-
Produce a plot of one or more visualizations within a Mercator object. The default
view
, when omitted, is the first one contained in the object. You can request multiple views at once; if the current plot layout doesn't have enough space in an interactive session, theask
parameters detemines whether the system will ask you before advancing to the next plot. When plotting a graph view, you can use an optionallayout
parameter to select a specific layout by name. - barplot(height, main = ”, sub = NULL, border = NA, space = 0, ...)
-
Produce a (colored) barplot of the silhouette widths for elements clustered in this class. Arguments are as described in te base function
barplot
. - scatter(object, view = NULL, ask = NULL, colramp = NULL, ...):
-
Produce a smooth scatter plot of one or more visualizations within a Mercator object. The default
view
, when omitted, is the first one contained in the object. You can request multiple views at once; if the current plot layout doesn't have enough space in an interactive session, theask
parameters detemines whether the system will ask you before advancing to the next plot. When plotting a graph view, you can use an optionallayout
parameter to select a specific layout by name. Arguments are otherwise the same as thesmoothScatter
function, execpt that the default color ramp istopo.colors
. - hist(x, breaks=123, ...):
-
Produce a histogram of distances calculated in the dissimilarity matrix generated in the
Mercator
object. - summary(object, ...):
-
Returns the chosen distance metric, dimensions of the distance matrix, and available, calculated visualizations in this object.
- dim(x):
-
Returns the dimensions of the distance matrix of this object.
- [:
-
Subsets the distance matrix of this object.
Author(s)
Kevin R. Coombes <krc@silicovore.com>, Caitlin E. Coombes
See Also
silhouette
, smoothScatter
,
topo.colors
, som
,
umap
.
Examples
# Form a BinaryMatrix
data("iris")
my.data <- as.matrix(iris[,c(1:4)])
my.rows <- as.data.frame(c(1:length(my.data[,1])))
my.binmat <- BinaryMatrix(my.data, , my.rows)
my.binmat <- t(my.binmat)
summary(my.binmat)
# Form a Mercator object
# Set K to the known number of species in the dataset
my.vis <- Mercator(my.binmat, "euclid", "hclust", K=3)
summary(my.vis)
hist(my.vis)
barplot(my.vis)
my.vis <- addVisualization(my.vis, "mds")
plot(my.vis, view = "hclust")
plot(my.vis, view = "mds")
scatter(my.vis, view ="mds")
# change the color palette
slot(my.vis, "palette") <- c("purple", "red", "orange", "green")
scatter(my.vis, view ="mds")
# Recover cluster identities
# What species comprise cluster 1?
my.clust <- getClusters(my.vis)
my.species <- iris$Species[my.clust == 1]
my.species