Learn R Programming

SNFtool (version 2.3.1)

plotAlluvial: Plot Alluvial

Description

This function plots an alluvial (Parallel coordinate plot) of sample clusterings for a specified number of clusters. Samples can be coloured by providing a vector of colours, allowing for the visualization of sample properties over a range of clustering number choices.

*This is a wrapper function calling the Alluvial Package (Bojanowski M. & Edwards R)

Usage

plotAlluvial(W, clust.range, color.vect)

Arguments

W

Affinity matrix of dimension n.samples by n.samples

clust.range

Integer vector specifying the number of clusters for each clustering

color.vect

A vector of color's of length n.samples to colour the samples

Value

Plots an alluvial plot for range of clustering choices.

See Also

More information on Alluvial Package

Examples

Run this code
# NOT RUN {
K <- 20
alpha <- 0.5
iter <- 20

data(Data1)
data(Data2)

dist1 <- (dist2(as.matrix(Data1), as.matrix(Data1)))^(1/2)
dist2 <- (dist2(as.matrix(Data2), as.matrix(Data2)))^(1/2)

W1 <- affinityMatrix(dist1, K, alpha)
W2 <- affinityMatrix(dist2, K, alpha)

W <- SNF(list(W1, W2), K, iter)

#Plots the alluvial with no colouring
plotAlluvial(W, 2:5)

#Change the colour of all samples a single colour
plotAlluvial(W, 2:5, col="red")

colour.breaks <- 30
#This will assign each sample to one of colour.breaks colour bins between green and red.
colFunc <- colorRampPalette(c("green", "red"))
colours <- colFunc(colour.breaks)[as.numeric(cut(Data1[,1],breaks=colour.breaks))]
plotAlluvial(W, 2:5, col=colours)
# }

Run the code above in your browser using DataLab