The Model class is a wrapper around the nplr
model. It allows to predict the RAU (Relative Antibody Unit) values
directly from the MFI values of a given sample.
The nplr
model is fitted using the formula:
$$y = B + \frac{T - B}{(1 + 10^{b \cdot (x_{mid} - x)})^s},$$
where:
\(y\) is the predicted value, MFI in our case,
\(x\) is the independent variable, dilution in our case,
\(B\) is the bottom plateau - the right horizontal asymptote,
\(T\) is the top plateau - the left horizontal asymptote,
\(b\) is the slope of the curve at the inflection point,
\(x_{mid}\) is the x-coordinate at the inflection point,
\(s\) is the asymmetric coefficient.
This equation is referred to as the Richards' equation. More information about the model can be found in the nplr
package documentation.
After the model is fitted to the data, the RAU values can be predicted using the predict
method.
The RAU value is simply a predicted dilution value (using the standard curve) for a given MFI
multiplied by 1,000 000 to have a more readable value.
For more information about the differences between dilution, RAU and MFI values, please see the
"Normalisation" section in the "Basic PvSTATEM functionalities" vignette.
Public fields
analyte
(
character(1)
)
Name of the analyte for which the model was fitteddilutions
(
numeric()
)
Dilutions used to fit the modelmfi
(
numeric()
)
MFI values used to fit the modelmfi_min
(
numeric(1)
)
Minimum MFI used for scaling MFI values to the range [0, 1]mfi_max
(
numeric(1)
)
Maximum MFI used for scaling MFI values to the range [0, 1]model
(
nplr
)
Instance of thenplr
model fitted to the datalog_dilution
(
logical()
)
Indicator should the dilutions be transformed using thelog10
functionlog_mfi
(
logical()
)
Indicator should the MFI values be transformed using thelog10
functionscale_mfi
(
logical()
)
Indicator should the MFI values be scaled to the range [0, 1]
Active bindings
top_asymptote
(
numeric(1)
)
The top asymptote of the logistic curvebottom_asymptote
(
numeric(1)
)
The bottom asymptote of the logistic curve
Methods
Method new()
Create a new instance of Model R6 class
Usage
Model$new(
analyte,
dilutions,
mfi,
npars = 5,
verbose = TRUE,
log_dilution = TRUE,
log_mfi = TRUE,
scale_mfi = TRUE,
mfi_min = NULL,
mfi_max = NULL
)
Arguments
analyte
(
character(1)
)
Name of the analyte for which the model was fitted.dilutions
(
numeric()
)
Dilutions used to fit the modelmfi
MFI (
numeric()
)
values used to fit the modelnpars
(
numeric(1)
)
Number of parameters to use in the modelverbose
(
logical()
)
IfTRUE
prints messages,TRUE
by defaultlog_dilution
(
logical()
)
IfTRUE
the dilutions are transformed using thelog10
function,TRUE
by defaultlog_mfi
(
logical()
)
IfTRUE
the MFI values are transformed using thelog10
function,TRUE
by defaultscale_mfi
(
logical()
)
IfTRUE
the MFI values are scaled to the range [0, 1],TRUE
by defaultmfi_min
(
numeric(1)
)
Enables to set the minimum MFI value used for scaling MFI values to the range [0, 1]. Use values before any transformations (e.g., before thelog10
transformation)mfi_max
(
numeric(1)
)
Enables to set the maximum MFI value used for scaling MFI values to the range [0, 1]. Use values before any transformations (e.g., before thelog10
transformation)
Method predict()
Predict RAU values from the MFI values
Arguments
mfi
(
numeric()
)
MFI values for which we want to predict the RAU valuesover_max_extrapolation
(
numeric(1)
)
How much we can extrapolate the values above the maximum RAU value seen in standard curve samples \(\text{RAU}_{max}\). Defaults to 0. If the value of the predicted RAU is above \(RAU_{max} + \text{over\_max\_extrapolation}\), the value is censored to the value of that sum.eps
(
numeric(1)
)
A small value used to avoid numerical issues close to the asymptotes
Returns
(data.frame()
)
Dataframe with the predicted RAU values for given MFI values
The columns are named as follows:
RAU
- the Relative Antibody Units (RAU) valueMFI
- the predicted MFI value
Method get_plot_data()
Data that can be used to plot the standard curve.
Returns
(data.frame()
)
Prediction dataframe for scaled MFI (or logMFI) values in the range [0, 1].
Columns are named as in the predict
method
Method print()
Function prints the basic information about the model such as the number of parameters or samples used
Examples
plate_file <- system.file("extdata", "CovidOISExPONTENT.csv", package = "PvSTATEM")
layout_file <- system.file("extdata", "CovidOISExPONTENT_layout.csv", package = "PvSTATEM")
plate <- read_luminex_data(plate_file, layout_filepath = layout_file)
#> Reading Luminex data from: /home/runner/work/_temp/Library/PvSTATEM/extdata/CovidOISExPONTENT.csv
#> using format xPONENT
#>
#> New plate object has been created with name: CovidOISExPONTENT!
#>
model <- create_standard_curve_model_analyte(plate, "S2", log_mfi = TRUE)
print(model)
#> Instance of the Model class fitted for analyte ' S2 ':
#> - fitted with 5 parameters
#> - using 11 samples
#> - using log residuals (mfi): TRUE
#> - using log dilution: TRUE
#> - top asymptote: 6587.765
#> - bottom asymptote: 24.6534
#> - goodness of fit: 0.996416
#> - weighted goodness of fit: 0.9998704