mahalanobisRain: Define 'rain' (unclassified) droplets by fitting the clusters...

Description Usage Arguments Value Author(s) Examples

Description

Assume that each of the classified clusters are bivariate normally distributed. We add fuzziness to the classifications by assigning droplets far away from the centres as "Rain". We use the Mahalanobis distance for each cluster to determine whether a droplet is 'too far away'.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
mahalanobisRain(droplets, cMethod, maxDistances = 30, ...)

## S4 method for signature 'data.frame'
mahalanobisRain(droplets, cMethod, maxDistances = 30, fullTable = TRUE)

## S4 method for signature 'ddpcrWell'
mahalanobisRain(droplets, cMethod, maxDistances = 30)

## S4 method for signature 'ddpcrPlate'
mahalanobisRain(droplets, cMethod, maxDistances = 30)

Arguments

droplets

A ddpcrWell or ddpcrPlate object, or a data frame of droplets with "Ch1.Amplitude" and "Ch2.Amplitude" columns, as well as a class column.

cMethod

The name or column number of the classification for which we want to add rain to.

maxDistances

A list of (levels) with keys in c("NN", "PN", "NP", "PP"). If the list is empty or set as NULL, no rain is added. If set as a single integer n, this value is taken for all classes, i.e. list("NN"=n, "PN"=n, "NP"=n, "PP"=n).

...

Other options depending on the type of droplets.

fullTable

If TRUE, returns a full data frame of droplets and their classification; if FALSE, simply returns a factor corresponding to this classification. Defaults to TRUE.

Value

An object where the specified class has "Rain" entries added.

Author(s)

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

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
## Take a data frame of droplets of transform it into the rigth format.
droplets <- KRASdata[["E03"]]
droplets$Cluster <- relabelClasses(droplets, classCol="Cluster")

## Add rain as a new column.
droplets$ClusterMahRain <-
    mahalanobisRain(droplets, cMethod="Cluster", fullTable=FALSE)
table(droplets$ClusterMahRain)

## The maximum distance around each mean can be changed uniformly.
droplets$ClusterMahRain <-
    mahalanobisRain(droplets, cMethod="Cluster", maxDistances=35,
                    fullTable=FALSE)
table(droplets$ClusterMahRain)

## Or we can change the maximum distances for each individual cluster.
droplets$ClusterMahRain <-
    mahalanobisRain(droplets, cMethod="Cluster",
                    maxDistances=list(NN=35, NP=30, PN=30, PP=30),
                    fullTable=FALSE)
table(droplets$ClusterMahRain)

# This method works the same for ddpcrWell objects.
aWell <- ddpcrWell(well=KRASdata[["E03"]])
aWell <- mahalanobisRain(aWell, cMethod="Cluster")
table(wellClassification(aWell, cMethod="ClusterMahRain"))

# Likewise for ddpcrPlate objects.
krasPlate <- ddpcrPlate(wells=KRASdata[c("E03", "H03", "C04", "F04")])
krasPlate <- mahalanobisRain(krasPlate, cMethod="Cluster")
lapply(plateClassification(krasPlate, cMethod="ClusterMahRain"), table)

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