Cluster-class {flowMatch} | R Documentation

## Cluster: A class representing a cell population in FC

### Description

An object of class "`Cluster`" represents a cluster or a cell population. We model a cluster with a normal distribution. An object of class "`Cluster`" therefore represents a cluster with a mean vector, a covariance matrix and the size of the cluster.

### Creating Object

An object of class `Cluster` is usually created when constructing an object of class `ClusteredSample`. Unless you know exactly what you are doing, creating an object of class "`Cluster`" using `new` or using the constructor is discouraged.

An object of class "`Cluster`" can be created using the following constructor
`Cluster(size, center, cov, cluster.id = NA_integer_, sample.id=NA_integer_)`
The arguments of the constructor bear usual meaning as described in the value section above.

### Slots

An object of class "`Cluster`" contains the following slots:

`size`:

  An integer denoting the number of points (cells) present in the cluster.

`center`:

  A numeric vector denoting the center of the cluster.

`cov`:

  A matrix denoting the covariances of the underlying normal distribution of the cluster.

`cluster.id`:

  The index of the cluster (relative to other clusters in same sample). Default is `NA_integer_` .

`sample.id`:

  The index of sample in which the cluster belongs to. Default is `NA_integer_` .

### Accessors

All the slot accessor functions take an object of class `Cluster`. I show usage of the first accessor function. Other functions can be called similarly.

`get.size`:

  Returns the number of cells in the cluster.

  Usage: `get.size(object)`

  here `object` is a `Cluster` object.

`get.center`:

  Returns the center of the cluster.

`get.cov`:

  Returns the covariances matrix of the cluster.

`get.cluster.id`:

  Returns the index of the cluster (relative to other clusters in same sample).

`get.sample.id`:

  Returns the index of sample in which the cluster belongs to.

`sample.id<-`:

  Set the index of sample in which the cluster belongs to.

### Methods

show

  Display details about the `Cluster` object.

summary

  Return descriptive summary for each `Cluster` object.

  Usage: `summary(Cluster)`

### Author(s)

Ariful Azad

### See Also

`ClusteredSample`

### Examples

    ## An object of class "Cluster"" is usually created when constructing a "ClusteredSample".
    ## Unless you know exactly what you are doing, creating an object of class "Cluster"
    ## using new or using the constructor is discouraged.

    ## ------------------------------------------------
    ## load data and retrieve a sample
    ## ------------------------------------------------

    library(healthyFlowData)
    data(hd)
    sample = exprs(hd.flowSet[[1]])

    ## ------------------------------------------------
    ## cluster sample using kmeans algorithm
    ## and retrive the parameters of  the first cluster
    ## ------------------------------------------------

    km = kmeans(sample, centers=4, nstart=20)
    center1 = km$centers[1,]
    # compute the covariance matrix of the first cluster
    cov1 = cov(sample[km$cluster==1,])
    size1 = length(which(km$cluster==1))

    ## ------------------------------------------------
    ## Create an object of class "Cluster"
    ## and show summary
    ## ------------------------------------------------

    clust = Cluster(size=size1, center=center1, cov=cov1)
    summary(clust)

[Package flowMatch version 1.16.0 Index]