dist.matrix {flowMatch} | R Documentation

## Dissimilarity matrix between each pair of clusters/meta-clusters across a pair of samples/templates

### Description

Calculate a matrix storing the dissimilarities between each pair of clusters (meta-clusters) across a pair of samples (templates) `S1` and `S2`. `(i,j)th` entry of the matrix stores dissimilarity between `i-th` cluster (meta-cluster) from `S1` and the `j-th` cluster (meta-cluster) from `S2`.

### Usage

    dist.matrix(object1,object2, dist.type = 'Mahalanobis')

### Arguments

`object1` | an object of class `ClusteredSample` or `Template`.
`object2` | an object of class `ClusteredSample` or `Template`.
`dist.type` | character, indicating the method with which the dissimilarity between a pair of clusters (meta-clusters) is computed. Supported dissimilarity measures are: 'Mahalanobis', 'KL' and 'Euclidean', with the default is set to 'Mahalanobis' distance.

### Details

Consider two FC samples/templates `S1` and `S2` with `k1` and `k2` clusters/meta-clusters. The dissimilarity between each pair of cluster (meta-clusters) across `S1` and `S2` is computed and stored in a (`k1 x k2`) matrix. The dissimilarity between `i-th` cluster (meta-cluster) from `S1` and `j-th` cluster (meta-cluster) from `S2` is computed using function `dist.cluster`.

### Value

`dist.matrix` function returns a (`k1 x k2`) matrix where `k1` and `k2` are the number of clusters (meta-clusters) in the first and the second samples (templates) respectively. `(i,j)`th entry of the matrix contains the dissimilarity between the `i-th` cluster (meta-cluster) from sample1 (template1) and the `j-th` cluster (meta-cluster) from sample2 (template2).

### Author(s)

Ariful Azad

### See Also

`dist.cluster`

### Examples

    ## ------------------------------------------------
    ## load data and retrieve two samples
    ## ------------------------------------------------

    library(healthyFlowData)
    data(hd)
    sample1 = exprs(hd.flowSet[[1]])
    sample2 = exprs(hd.flowSet[[2]])

    ## ------------------------------------------------
    ## cluster sample using kmeans algorithm
    ## ------------------------------------------------

    clust1 = kmeans(sample1, centers=4, nstart=20)
    clust2 = kmeans(sample2, centers=4, nstart=20)
    cluster.labels1 = clust1$cluster
    cluster.labels2 = clust2$cluster

    ## ------------------------------------------------
    ## Create ClusteredSample object
    ## and compute the Mahalanobis distance between
    ## each pair of clsuters and save it in a matrix
    ## ------------------------------------------------

    clustSample1 = ClusteredSample(labels=cluster.labels1, sample=sample1)
    clustSample2 = ClusteredSample(labels=cluster.labels2, sample=sample2)
    ## compute the dissimilarity matrix
    DM = dist.matrix(clustSample1, clustSample2, dist.type='Mahalanobis')
    print(DM)

[Package flowMatch version 1.22.0 Index]