Learn R Programming

cellGrowth (version 1.16.0)

bandwidthCV: Bandwidth cross-validation

Description

Perform cross-validation to detect optimal bandwidth

Usage

bandwidthCV(well, fileParser = readYeastGrower, getWellIds = getWellIdsTecan, bandwidths = seq(0.5 * 3600, 10 * 3600, length.out = 30), nFold = 10, nWell = 100, cutoff = 0.95, calibration = identity, scaleY = log2)

Arguments

well
well dataframe. See wellDataFrame.
fileParser
Converts the file generated by the machine to proper R format. See readYeastGrower for details.
getWellIds
function or vector. If function its parameter is the return value of fileParser. It should return a vector containing the well ids (e.g. A01, A02, ...). You can set the well ids vector directly. See getWellIdsTecan.
bandwidths
vector of bandwidths to test on
nFold
integer. In how many parts is the sample divided for cross-validation?
nWell
integer. How many wells out of the well dataframe will be used for cross validation?
cutoff
scalar between 0 and 1. See details.
calibration
function or list of functions. If function, calibration is applied to all raw data. If list, the well dataframe must contain a column machine. Depending on that column the according function in the list is applied to the raw data. See details
scaleY
function applied to the calibrated data.

Value

list with entries
bandwidth
"optimal" bandwidth
well
well dataframe
bandwidths
tested bandwidths
err2
squared error
err2std
Standard deviation of squared error
muStd
Standard deviation of max growth rate
oneStdOfMini
bandwidths within one std of best

Details

This function needs a few minutes time. The "optimal" bandwidth is the largest bandwidth which is in 95% (cutoff parameter) of all cases within one standard deviation of the best bandwidth. This should make the derivative of the fitted curve more robust. The raw values from the machine might not be directly optical densities (OD), which is needed to infer doubling time. Calibration functions for each machine can be provided to map raw values into OD using the calibration parameter.

Examples

Run this code
folder <- system.file("extdata", package="cellGrowth")
well <- wellDataFrame(file.path(folder, "plateLayout.txt"), file.path(folder,"machineRun.txt"))

## for a fast example, we use nWell = 1 here. Use a large number (default 100) for real life applications
bw <- bandwidthCV(well, nWell=1)

Run the code above in your browser using DataLab