Title: | ELISA Data Analysis with Batch Correction |
---|---|
Description: | To run data analysis for enzyme-link immunosorbent assays (ELISAs). Either the five- or four-parameter logistic model will be fitted for data of single ELISA. Moreover, the batch effect correction/normalization will be carried out, when there are more than one batches of ELISAs. Feng (2018) <doi:10.1101/483800>. |
Authors: | Feng Feng [aut, cre] |
Maintainer: | Feng Feng <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.5 |
Built: | 2024-11-20 06:26:18 UTC |
Source: | CRAN |
An R package to run ELISA data analysis with the ability to do batch correction/normalization
This package is developed to run analysis of ELISA data. First, the calibration data are used to fit either the five- or four-parameter logistic model. Then the fitted model is used to predict the concentrations of unknown samples. If the batches of calibration data exist, the correction/normalization could be done. The corrected calibration curve are then used for predication.
Please refer to the vignettes to see details.
Maintainer: Feng Feng [email protected]
Feng, et al 2018 doi:10.1101/483800
to write annotations for an ELISA plate as an input to guide the functions to read OD values
annotate.plate( sample.id, sample.prefix, sample.suffix, num.sample, num.std = 8, byRow.sample = TRUE, byRow.replicates = TRUE, replicates.sample = 3, replicates.std = 3, rows, columns, std.first = TRUE )
annotate.plate( sample.id, sample.prefix, sample.suffix, num.sample, num.std = 8, byRow.sample = TRUE, byRow.replicates = TRUE, replicates.sample = 3, replicates.std = 3, rows, columns, std.first = TRUE )
sample.id |
character vector to specify the names/ids of the samples on the plate. Note, standard/calibration sample ids/names is fixed to be "s1","s2", etc, which are specified by the software and users don't need to privide. |
sample.prefix |
characters will be added to the beginning of sample names |
sample.suffix |
characters will be added to the end of sample names |
num.sample |
numeric number of samples to write |
num.std |
numeric number of standards |
byRow.sample |
boolean indicate whether to write sample names horizontally by row (TURE) or vertically by column (FALSE) |
byRow.replicates |
boolean indicate whether to write sample replicates horizontally by row (TURE) or vertically by column (FALSE) |
replicates.sample |
numeric number of replicates for each sample |
replicates.std |
numeric number of replicates for each standards |
rows |
numeric vector to specify which rows to be included in the annotation |
columns |
numeric vector to specify which columns to be included in the annotation |
std.first |
boolean to indicate whether to write standards first or the samples first. |
Based on the input to quickly write the annotations for ELISA plate. The output is in a 96-well format and will be used to giude the reading of OD plates. This way only a nxm dataframe can be used. To write non-regular annotation, you have to do it mannually.
a dataframe holding the annotations for the plate.
Get rid of zeros in a numeric vector before taking the logarithm of them. We basically replace the "zeros" with a negligible small value in order to avoid NaN upon the log-transformation.
avoidZero(x, fac = 10)
avoidZero(x, fac = 10)
x |
numeric values as input |
fac |
numeric a factor of scale in order to get a "small" value to replace zeros |
a vector of value with zeros replaced.
Combine the two lists of elisa_batch data.
combineData(eb1, eb2)
combineData(eb1, eb2)
eb1 |
list of elisa_batch data |
eb2 |
list of elisa_batch data |
When combining, we not only concatenate the two data sets, but also combine batches, meaning the two batches with same batch ID will be merged into one. We will not merge the runs. Therefore, same batch from different list will always have different runs. It is the user's responsibility to make sure the runs are different.
a list of elisa_batch data combining the two input lists (sorted);
elisa_batch-class
loadData
saveDB
#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #make a guess for the parameters, the other two parameters a and d #will be estimated based on data. model<-"5pl" pars<-c(7.2,0.5, 0.015) #5pl inits names(pars)<-c("xmid", "scal", "g") #do fitting. model will be written into data set. batches<-runFit(pars=pars, batches=batches, refBatch.ID=1, model=model ) #call to do predications based on the model. batches<-predictAll(batches); batches.old<-batches; #now suppose want to join/combine the two batches, old and new batches.com<-combineData(batches.old, batches);
#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #make a guess for the parameters, the other two parameters a and d #will be estimated based on data. model<-"5pl" pars<-c(7.2,0.5, 0.015) #5pl inits names(pars)<-c("xmid", "scal", "g") #do fitting. model will be written into data set. batches<-runFit(pars=pars, batches=batches, refBatch.ID=1, model=model ) #call to do predications based on the model. batches<-predictAll(batches); batches.old<-batches; #now suppose want to join/combine the two batches, old and new batches.com<-combineData(batches.old, batches);
S3 method as a constructor to build the S4
class object of elisa_batch elisa_batch-class
elisa_batch( batchID = NA_character_, desc = NA_character_, runs = list(), model.fit = list(), model.name = NA_character_, pars = c(-1), num.runs = 1, range.ODs = c(-1, -1), normFactor = NaN )
elisa_batch( batchID = NA_character_, desc = NA_character_, runs = list(), model.fit = list(), model.name = NA_character_, pars = c(-1), num.runs = 1, range.ODs = c(-1, -1), normFactor = NaN )
batchID |
character string to specify a batches |
desc |
character string for the data/experiment information |
runs |
list of elisa_plates in this run. There could be one or many plates in a run. |
model.fit |
list intend to contain information for the fitting of nls.lm. But not using it now. |
model.name |
character string of either the 5pl (5-parameter) or 4pl (4-parameter) logistic function |
pars |
numeric the actually parameters for the fitting. for example for the 5pl model they are c(a, d,xmid, scal, g). |
num.runs |
numeric the number of plates in this run. |
range.ODs |
numeric the min and max ODs |
normFactor |
numeric the batch effect normalization factor ("S"). |
S3 method as a constructor to build the S4
class object of elisa_batch elisa_batch-class
.
Normally this is called to build a empty object
with default values and then load the elisa_run data into it
an elisa_batch object
nls.lm
elisa_run-class
elisa_plate-class
elisa_batch-class
elisa_batch();
elisa_batch();
elisa_batch-class
define the S4 class of an elisa_batch object
batchID |
characters to specify the batch |
runs |
list of elisa_run objects |
num.runs |
numeric the number of elisa_runs in this batch |
pars |
numeric the actually parameters for the fitting. for example for the 5pl they are c(a, d,xmid, scal, g). |
model.fit |
list intend to contain information for the fitting of nls.lm. But not using it now. |
model.name |
characters of either the 5pl (5-parameter) or 4pl (4-parameter) logistic function |
range.ODs |
numeric the min and max ODs |
normFactor |
numeric the batch normalization factor ("S"). |
defining the S4 class of the elisa_batch. This holds the data for elisa batch. It contains one or many elisa_run objects.
batchID
character
desc
character
runs
list
num.runs
numeric
pars
numeric
model.fit
list
model.name
character
range.ODs
numeic
normFactor
numeric
nls.lm
elisa_plate-class
elisa_run-class
elisa_batch-class
elisa_batch();
elisa_batch();
S3 method as a constructor to build the S4
class object of the elisa_plate elisa_plate
elisa_plate( batchID = NA_character_, expID = NA_character_, desc = NA_character_, data.std = data.frame(), mdata.std = data.frame(), data.unknown = data.frame(), mdata.unknown = data.frame(), normFactor = NaN, range.ODs = c(-1, -1) )
elisa_plate( batchID = NA_character_, expID = NA_character_, desc = NA_character_, data.std = data.frame(), mdata.std = data.frame(), data.unknown = data.frame(), mdata.unknown = data.frame(), normFactor = NaN, range.ODs = c(-1, -1) )
batchID |
characters to specify the batch |
expID |
characters to specify experiment or plate ID |
desc |
characters for the data/experiment information |
data.std |
data.frame for standard curve data |
mdata.std |
data.frame containing the mean ODs and concentration of the calibration data |
data.unknown |
data.frame for data of samples with unknown concentration fitted with either four- or five-parameter logistic function. |
mdata.unknown |
data.frame containing the mean ODs and concentration by sample IDs. |
normFactor |
numeric the correction factor for batch effects. |
range.ODs |
numeric the min and max ODs in the plate. |
S3 method as a constructor to build the S4
class object of elisa_plate elisa_plate
.
Normally this is called to build an empty object
with default values and then load data into it
by calling loadData loadData
or load.ODs
load.ODs
an elisa_plate object
nls.lm
loadData
elisa_plate
load.ODs
elisa_plate();
elisa_plate();
elisa_plate
define the S4 class of an elisa_plate object
batchID |
characters to specify the batch |
expID |
characters to specify experiment or plate ID |
desc |
characters for the data/experiment information |
data.std |
data.frame for standard curve data |
data.unknown |
data.frame containing data for samples with unknown concentration |
normFactor |
numeric the correction factor for batch effects ("S"). |
mdata.unknown |
data.frame containing the mean ODs and concentration by sample IDs. |
mdata.std |
data.frame containing the mean ODs and concentrations for standard data |
defining the S4 class of the elisa_plate object.
This is the data structure to hold the elisa_plate Data.
It contains different slots for holding both standard and
unknown data. It also defines
the regression model and the correction parameter
for the batch effects.
Note: we assume each plate has its own standard curve.
batchID
character
expID
character
data.std
data.frame
data.unknown
data.frame
normFactor
numeric
desc
character
range.ODs
numeric
mdata.unknown
data.frame
mdata.std
data.frame
elisa_plate();
elisa_plate();
S3 method as a constructor to build the S4
class object of elisa_run elisa_run-class
elisa_run( batchID = NA_character_, desc = NA_character_, plates = list(), num.plates = 1, date = NA_character_, range.ODs = c(-1, -1) )
elisa_run( batchID = NA_character_, desc = NA_character_, plates = list(), num.plates = 1, date = NA_character_, range.ODs = c(-1, -1) )
batchID |
characters to specify the batch |
desc |
characters for data/experiment information |
plates |
list of elisa_plates in this run. could be one or many |
num.plates |
numeric the number of plates in this run. |
date |
charaters the date to run ELISA measurements |
range.ODs |
numeric the range of ODs for the measurements |
S3 method as a constructor to build the S4
class object of elisa_run elisa_run-class
.
Normally this is called to build a empty object
with default values and then load the elisa_run data into.
#
an elisa_run object
nls.lm
elisa_run-class
elisa_plate-class
elisa_run();
elisa_run();
elisa_run-class
defines the S4 class of elisa_run
batchID |
characters to specify the batch |
desc |
characters for the data/experiment information |
plates |
list of elisa_plates |
num.plates |
numeric the number of plates in this run |
date |
characters for the date of running the ELISA measurements |
defining the S4 class of the elisa_run object. This is list to hold the data for each elisa run. It contains one or many elisa plate objects.
batchID
character
plates
list
desc
character
num.plates
numeric
date
character
range.ODs
numeric
elisa_run();
elisa_run();
read in the paramters and the independent variable value(s), and then return the 5pl function value(s). For the 4pl model, set g to be 1.
f5pl(pars, x)
f5pl(pars, x)
pars |
numeric the parameters of the 5pl (or 4pl). It has the following content: [a, d, xmid, scal, g]. |
x |
numeric the log-transformed x value(s). |
The function has the following form
f(x)=a+(d-a)/((1+exp((xmid-x)/scal))^g)
the 5pl function value(s).
The inverse function of the 5pl. Set the value of g to be 1, if the 4pl is of interest.
inv.f5pl(pars, y)
inv.f5pl(pars, y)
pars |
the parameters of the function. It has the following content: [a, d, xmid, scale, g]. |
y |
the value to be reverse calculated. |
the value of the reverse function
Generic function to load OD data into an elisa_plate object
load.ODs(x, plate.header, plate.data, plate.blank, annotation, ....) ## S4 method for signature 'elisa_plate' load.ODs(x, plate.header, plate.data, plate.blank, annotation)
load.ODs(x, plate.header, plate.data, plate.blank, annotation, ....) ## S4 method for signature 'elisa_plate' load.ODs(x, plate.header, plate.data, plate.blank, annotation)
x |
the elisa_plate object to load data into |
plate.header |
characters |
plate.data |
data.frame OD readings |
plate.blank |
data.frame OD blank readings |
annotation |
data.frame annotation to guide reading. |
.... |
other parameters that will help reading data. |
It loads OD data into an elisa_plate object. The data usually read int from design file, annotation file, OD file and standard concentration data.
elisa_plate
: to load ODs to an elisa_plate object
Read the design file and then load the data according to the information in the design file.
loadData(design.file)
loadData(design.file)
design.file |
characters to specify the path and the file name of the design file. |
The design file contains all the information necessary
to read data. It has the following format
ExpID | FileName | Batch | Num_Plate | Date | AnnotationFile | Std_Conc | Dir_Annotation | Dir_StdConc |
Exp1 | file1.txt | Batch1 | 1 | 9/18/2009 | annote.txt | stdConc.txt | ||
Exp2 | file2.txt | Batch2 | 2 | 9/18/2009 | annote.txt | stdConc.txt | ||
The return data is a list of batches (elisa_batch-class
),
which are made of one or many elisa runs(elisa_run-class
)
. The
run could contain one or many elisa plates (elisa_plate-class
)
with data or annotation of each plate.
list | | | |||||
| | --batch1 | | | ||||
| | | | --run1 | | | |||
| | | | | | --plate1 | |||
| | | | | | --plate2 | |||
| | --batch2 | | | ||||
| | | | |||||
a list of batches holding different runs of elisa, which could contain one or many elisa_plates with data and annotations for each plate.
elisa_batch-class
elisa_plate-class
elisa_run-class
file.dir<-system.file("extdata", package="ELISAtools") loadData(file.path(file.dir,"design.txt"));
file.dir<-system.file("extdata", package="ELISAtools") loadData(file.path(file.dir,"design.txt"));
Load the serialized elisa_batch data from disk.
loadDB(db)
loadDB(db)
db |
characters to specify the path and file name the elisa data file. |
Here we deserialize elisa_batch data by wrapping the readRds() function call. The serialized elisa_batch data are assumed to have been correctly analyzed. We will print a summary for what has been read.
a list of batches holding different runs of elisa, which could contain one or many elisa_plates with data and annotations for each plate.
elisa_batch-class
loadData
saveDB
#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #make a guess for the parameters, the other two parameters a and d #will be estimated based on data. model<-"5pl" pars<-c(7.2,0.5, 0.015) #5pl inits names(pars)<-c("xmid", "scal", "g") #do fitting. model will be written into data set. batches<-runFit(pars=pars, batches=batches, refBatch.ID=1, model=model ) #now call to do predications based on the model. batches<-predictAll(batches); #now saving the data. saveDB(batches, file.path(tempdir(),"elisa_tool1.rds")); loadDB(file.path(tempdir(),"elisa_tool1.rds"));
#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #make a guess for the parameters, the other two parameters a and d #will be estimated based on data. model<-"5pl" pars<-c(7.2,0.5, 0.015) #5pl inits names(pars)<-c("xmid", "scal", "g") #do fitting. model will be written into data set. batches<-runFit(pars=pars, batches=batches, refBatch.ID=1, model=model ) #now call to do predications based on the model. batches<-predictAll(batches); #now saving the data. saveDB(batches, file.path(tempdir(),"elisa_tool1.rds")); loadDB(file.path(tempdir(),"elisa_tool1.rds"));
Plot the batch data together for visualization.
plotAlignData(batches, graph.file = NULL)
plotAlignData(batches, graph.file = NULL)
batches |
list of batch data objects either raw or analyzed data. |
graph.file |
characters as the output graph file name. If specified, a SVG (*.svg) graph will be saved to the disk. Otherwise, the graph will be send to the stdout. |
If the data has been analysed, a fitted line will be drawn too. If there are more than one batches, each batch will be plotted with different color and different synmbols. Different batches will also be shifted/adjusted based on their "S" factor, and one single fitted line (based on the "reference" batch) will be plotted.
characters which specify the graph file name, if graph.file is specified. NULL otherwise.
#load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") #load the data batches<-loadData(file.path(dir_file,"design.txt")) #plot the raw batch data together plotAlignData(batches);
#load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") #load the data batches<-loadData(file.path(dir_file,"design.txt")) #plot the raw batch data together plotAlignData(batches);
Plot the individual batch data for visualization.
plotBatchData(batch, graph.file = NULL)
plotBatchData(batch, graph.file = NULL)
batch |
batch data objects with either raw or analyzed data. |
graph.file |
characters as the output graph file name. If specified, a SVG (*.svg) graph will be saved to the disk. Otherwise, the graph will be send to the stdout. |
If the data has been analysed, a fitted line will be drawn too.
characters which is the graph file name, if graph.file is specified. NULL otherwise.
#load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") #load the data batches<-loadData(file.path(dir_file,"design.txt")) #plot the raw batch 1 data plotBatchData(batches[[1]]);
#load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") #load the data batches<-loadData(file.path(dir_file,"design.txt")) #plot the raw batch 1 data plotBatchData(batches[[1]]);
Based on the 5pl or 4pl regression, predict the concentration of of unknown samples. Assume the regression has been accomplished.
predictAll(batches)
predictAll(batches)
batches |
list of elisa_batch objects containing both the raw data and the fitted regression model. |
The input data structure contains both the data (ODs) and the fitted regression model. The estimation of unknonw concentration based on the ODs and the standard curve of each plate. The batch effects are corrected/normalized and the corrected concentrations also are also written into the batch data structure, if there are more than one batches in the data.
The same list of elisa_batch with estimated sample concentrations based on ODs and the fitted regression model. The estimated concentrations normalized/corrected between different batches are also calculated and recorded.
Feng 2018 doi:10.1101/483800
elisa_batch
elisa_run
elisa_plate
Generate the initial values for fitting shifts with a model of the 5-parameter logistic function.
prepareInitsLM(batches, ref.batch = 1)
prepareInitsLM(batches, ref.batch = 1)
batches |
list of elisa_batch data |
ref.batch |
numeric the index of the reference batch. It is 1 by default. |
This is a more complicated way to prepare the initials for shifting.
a data list contain the following elements,
inits, the initial values for the standard curves of all the plates
ref.ibatch, the index of the reference batch
This one is specified by the input ref.batch.
ref.irun,the index of the reference run
ref.index,the index of the reference line in the order
of the inits vector
Prepare the input data to feed in the fitting.
prepareRegInput(batches)
prepareRegInput(batches)
batches |
list of the ELISA data arranged in
batches. Each element of list contains a batch (list)
data, and each batch contains one or many the elisa_run
objects |
list of data that will feed in to do regression.
elisa_plate
elisa_batch
elisa_run
Going through the list of batches to get the OD range (min and max)
rangeOD(batches)
rangeOD(batches)
batches |
list of batches data |
Parse the annotations for one single ELISA plate from a section of a file and output the annotations for standard and unknown separately.
read.annotation(annotation, std.conc)
read.annotation(annotation, std.conc)
annotation |
characters to specify the path and name of the annotation file |
std.conc |
data.frame containing standard concentration data. Only first two columns are used with first one to be the standard IDs and second the concentrations. |
The annotation file may contain annotations for more than
one plate. Each plate is marked by "Plate: plate 1..." and
"~End". This function is fed in with the content for each section
and we do actually parsing in here. Store the annotations into
data frame. It also parse the standard concentration and
include this information in the data frame.
For each section,we expect
the following format
1 | 2 | 3 | 4 | ... | |
C | s1 | s1 | sample1 | sample1 | ... |
D | s2 | s2 | sample2 | sample | ... |
... | ... | ... | ... | ... | ... |
In addition, the row name and column names indicate the the plate row and column indices. As input, the stardard and unknown are returned separately in two tables.
a list of data.frames holding the annotations for the plate.
#get example annotation file path from the system folder fileName<-system.file("extdata", "annote_single.txt", package="ELISAtools") #prepare the standard concentration file. std.conc<-data.frame(id=c("s1","s2","s3","s4","s5","s6"), conc=c(1:6)) #read the data as a data frame. ann<-read.table(fileName, header=TRUE, sep="\t", stringsAsFactors=FALSE) #call to do the reading.
#get example annotation file path from the system folder fileName<-system.file("extdata", "annote_single.txt", package="ELISAtools") #prepare the standard concentration file. std.conc<-data.frame(id=c("s1","s2","s3","s4","s5","s6"), conc=c(1:6)) #read the data as a data frame. ann<-read.table(fileName, header=TRUE, sep="\t", stringsAsFactors=FALSE) #call to do the reading.
Parse annotations for multiple ELISA plates from files, one annotation file and one standard concentration file, and output the annotations for standard and unknown separately.
read.annotations( annotation, std.conc, dir.annotation, dir.stdConc, num.plate = 1 )
read.annotations( annotation, std.conc, dir.annotation, dir.stdConc, num.plate = 1 )
annotation |
characters to specify the path and name of the annotation file |
std.conc |
characters to specify the standard concentration file. |
dir.annotation |
characters specifying the file to the annotatoin file. |
dir.stdConc |
characters specifying the path to the annotatoin file. |
num.plate |
numeric indicating the number of plates in the annotation files. |
The annotation file may contain annotations for more than
one plate. Each plate is marked by "Plate: plate 1..." and
"~End". This function parses each section in both annotation
file and standard concentration file. Then passes the section
on to do the parsing.
For each section,we expect
the following format
1 | 2 | 3 | 4 | ... | |
C | s1 | s1 | sample1 | sample1 | ... |
D | s2 | s2 | sample2 | sample | ... |
... | ... | ... | ... | ... | ... |
a list of annotations for elisa plates.
#get example annotation file path from the system folder ann<-system.file("extdata", "annote.txt", package="ELISAtools") std.conc<-system.file("extdata", "stdConc.txt", package="ELISAtools") #read them in and there are 2 plates. read.annotations(annotation=ann, std.conc=std.conc, num.plate=2)
#get example annotation file path from the system folder ann<-system.file("extdata", "annote.txt", package="ELISAtools") std.conc<-system.file("extdata", "stdConc.txt", package="ELISAtools") #read them in and there are 2 plates. read.annotations(annotation=ann, std.conc=std.conc, num.plate=2)
Read the individual ELISA plate to parse the ODs.
read.plate(ODs, annotation, batchID, expID)
read.plate(ODs, annotation, batchID, expID)
ODs |
characters containing data of ODs for one plate |
annotation |
list of data containing annotations of the plate |
batchID |
characters specifying the batchID read from the design file |
expID |
characters specifying the expID or plateID read from the design file |
The input is a text file imported from the sdf file. We only read the first section with both the OD and blank file. The OD data are read in according to the annotation file.
an object of elisa_plate holding data and annotations for a single plate.
Read the ELISA OD file to parse the ODs.
read.plates( fileName, annotations, num.plate = 1, batchID, expID, date = NA_character_ )
read.plates( fileName, annotations, num.plate = 1, batchID, expID, date = NA_character_ )
fileName |
characters containing file name of OD data |
annotations |
list of data containing annotations of the plates |
num.plate |
numeric number of OD plates in the OD file. |
batchID |
characters specify the batchID read from the design file |
expID |
characters specify the expID or plateID read from the design file |
date |
characters the date running the ELISA exps. |
The input is a text file imported from the sdf file. The file may contain multiple plates of OD. We will parse each file section and then read them according to the annotation to load the data. We assume for each file the data are for the same batch and experiment. If otherwise, please split the file into different ones.
an object of elisa_run holding data and annotations for one or multiple plates.
#get example annotation file path from the system folder ann<-system.file("extdata", "annote.txt", package="ELISAtools") std.conc<-system.file("extdata", "stdConc.txt", package="ELISAtools") #read them in and there are 2 plates. annotations<-read.annotations(annotation=ann, std.conc=std.conc, num.plate=2) #now start reading the OD plate file fileName <-system.file("extdata", "Assay_3_and_4.txt", package="ELISAtools") plates<-read.plates(fileName, annotations=annotations, num.plate=2, batchID="b1", expID="e1")
#get example annotation file path from the system folder ann<-system.file("extdata", "annote.txt", package="ELISAtools") std.conc<-system.file("extdata", "stdConc.txt", package="ELISAtools") #read them in and there are 2 plates. annotations<-read.annotations(annotation=ann, std.conc=std.conc, num.plate=2) #now start reading the OD plate file fileName <-system.file("extdata", "Assay_3_and_4.txt", package="ELISAtools") plates<-read.plates(fileName, annotations=annotations, num.plate=2, batchID="b1", expID="e1")
Writting the ELISA analysis results by batch in HTML format.
reportHtml(batches, file.name = "report", file.dir = ".", desc = "")
reportHtml(batches, file.name = "report", file.dir = ".", desc = "")
batches |
list of elisa batch data objects. The data can be raw or after analyzed and batch-corrected. |
file.name |
character string denoting the report file. The file will be written in HTML format. |
file.dir |
character string denoting the directory to save the report. |
desc |
character string describing the project and experiment. Will be written into the report. |
the function returns NULL. But it will save the html report to the disk. Therefore, it is IMPORTANT to specify a directory you have write permission to run this function.
elisa_batch
elisa_run
elisa_plate
#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) ## #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #----IMPORTANT----- #please make sure you have the write permission to save the html report reportHtml(batches,file.dir=tempdir());
#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) ## #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #----IMPORTANT----- #please make sure you have the write permission to save the html report reportHtml(batches,file.dir=tempdir());
Fit 5- or 4-parameter logistic function to estimate the parameters by pooling the standard curves from all batches
runFit(pars, a, d, batches, refBatch.ID = 1, model = c("5pl", "4pl"))
runFit(pars, a, d, batches, refBatch.ID = 1, model = c("5pl", "4pl"))
pars |
numeric vector initial values to estimate the paramters |
a |
numeric the initial value for a (the lower limit of the function) |
d |
numeric the initial value for d (the upper limit of the function) |
batches |
list of the batch data used to fit the model |
refBatch.ID |
numeric or string indicating the reference batch, by default is set to be the first one. |
model |
characters to indicate either 5-parameter logistic function (5pl, default one) or 4-parameter logistic (4pl) to be used in the fitting. |
In this fitting, we first "guess" the initial values and then estimate
the parameters based on 5- or 4-parameter function by shifting every single standard
curves towards the reference line.
We are reasoning that the intra-batch and
inter-batch factors affect the curve similarly by shifting the curve
left or right without changing its shapes. So we combine them together to
to fit one single reference curve. To model the inter-batch effects, we
take the average of the shifts of curves withine each batch, and use it
to correct/normalize between different batches.
To summerize, each individual curve has its own shifts, which contains
the information about intra- and inter-batch effects. each batch has
one batch level shifts (S Factor), which is an average of shifts of
curves within its batch and contains information about inter-batch effects.
When we try to normalize between batches, we will apply the batch level shift to
all the curves within the same batch.
the batch data with the fitted model
Feng, et al 2018 doi:10.1101/483800
#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #make a guess for the parameters, the other two parameters a and d #will be estimated based on data. model<-"5pl" pars<-c(7.2,0.5, 0.015) #5pl inits names(pars)<-c("xmid", "scal", "g") #do fitting. model will be written into data set. batches<-runFit(pars=pars, batches=batches, refBatch.ID=1, model=model )
#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #make a guess for the parameters, the other two parameters a and d #will be estimated based on data. model<-"5pl" pars<-c(7.2,0.5, 0.015) #5pl inits names(pars)<-c("xmid", "scal", "g") #do fitting. model will be written into data set. batches<-runFit(pars=pars, batches=batches, refBatch.ID=1, model=model )
Save the data analysis results to disk in text format.
saveDataText(batches, file.name)
saveDataText(batches, file.name)
batches |
list of elisa batch data to be serialized. |
file.name |
character specifying name of the output file. |
The results are written to disk in the text format (tab-delimited) and is easy to be used for other analysis.
#'#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #make a guess for the parameters, the other two parameters a and d #will be estimated based on data. model<-"5pl" pars<-c(7.2,0.5, 0.015) #5pl inits names(pars)<-c("xmid", "scal", "g") #do fitting. model will be written into data set. batches<-runFit(pars=pars, batches=batches, refBatch.ID=1, model=model ) #now call to do predications based on the model. batches<-predictAll(batches); #now saving the data in text. saveDataText(batches, file.path(tempdir(),"elisa_data.txt"));
#'#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #make a guess for the parameters, the other two parameters a and d #will be estimated based on data. model<-"5pl" pars<-c(7.2,0.5, 0.015) #5pl inits names(pars)<-c("xmid", "scal", "g") #do fitting. model will be written into data set. batches<-runFit(pars=pars, batches=batches, refBatch.ID=1, model=model ) #now call to do predications based on the model. batches<-predictAll(batches); #now saving the data in text. saveDataText(batches, file.path(tempdir(),"elisa_data.txt"));
Serialize elisa_batch data to disk.
saveDB(batches, db)
saveDB(batches, db)
batches |
list of elisa batch data to be serialized. |
db |
character the file name specifying name of the db. |
We serialize elisa_batch data by wrapping the saveRds() function call. The serialized elisa_batch data are assumed to have been correctly analyzed. We will print a summary for what has been saved.
elisa_batch-class
loadData
saveDB
#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #make a guess for the parameters, the other two parameters a and d #will be estimated based on data. model<-"5pl" pars<-c(7.2,0.5, 0.015) #5pl inits names(pars)<-c("xmid", "scal", "g") #do fitting. model will be written into data set. batches<-runFit(pars=pars, batches=batches, refBatch.ID=1, model=model ) #now call to do predications based on the model. batches<-predictAll(batches); #now saving the data. saveDB(batches, file.path(tempdir(),"elisa_tool1.rds"));
#R code to run 5-parameter logistic regression on ELISA data #load the library library(ELISAtools) #get file folder dir_file<-system.file("extdata", package="ELISAtools") batches<-loadData(file.path(dir_file,"design.txt")) #make a guess for the parameters, the other two parameters a and d #will be estimated based on data. model<-"5pl" pars<-c(7.2,0.5, 0.015) #5pl inits names(pars)<-c("xmid", "scal", "g") #do fitting. model will be written into data set. batches<-runFit(pars=pars, batches=batches, refBatch.ID=1, model=model ) #now call to do predications based on the model. batches<-predictAll(batches); #now saving the data. saveDB(batches, file.path(tempdir(),"elisa_tool1.rds"));