removeDropletClasses {twoddpcr} | R Documentation

## Retrieve a data frame of droplet amplitudes with droplets of a given class removed.

### 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

    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

    ## 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)

[Package twoddpcr version 1.6.0 Index]