Description Usage Arguments Value Author(s) See Also Examples
If droplets
is a data frame, the droplets are classified
using the k-nearest neighbour algorithm against a training data set.
If droplets
is a ddpcrWell
object, the droplets
in the well are classified and returned in another ddpcrWell
object.
If droplets
is a ddpcrPlate
object, the
wells are combined and classified together, with the resulting
classification assigned to the ddpcrPlate
object.
1 2 3 4 5 6 7 8 9 10 | knnClassify(droplets, trainData, cl, k, prob = 0, ...)
## S4 method for signature 'data.frame'
knnClassify(droplets, trainData, cl, k, prob = 0, fullTable = TRUE)
## S4 method for signature 'ddpcrWell'
knnClassify(droplets, trainData, cl, k, prob = 0)
## S4 method for signature 'ddpcrPlate'
knnClassify(droplets, trainData, cl, k, prob = 0)
|
droplets |
A |
trainData |
A data frame of training data with columns
|
cl |
A vector of classes corresponding to |
k |
The number of nearest neighbours to use in the algorithm. |
prob |
The minimal proportion of votes for the winning class needed to assert that a droplet belongs to the class. This figure should be a float between 0 and 1. For example, if 0.6 then at least 60 k-nearest neighbours need to be of one class, otherwise it is classified as "Rain". Defaults to 0, i.e. we do not use "Rain". |
... |
Other options depending on the type of |
fullTable |
If |
An object with the new classification.
If droplets
is a data frame, return data frame or factor
(depending on the value of fullTable
) of the droplet classification
under the k-NN algorithm.
Anthony Chiu, anthony.chiu@cruk.manchester.ac.uk
This method uses the knn
function.
To manually set and retrieve classifications, use the
wellClassification
, plateClassification
and
plateClassificationMethod
methods.
kmeansClassify
provides a wrapper for the k-means clustering
algorithm.
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 | ### Use the KRASdata dataset for all of these examples.
## Use k-means clustering to classify one sample. Use this as training
## data for the K-Nearest Neighbour algorithm.
trainingData <- KRASdata[["E03"]]
trainingData <- kmeansClassify(trainingData)$data
## Classify a dataframe using k-NN with k = 1 and the above training data.
aWell <- knnClassify(
KRASdata[["F03"]],
trainData=trainingData[, c("Ch1.Amplitude", "Ch2.Amplitude")],
cl=trainingData$class,
k=1)
dropletPlot(aWell, cMethod="class") # visualising the classification
## We can change k to a larger number, here with a ddpcrWell object.
aWell <- ddpcrWell(well=KRASdata[["E03"]])
aWell <- knnClassify(
aWell,
trainData=trainingData[, c("Ch1.Amplitude", "Ch2.Amplitude")],
cl=trainingData$class,
k=3)
dropletPlot(aWell, cMethod="knn") # visualising the classification
## Changing the 'prob' parameter means that droplets with less than 'prob'
## of the votes will not be classified. We do this for a ddpcrPlate
## object.
krasPlate <- ddpcrPlate(wells=KRASdata[c("E03", "H03", "C04", "F04")])
krasPlate <- knnClassify(
krasPlate,
trainData=trainingData[, c("Ch1.Amplitude", "Ch2.Amplitude")],
cl=trainingData$class,
k=3,
prob=0.6)
dropletPlot(krasPlate, cMethod="knn") # visualising the classification
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.