removeDropletClasses: Retrieve a data frame of droplet amplitudes with droplets of...

Description Usage Arguments Value Author(s) See Also Examples

Description

By default, all droplets classified as "N/A" or "Rain" will be removed. Including these droplets is useful for visualisation purposes, but they could be a problem in some scenarios, e.g. if we wish to use the classification as a training data set.

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
25
26
27
28
29
30
removeDropletClasses(
  droplets,
  ...,
  classesToRemove = NULL,
  keepUnclassified = FALSE
)

## S4 method for signature 'data.frame'
removeDropletClasses(
  droplets,
  cMethod = "class",
  classesToRemove = NULL,
  keepUnclassified = FALSE
)

## S4 method for signature 'ddpcrWell'
removeDropletClasses(
  droplets,
  cMethod,
  classesToRemove = NULL,
  keepUnclassified = FALSE
)

## S4 method for signature 'ddpcrPlate'
removeDropletClasses(
  droplets,
  cMethod,
  classesToRemove = NULL,
  keepUnclassified = FALSE
)

Arguments

droplets

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

...

Other parameters depending on the type of droplets.

classesToRemove

A vector of character strings corresponding to the classes that should be removed. Defaults to NULL, i.e. remove nothing.

keepUnclassified

A logical flag determining whether unclassified droplets (i.e. "Rain" or "N/A") should be kept. Defaults to FALSE, i.e. remove them.

cMethod

This is the name or column number corresponding to the classification in droplets. This column should only have entries in "NN", "PN", "NP, "PP", "Rain" and "N/A". Defaults to "class".

Value

If a ddpcrWell object is given, return a data frame corresponding to droplets with the given droplet classes removed. If a ddpcrPlate object is given, return a list of data frames instead.

Author(s)

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

See Also

This function can remove "N/A" droplets from classifications produced by gridClassify.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
## Take a data frame and transform it into the right format.
aWell <- KRASdata[["E03"]]
aWell$Cluster <- relabelClasses(aWell, classCol="Cluster")

## Add rain using the Mahalanobis distance.
aWell$ClusterMahRain <-
    mahalanobisRain(aWell, cMethod="Cluster", fullTable=FALSE)
table(aWell$ClusterMahRain)

## Suppose we want to use this for training. Remove the "Rain" droplets.
aWellCleaned <- removeDropletClasses(aWell, cMethod="ClusterMahRain")
table(aWellCleaned$ClusterMahRain)

## All of the above works with ddpcrWell objects.
aWell <- ddpcrWell(well=KRASdata[["E03"]])
aWell <- mahalanobisRain(aWell, cMethod="Cluster")
trainingData <- removeDropletClasses(aWell, cMethod="ClusterMahRain")
table(wellClassification(aWell, "ClusterMahRain"))
table(trainingData$ClusterMahRain)

## Likewise for ddpcrPlate objects we can create the training data.
krasPlate <- ddpcrPlate(wells=KRASdata[c("E03", "F03", "G03")])
krasPlate <- mahalanobisRain(krasPlate, cMethod="Cluster")
trainingData <- removeDropletClasses(krasPlate, cMethod="ClusterMahRain")
cl <- plateClassification(krasPlate, cMethod="ClusterMahRain")
cl <- unlist(cl)
table(cl)
td <- do.call(rbind, trainingData)
table(td$ClusterMahRain)

## We could also remove other droplet classes, such as the "PN" and "PP"
## clusters.
noPNPP <- removeDropletClasses(krasPlate, cMethod="ClusterMahRain",
                               classesToRemove=c("PN", "PP"))
td <- do.call(rbind, noPNPP)
table(td$ClusterMahRain)

## The same could be done, but with the "Rain" retained.
noPNPPWithRain <- removeDropletClasses(krasPlate, cMethod="ClusterMahRain",
                                       classesToRemove=c("PN", "PP"),
                                       keepUnclassified=TRUE)
td <- do.call(rbind, noPNPPWithRain)
table(td$ClusterMahRain)

CRUKMI-ComputationalBiology/twoddpcr documentation built on Feb. 14, 2021, 9:18 p.m.