removeDropletClasses {twoddpcr} | R Documentation |
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.
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)
droplets |
A |
... |
Other parameters depending on the type of |
classesToRemove |
A vector of character strings corresponding to the
classes that should be removed. Defaults to |
keepUnclassified |
A logical flag determining whether unclassified
droplets (i.e. "Rain" or "N/A") should be kept. Defaults to |
cMethod |
This is the name or column number corresponding to the
classification in |
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.
Anthony Chiu, anthony.chiu@cruk.manchester.ac.uk
This function can remove "N/A" droplets from classifications
produced by gridClassify
.
## 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)