Learn R Programming

MotilityLab (version 0.2-5)

clusterTracks: Cluster Tracks

Description

Perform a hierarchical clustering of a set of tracks according to a given vector of track measures.

Usage

clusterTracks(tracks, measures, scale = TRUE, ...)

Arguments

tracks
the tracks that are to be clustered.
measures
a function, or a vector of functions (see TrackMeasures). Each function is expected to return a single number given a single track.
scale
logical indicating whether the measures values shall be scaled using the function scale before the clustering.
...
additional parameters to be passed to hclust.

Value

An object of class *hclust*, see hclust.

Details

The measures are applied to each of the tracks in the given tracks object. According to the resulting values, the tracks are clustered using a hierarchical clustering (see hclust). If scale is TRUE, the measure values are scaled to mean value $0$ and standard deviation $1$ (per measure) before the clustering.

Examples

Run this code
## Cluster tracks according to the mean of their Hust exponents along X and Y

cells <- c(TCells,Neutrophils)
real.celltype <- rep(c("T","N"),c(length(TCells),length(Neutrophils)))
## Prefix each track ID with its cell class to evaluate the clustering visually
names(cells) <- paste0(real.celltype,seq_along(cells))
clust <- clusterTracks( cells, hurstExponent )
plot( clust )
## How many cells are "correctly" clustered?
sum( real.celltype == c("T","N")[cutree(clust,2)] )

Run the code above in your browser using DataLab