kmeansClassify: K-means classify the wells in a 'ddpcrWell' or 'ddpcrPlate'...

Description Usage Arguments Value Author(s) See Also Examples

Description

If droplets is a data frame, the droplets are classified using the k-means clustering algorithm.

For ddpcrWell, the droplets are classified by using the k-means clustering algorithm.

For ddpcrPlate, all of the wells are combined and classified, with this new classification assigned to the ddpcrPlate object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
kmeansClassify(
  droplets,
  centres = matrix(c(0, 0, 10000, 0, 0, 7000, 10000, 7000), ncol = 2, byrow = TRUE),
  ...
)

## S4 method for signature 'data.frame'
kmeansClassify(
  droplets,
  centres = matrix(c(0, 0, 10000, 0, 0, 7000, 10000, 7000), ncol = 2, byrow = TRUE),
  fullTable = TRUE
)

## S4 method for signature 'ddpcrWell'
kmeansClassify(
  droplets,
  centres = matrix(c(0, 0, 10000, 0, 0, 7000, 10000, 7000), ncol = 2, byrow = TRUE)
)

## S4 method for signature 'ddpcrPlate'
kmeansClassify(
  droplets,
  centres = matrix(c(0, 0, 10000, 0, 0, 7000, 10000, 7000), ncol = 2, byrow = TRUE)
)

Arguments

droplets

A ddpcrWell or ddpcrPlate object, or a data frame with columns Ch1.Amplitude and Ch2.Amplitude.

centres

Either:

  • A matrix corresponding to the initial centres to use for the k-means algorithm; or

  • An integer corresponding to the number of clusters. If this is set, the initial centres are randomly set.

Defaults to matrix(c(0, 0, 10000, 0, 0, 7000, 10000, 7000), ncol=2, byrow=TRUE)

...

Other options depending on the type of droplets.

fullTable

If TRUE, returns a full data frame of droplets and their classification; if FALSE, simply returns a factor corresponding to this classification. Defaults to TRUE.

Value

An object with the new classification.

If droplets is a data frame, a list is returned with the following components:

data

A data frame or vector corresponding to the classification.

centres

A data frame listing the final centre points from the k-means algorithm with the corresponding cluster labels.

Author(s)

Anthony Chiu, anthony.chiu@cruk.manchester.ac.uk

See Also

This method uses the kmeans function.

To manually set and retrieve classifications, use the wellClassification, plateClassification and plateClassificationMethod methods.

For a supervised classification approach, one may want to consider knnClassify.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
### Use the KRASdata dataset for all of these examples.

## Use K-means clustering to classify droplets into four (the default
## number) classes.
aWell <- kmeansClassify(KRASdata[["E03"]])

## We can look the the classification or the centres.
head(aWell$data)
aWell$centres

## Specify 3 centres for a different sample in KRASdata.
aWell <- kmeansClassify(KRASdata[["H04"]], centres=3)
head(aWell$data)

## We can be more specific with the choice of centres.
aWell <- kmeansClassify(KRASdata[["H04"]],
                       centres=matrix(c(5000, 1500, 5500, 7000, 10000,
                                        2000), ncol=2, byrow=TRUE))

## We can use \code{ddpcrWell} objects directly as a parameter.
aWell <- ddpcrWell(well=KRASdata[["E03"]])
kmeansClassify(aWell)

## We can take multiple samples in a \code{ddpcrPlate} object and
## classify everything together.
krasPlate <- ddpcrPlate(wells=KRASdata)
kmeansClassify(krasPlate)

twoddpcr documentation built on Nov. 8, 2020, 5:49 p.m.