thresholdClassify {twoddpcr} | R Documentation

## Set thresholds to classify droplets.

### Description

Classify droplets as "NN", "NP", "PN" or "PP" depending on whether they lie above or below given thresholds. This is illustrated in the details and parameters for more detail.

### Usage

    thresholdClassify(droplets, ch1Threshold = 6500, ch2Threshold = 2900, ...)

    ## S4 method for signature 'data.frame'
    thresholdClassify(
      droplets,
      ch1Threshold = 6500,
      ch2Threshold = 2900,
      fullTable = TRUE
    )

    ## S4 method for signature 'ddpcrWell'
    thresholdClassify(
      droplets,
      ch1Threshold = 6500,
      ch2Threshold = 2900,
      classMethodLabel = "thresholds"
    )

    ## S4 method for signature 'ddpcrPlate'
    thresholdClassify(
      droplets,
      ch1Threshold = 6500,
      ch2Threshold = 2900,
      classMethodLabel = "thresholds"
    )

### Arguments

`droplets` | A `ddpcrWell` object or a data frame of droplet amplitudes with columns `Ch1.Amplitude` and `Ch2.Amplitude`.
`ch1Threshold` | The channel 1 upper bound for the NN and NP classes. Defaults to 8000
`ch2Threshold` | The channel 2 upper bound for the NN and PN classes. Defaults to 3000.
`...` | Other options depending on the type of `droplets`.
`fullTable` | Whether to return a data frame including amplitude figures. If `TRUE`, a data frame with columns `Ch1.Amplitude`, `Ch1.Amplitude` and `class` is returned. If `FALSE`, a factor with levels in `ddpcr$classesRain` is returned, where each entry corresponds to each row in `droplets` (and `trainingData` is automatically set to `FALSE`). Defaults to `TRUE`.
`classMethodLabel` | A name (as a character string) of the classification method. Defaults to "thresholds".

### Details

The `threshold` parameters correspond to those in the following diagram:

    Ch1 ^          |
        |          |
        |          |
        |    PN    |    PP
        |          |
        |          |
       a|__________|__________
        |          |
        |          |
        |    NN    |    NP
        |          |
        |          |
        --------------------->
                   b      Ch2

Specifically:

a:

  `ch1Threshold`,

b:

  `ch2Threshold`.

### Value

If `droplets` is a data frame, return a data frame or factor (depending on the `trainingData` and `fullTable` parameters) with a classification for droplets in the chosen regions.

If `droplets` is a `ddpcrWell` object, return a `ddpcrWell` object with the appropriate classification.

If `droplets` is a `ddpcrPlate` object, return a `ddpcrPlate` object with the appropriate classification.

### Author(s)

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

### See Also

This function is a special case of `gridClassify`.

### Examples

    ## Use thresholds to set a classification for a data frame.
    gCl <- thresholdClassify(KRASdata[["E03"]],
                             ch1Threshold=6789, ch2Threshold=3000)
    str(gCl)

    ## The same works for ddpcrWell objects.
    aWell <- ddpcrWell(well=KRASdata[["E03"]])
    aWell <- thresholdClassify(aWell, ch1Threshold=6789, ch2Threshold=3000)
    str(aWell)

    ## ddpcrPlate objects work in exactly the same way.
    krasPlate <- ddpcrPlate(wells=KRASdata)
    krasPlate <- thresholdClassify(krasPlate,
                                   ch1Threshold=6789, ch2Threshold=3000)
    lapply(plateClassification(krasPlate, withAmplitudes=TRUE), head, n=1)

    ## The default classification method (column name) is 'threshold'. It can be
    ## changed by providing a label.
    krasPlate <- ddpcrPlate(wells=KRASdata)
    krasPlate <- thresholdClassify(krasPlate,
                                   ch1Threshold=6789, ch2Threshold=3000,
                                   classMethodLabel="manual")
    lapply(plateClassification(krasPlate, withAmplitudes=TRUE), head, n=1)

[Package twoddpcr version 1.16.0 Index]