calculateProxy: Calculation of Lifespan Proxies

Description Usage Arguments Details Value Examples

View source: R/proxy.R

Description

calculateProxy will calculate a proxy for each sample, providing a single number which encapsulates lifespan.

plotProxy will create a plot showing how the proxy is calculated for a specified sample.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
calculateProxy(
  CFUsMLE,
  maxTime = max(CFUsMLE$Time),
  viability = 0.05,
  constraint = "decrease",
  ...
)

plotProxy(
  CFUsMLE,
  Sample,
  maxTime = max(CFUsMLE$Time),
  viability = 0.05,
  constraint = "decrease",
  ...
)

Arguments

CFUsMLE

A data.frame produced by analyseColonyVectors containing CFU data from which proxies are to be calculated. Must contain the column names "Sample", "Time" and "ColonyFormingUnitsPerDroplet".

maxTime

The maximum time. Proxy solutions will be searched for in the interval between 0 and "maxTime". Defaults to the maximum value in the "Time" column of CFUsMLE.

viability

The proportion of viable cells. See 'Details'. Defaults to 0.05.

constraint

The constraint used when fitting a spline to CFU data. Must be one of "none", "increase", "decrease", "convex", "concave" or "periodic". See cobs. Defaults to "decrease".

...

Additional arguments passed to cobs.

Sample

Length 1 character vector specifying which sample to plot.

Details

Proxies are calculated as the square root of the amount of time take for a sample to reach a specified viability. This is achieved by fitting a median spline (see cobs) to the CFU data. Specifically, CFUsMLE$Time is fitted against log10(CFUsMLE$ColonyFormingUnitsPerDroplet + 1). The proxy is the square root of the amount of time taken for the fitted values to reach the indicated viability. In the case that no solutions are found within the specified time interval, the proxy is set as NA. In the case that multiple solutions are found, the proxy is set as the first solution.

Value

calculateProxy will return a data.frame containing the proxy for each sample.

plotProxy will return a ggplot object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#Get a data.frame showing maximum likelihood estimation as produced by analyseColonyVectors
CFUsMLE <- system.file("extdata", "CFUsMLE.csv", package="DeadOrAlive")
CFUsMLE <- read.csv(CFUsMLE)

#Remove low quality data points
CFUsMLE <- CFUsMLE[CFUsMLE$TotalExclusions<=1,]

#Plot proxy calculation for the wt (972 h-)
g1 <- plotProxy(CFUsMLE, "972 h-")
print(g1)

#Calculate a proxy for all samples
proxy <- calculateProxy(CFUsMLE)

#Add proxies to CFUsMLE
CFUsMLE$Proxy <- proxy$Proxy[match(CFUsMLE$Sample, proxy$Sample)]

#Plot all lifespan curves and color by proxy
require(ggplot2)
g2 <- g2 <- ggplot(CFUsMLE, aes(Time, ColonyFormingUnitsPerDroplet + 1, group=Sample, color=Proxy))
g2 <- g2 + geom_point() + geom_line()
g2 <- g2 +  scale_y_log10() + xlab("Time / days") + ylab("CFUs / droplet + 1")
print(g2)

JohnTownsend92/DeadOrAlive documentation built on Aug. 14, 2021, 6:16 p.m.