Title: | Flexible Format Standard Curve Fitting and Data Processing |
---|---|
Description: | More about what it does (maybe more than one line) Use four spaces when indenting paragraphs within the Description. |
Authors: | Who wrote it |
Maintainer: | The package maintainer <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.99.0 |
Built: | 2024-11-08 04:42:36 UTC |
Source: | https://github.com/eppicenter/flexfit |
Numerically finds roots for 4th derivative of the model function that are used to indicate "flat" portions of the curve.
calcBounds(FUNmod, par, xrange, seql = 200)
calcBounds(FUNmod, par, xrange, seql = 200)
FUNmod |
model function |
par |
values of function parameters |
xrange |
range of function domain to be searched for roots |
seql |
length of the search grid |
to be added
A named list with upper and lower bounds.
Calculates roots for 4th derivative of logistic function that are used to indicate "flat" portions of the curve.
calcBoundsSig(par, xrange)
calcBoundsSig(par, xrange)
par |
values of function parameters |
xrange |
range of function domain to be searched for roots |
to be added
A named list with upper and lower bounds.
Separates specified serial dilutions for fitting, background, and samples
extractStd(MFI, stdstr, bgstr, stddil, smpdil, antigen, fname, pdate)
extractStd(MFI, stdstr, bgstr, stddil, smpdil, antigen, fname, pdate)
MFI |
data frame with variable "Sample" that contains information about standard concentrations in "1/dilution" format (e.g. "1/200"). |
stdstr |
character string indicating standards in the file's "Sample"
column. Not case sensitive. If |
bgstr |
character string indicating background in the file's "Sample" column. Not case sensitive. |
stddil |
standard dilutions to use for standard curve fitting. If
|
smpdil |
single value for sample dilutions (if dilutions are not
provided in |
antigen |
character string. |
fname |
name of the file that contains raw data. |
pdate |
date of the plate processing. |
details
A list with standards for fitting, background values, sample values, indices for samples.
Fit a specified function to standards (serial dilutions). Optionally an interactive procedure that allows to remove outliers, evaluate resulting fits, perform revisions, and record a message regarding the fit.
fitStd( std, xvar, yvar, model = "sigmoid", Alow = NULL, asym = TRUE, interactive = TRUE, monot.prompt = FALSE, rm.before = FALSE, rm.after = interactive, maxrm = 2, set.bounds = FALSE, overwrite.bounds = FALSE, bg = NULL, vsmp = NULL, optmethod = "Nelder-Mead", maxit = 5000, extrapolate.low = FALSE, extrapolate.up = FALSE, info = "", ifix = NULL, tcklab = NULL, stdcol = c("firebrick3", "darkslategray"), rugcol = c("cadetblue", "purple", "firebrick2"), ... )
fitStd( std, xvar, yvar, model = "sigmoid", Alow = NULL, asym = TRUE, interactive = TRUE, monot.prompt = FALSE, rm.before = FALSE, rm.after = interactive, maxrm = 2, set.bounds = FALSE, overwrite.bounds = FALSE, bg = NULL, vsmp = NULL, optmethod = "Nelder-Mead", maxit = 5000, extrapolate.low = FALSE, extrapolate.up = FALSE, info = "", ifix = NULL, tcklab = NULL, stdcol = c("firebrick3", "darkslategray"), rugcol = c("cadetblue", "purple", "firebrick2"), ... )
std |
matrix or data frame with standards for fitting. |
xvar , yvar
|
character strings for the variables used to fit a standard
curve. If |
model |
the model to be fit. |
Alow |
lower asymptote for the sigmoid model. If |
asym |
if |
interactive |
logical value. If |
monot.prompt |
if |
rm.before |
logical value indicating if potential outliers should be
removed before the model is fitted. Ignored if |
rm.after |
logical value indicating if potential outliers should be
removed after the model is fitted. Ignored if |
maxrm |
maximum number of outliers to remove. |
set.bounds |
if |
overwrite.bounds |
logical value indicating the option to overwrite
automatically set bounds. Ignored if |
bg |
values for background spots. |
vsmp |
sample values. |
optmethod |
method to be used in optimization. |
maxit |
maximum number of iterations in optimization. |
extrapolate.low |
if |
extrapolate.up |
if |
info |
information about a particular run for warning messages. |
ifix |
sorted integer vector of length 3 with indices of standards to be used for getting starting values for optimization. |
tcklab |
tick labels for x-axis. |
stdcol |
vector of two colors for the standard points and the fit on the plot. |
rugcol |
vector of three colors for the rugplot, which indicates sample values (inside the bounds, between the bounds and extrema, and beyond extrema). |
... |
further graphical parameters. |
to be added
A list containing parameters of the fit and bounds of the fit (named vectors), as well as indices of removed points (if any) and flags r.
Calculate sample concentration based on the fit of standard dilutions.
normalizeSmp( smp, smpvar, resvar, dilvar, FUNinv, par, bounds, fitflag, fitlog, trim.flat = TRUE, extrapolate.low = FALSE, extrapolate.up = FALSE )
normalizeSmp( smp, smpvar, resvar, dilvar, FUNinv, par, bounds, fitflag, fitlog, trim.flat = TRUE, extrapolate.low = FALSE, extrapolate.up = FALSE )
smp |
data frame containing samples |
smpvar |
character string indicating sample variable. |
dilvar , resvar
|
character strings for dilution variable and results. |
FUNinv |
inverse function to infer sample concentration |
par |
values of model function parameters |
bounds |
named vector with values for extrema and bounds indicating "flat" regions of the curve |
fitflag |
flag for the fit as returned by |
fitlog |
character string indicating if standard values should be
log-transformed for fitting. If the string contains _x_, |
trim.flat |
logical value determining how the values of |
extrapolate.low |
if |
extrapolate.up |
if |
coming up
A data frame.
Produces a plot that includes points for standards, proposed fit, removed outliers, bounds for "flat" portions of the curve, and values for samples and for the background.
plotFit( std, xvar, yvar, fitpar = NULL, FUNmod = NULL, FUNinv = NULL, iout = NULL, bg = NULL, vsmp = NULL, smpflag = NULL, trimval = NULL, trimtype = NULL, extrapolate.low = FALSE, extrapolate.up = FALSE, ylim = NULL, tcklab = NULL, stdcol = c("firebrick3", "darkslategray"), rugcol = c("cadetblue", "purple", "firebrick2"), ... )
plotFit( std, xvar, yvar, fitpar = NULL, FUNmod = NULL, FUNinv = NULL, iout = NULL, bg = NULL, vsmp = NULL, smpflag = NULL, trimval = NULL, trimtype = NULL, extrapolate.low = FALSE, extrapolate.up = FALSE, ylim = NULL, tcklab = NULL, stdcol = c("firebrick3", "darkslategray"), rugcol = c("cadetblue", "purple", "firebrick2"), ... )
std |
matrix or data frame with standards for fitting. |
xvar , yvar
|
character strings for the variables used to fit a standard
curve. If |
fitpar |
values of function parameters. |
FUNmod |
model function. |
FUNinv |
model inverse function. |
iout |
indices of removed standard points. |
bg |
background values. |
vsmp |
sample values. |
smpflag |
character vector, flags for each sample. |
trimval |
for final results, the values at which the samples are trimmed. |
trimtype |
integer vector of length two indicating if the values are trimmed at the extremum (lower and upper). |
extrapolate.low |
if |
extrapolate.up |
if |
ylim |
limits of the y-axis. |
tcklab |
tick labels for x-axis. |
stdcol |
vector of two colors for the standard points and the fit on the plot. |
rugcol |
vector of three colors for the rugplot, which indicates sample values (inside the bounds, between the bounds and extrema, and beyond extrema). |
... |
further graphical parameters. |
to be added
Read in raw luminex files, extract standards and background (if provided), and format samples for processing.
prepLum( antigen, fname, fdir = NULL, dtype = "Median", stdstr = "std|stand", bgstr = "blank|background", stddil = NULL, smpdil = 1000, nwells = NULL, nsep = 2, ncolmax = 105, dformat = "%m/%d/%Y" )
prepLum( antigen, fname, fdir = NULL, dtype = "Median", stdstr = "std|stand", bgstr = "blank|background", stddil = NULL, smpdil = 1000, nwells = NULL, nsep = 2, ncolmax = 105, dformat = "%m/%d/%Y" )
antigen |
character string. |
fname |
name of the file that contains raw data. |
fdir |
directory where the file is located (alternatively, full path can
be included in |
dtype |
character string for data type in the file. |
stdstr |
character string indicating standards in the file's "Sample"
column. Not case sensitive. If |
bgstr |
character string indicating background in the file's "Sample" column. Not case sensitive. |
stddil |
a vector of standard dilutions. If |
smpdil |
single value for sample dilutions (if dilutions are not
provided in |
nwells |
number of wells. If |
nsep |
number of lines separating different data types in the file. |
ncolmax |
maximum number of columns in the file. |
dformat |
date format in the file. |
to be added
A list with standards for fitting, background values, sample values, indices for samples.
Process data for a single antigen: fit a standard curve, establish bounds, normalize samples, and save a plot showing the fit and the samples.
processSmp( smp, std, bg = NULL, smpdil = 1, fitlog = "xy", ismp = 1:nrow(smp), plotdir = "./", pname = NULL, ptitle = "fit and samples", xvar = NULL, yvar = NULL, smpvar = NULL, addvar = NULL, dilvar = NULL, resvar = "concentration", model = "sigmoid", Alow = NULL, asym = TRUE, trim.flat = TRUE, interactive = TRUE, monot.prompt = FALSE, rm.before = FALSE, rm.after = interactive, maxrm = 2, set.bounds = interactive, overwrite.bounds = FALSE, ifix = NULL, extrapolate.low = FALSE, extrapolate.up = FALSE, optmethod = "Nelder-Mead", maxit = 5000, stdcol = c("firebrick3", "darkslategray"), rugcol = c("cadetblue", "purple", "firebrick2"), width = 7, height = 6, ... )
processSmp( smp, std, bg = NULL, smpdil = 1, fitlog = "xy", ismp = 1:nrow(smp), plotdir = "./", pname = NULL, ptitle = "fit and samples", xvar = NULL, yvar = NULL, smpvar = NULL, addvar = NULL, dilvar = NULL, resvar = "concentration", model = "sigmoid", Alow = NULL, asym = TRUE, trim.flat = TRUE, interactive = TRUE, monot.prompt = FALSE, rm.before = FALSE, rm.after = interactive, maxrm = 2, set.bounds = interactive, overwrite.bounds = FALSE, ifix = NULL, extrapolate.low = FALSE, extrapolate.up = FALSE, optmethod = "Nelder-Mead", maxit = 5000, stdcol = c("firebrick3", "darkslategray"), rugcol = c("cadetblue", "purple", "firebrick2"), width = 7, height = 6, ... )
smp |
data frame with sample ID, sample values and other optional variables (e.g. dilution). |
std |
matrix or data frame with standards for fitting. |
bg |
values for background spots. |
smpdil |
single value for sample dilutions (if dilutions are not
provided in |
fitlog |
character string indicating if standard values should be
log-transformed for fitting. If the string contains _x_, |
ismp |
indices for samples to be plotted (e.g. to exclude standards that
are included in |
plotdir |
directory for the plots to be saved. |
pname |
character string for fit plot. If |
ptitle |
character string for plot title. |
xvar , yvar
|
character strings for the variables used to fit a standard
curve. If |
smpvar |
character string indicating sample variable. |
addvar |
named vector for additional variables (e.g. date or plate),
where element names will be used as variable names in |
dilvar , resvar
|
character strings for dilution variable and results. |
model |
the model to be fit. |
Alow |
lower asymptote for the sigmoid model. If |
asym |
if |
trim.flat |
logical value determining how the values of |
interactive |
logical value. If |
monot.prompt |
if |
rm.before |
logical value indicating if potential outliers should be
removed before the model is fitted. Ignored if |
rm.after |
logical value indicating if potential outliers should be
removed after the model is fitted. Ignored if |
maxrm |
maximum number of outliers to remove. |
set.bounds |
if |
overwrite.bounds |
logical value indicating the option to overwrite
automatically set bounds. Ignored if |
ifix |
sorted integer vector of length 3 with indices of standards to be used for getting starting values for optimization. |
extrapolate.low |
if |
extrapolate.up |
if |
optmethod |
method to be used in optimization. |
maxit |
maximum number of iterations in optimization. |
stdcol |
vector of two colors for the standard points and the fit on the plot. |
rugcol |
vector of three colors for the rugplot, which indicates sample values (inside the bounds, between the bounds and extrema, and beyond extrema). |
width , height
|
optional parameters for the final saved plot. |
... |
further graphical parameters. |
Note that if fitlog
contains _x_ and thus xvar
in
standards is log-transform before fitting, the results are still returned
on a regular scale (values of inverse function are exponentiated and then
multiplied by dilution).
A list of length three. The first element is a data frame that contains the results; the second is a character string with a flag containing information about removed points, failure to fit the model, manually set bounds, and/or an optional custom note provided by the user during an interactive model-fitting procedure. The last element is the number of sample values for which the results are trimmed.
Extract specified data type from the file.
read_data(fname, dtype = "Median", nwells = NULL, nsep = 2, ncolmax = 105)
read_data(fname, dtype = "Median", nwells = NULL, nsep = 2, ncolmax = 105)
fname |
name of the file that contains raw data. |
dtype |
character string for data type in the file. |
nwells |
number of wells. If |
nsep |
number of lines separating different data types in the file. |
ncolmax |
maximum number of columns in the file. |
to be added
A data frame.