Title: | N-Parameter Logistic Regression |
---|---|
Description: | Performing drug response analyses and IC50 estimations using n-Parameter logistic regression. Can also be applied to proliferation analyses. |
Authors: | Frederic Commo [aut],
Brian M. Bot [aut],
Tymoteusz Kwiecinski [aut, cre]
|
Maintainer: | Tymoteusz Kwiecinski <[email protected]> |
License: | GPL |
Version: | 0.1-8 |
Built: | 2025-02-20 05:30:50 UTC |
Source: | https://github.com/mini-pw/nplr |
Convert a vector of values to proportions, given a minimun and a maximun value (optional).
See Details
and Examples
.
convertToProp(y, T0 = NULL, Ctrl = NULL)
convertToProp(y, T0 = NULL, Ctrl = NULL)
y |
: a vector of values (responses to x). |
T0 |
: the minimal value to consider. If NULL (default), |
Ctrl |
: the maximal value to consider. If NULL (default), |
In typical cell viability experiments, responses to drug concentrations (inhibition rate) may be estimated with respect to a time zero (T0)
and an untreated condition values (Ctrl)
, as described in [1]:
If none of the T0 and Ctrl values are provided, min(y, na.rm=TRUE)
and max(y, na.rm=TRUE)
will be used, respectively. See Warning
.
a vector of values.
Note that, for drug response analyses, rescaling the responses between 0 to 1 using to the min and max of y, would lead to estimate a EC50 (the half effect between the maximum and the minimum of the observed effects), rather than a IC50.
The data used as examples come from the NCI-60 Growth Inhibition Data: https://wiki.nci.nih.gov/display/NCIDTPdata/NCI-60+Growth+Inhibition+Data, except for multicell.tsv which are simulated data.
Frederic Commo, Brian M. Bot
1 - https://dtp.nci.nih.gov/branches/btb/ivclsp.html
## Using the MDA-N data op <- par(no.readonly=TRUE) # save default parameters require(nplr) path <- system.file("extdata", "mdan.txt", package = "nplr") mdan <- read.delim(path) # fit a model on the original responses (proportions of control): conc <- mdan$CONC y0 <- mdan$GIPROP model0 <- nplr(conc, y0) # Adjust the data between 0 to 1, then fit a new model: y1 <- convertToProp(y0) model1 <- nplr(conc, y1) par(mfrow=c(1, 2)) plot(model0, ylim = range(0, 1), main = "Original y values") plot(model1, ylim = range(0, 1), main = "Rescaled y values") par(op)
## Using the MDA-N data op <- par(no.readonly=TRUE) # save default parameters require(nplr) path <- system.file("extdata", "mdan.txt", package = "nplr") mdan <- read.delim(path) # fit a model on the original responses (proportions of control): conc <- mdan$CONC y0 <- mdan$GIPROP model0 <- nplr(conc, y0) # Adjust the data between 0 to 1, then fit a new model: y1 <- convertToProp(y0) model1 <- nplr(conc, y1) par(mfrow=c(1, 2)) plot(model0, ylim = range(0, 1), main = "Original y values") plot(model1, ylim = range(0, 1), main = "Rescaled y values") par(op)
This function takes as its first argument a model returned by nplr()
. By inverting the logistic model, it estimates the x values corresponding to one (or a vector of) y target(s) provided. The standard error of the model, defined as the mean squared error on the fitted values, is used to estimate a confidence interval on the predicted x values, according to the specified conf.level
. See Details
.
## S4 method for signature 'nplr' getEstimates(object, targets = seq(.9, .1, by = -.1), B = 1e4, conf.level = .95)
## S4 method for signature 'nplr' getEstimates(object, targets = seq(.9, .1, by = -.1), B = 1e4, conf.level = .95)
object |
an object of class |
targets |
one, or a vector of, numerical value(s) for which the corresponding x has to be estimated. Default are target values from .9 to .1. |
B |
the length of the y distribution from which the x confidence interval is estimated. |
conf.level |
the estimated x confidence interval, bounded by (1-conf.level)/2 and 1 - (1-conf.level)/2 (by default .95, which gives x.025 and x.975). |
In n-parameter logistic regressions, none of the parameters follow any particular distribution from which confidence intervals can be estimated. To overcome this issue, the standard error is used to generate a normal distribution of the target(s) passed to the function. The quantiles of that distribution are used in order to provide estimated bounds for the corresponding x value, with respect to conf.level
.
See also Warning
.
A data set containing:
the target value.
the lower bound of the estimated 95% confidence interval (default). If another value is passed to conf.level, x will be labelled as x.(1-conf.level)/2.
the estimated value.
the upper bound of the estimated 95% confidence interval (default). If another value is passed to conf.level, x will be labelled as x.1-(1-conf.level)/2.
Notice that, if any or
, in other words outside the 2 asymptotes, the maximal (or minimal) possible value the model can estimate is returned.
The data used in the examples are samples from the NCI-60 Growth Inhibition Data: https://wiki.nci.nih.gov/display/NCIDTPdata/NCI-60+Growth+Inhibition+Data, except for multicell.tsv which are simulated data.
Frederic Commo, Brian M. Bot
nplr
, plot.nplr
, nplrAccessors
# Using the PC-3 data require(nplr) path <- system.file("extdata", "pc3.txt", package="nplr") pc3 <- read.delim(path) model <- nplr(x = pc3$CONC, y = pc3$GIPROP) getEstimates(model) getEstimates(model, c(.3, .6), conf.level = .9)
# Using the PC-3 data require(nplr) path <- system.file("extdata", "pc3.txt", package="nplr") pc3 <- read.delim(path) model <- nplr(x = pc3$CONC, y = pc3$GIPROP) getEstimates(model) getEstimates(model, c(.3, .6), conf.level = .9)
This function computes a weighted n-parameters logistic regression, given x (typically compound concentrations) and y values (responses: optic densities, fluorescence, cell counts,...). See Details
.
nplr(x, y, useLog = TRUE, LPweight = 0.25, npars = "all", method = c("res", "sdw", "gw"), silent = FALSE)
nplr(x, y, useLog = TRUE, LPweight = 0.25, npars = "all", method = c("res", "sdw", "gw"), silent = FALSE)
x |
a vector of numeric values, e.g., a vector of drug concentrations. |
y |
a vector of numeric values, e.g., a vector of responses, typically provided as proportions of control. |
useLog |
Logical. Should x-values be Log10-transformed? Default is |
LPweight |
a coefficient to adjust the weights. |
npars |
a numeric value (or |
method |
a character string to specify which weight method to use. Options are |
silent |
Logical. Specify whether |
The 5-parameter logistic regression is of the form:
where B
and T
are the bottom and top asymptotes, respectively, b
and xmid
are the Hill slope and the x-coordinate at the inflection point, respectively, and s
is an asymmetric coefficient. This equation is sometimes referred to as the Richards' equation [1,2].
When specifying npars = 4
, the s
parameter is forced to be 1
, and the corresponding model is a 4-parameter logistic regression, symmetrical around its inflection point. When specifying npars = 3
or npars = 2
, two more constraints are added, forcing B
and T
to be 0
and 1
, respectively.
Weight methods:
The model parameters are optimized, simultaneously, using nlm, given a sum of squared errors function, , to minimize:
where Yobs
, Yfit
, and W
are the vectors of observed values, fitted values, and weights, respectively.
In order to reduce the effect of possible outliers, the weights can be computed in different ways, specified in nplr
:
"res"
:
where residuals
and LPweight
are the squared error between the observed and fitted values, and a tuning parameter, respectively. Best results are generally obtained by setting (default value), while setting
results in computing a non-weighted sum of squared errors.
"sdw"
:
where Var(Yobs_r)
is the vector of the within-replicates variances.
"gw"
:
where Yfit
are the fitted values. As for the residuals-weights method, setting results in computing a non-weighted sum of squared errors.
The standard weights
and general weights
methods are described in [3].
An object of class nplr
.
the x values as they are used in the model. It can be Log10(x)
if useLog
was set to TRUE
.
the y values.
logical.
the best number of parameters if npars="all"
, or the specified number of parameters otherwise.
the weights tuning parameter.
the y fitted values.
the x values generated to draw the curve. 200 points between the min
and max
of x.
the fitted values used to draw the curve. These correspond to xCurve
.
the inflection point x and y coordinates.
the goodness-of-fit. The correlation between the fitted and the observed y values.
the mean squared error between the fitted and the observed y values.
the model parameters.
the area under the curve estimated using both the trapezoid method and Simpson's rule.
The data used in the examples are samples from the NCI-60 Growth Inhibition Data: https://wiki.nci.nih.gov/display/NCIDTPdata/NCI-60+Growth+Inhibition+Data, except for multicell.tsv which are simulated data.
Frederic Commo, Brian M. Bot
1- Richards, F. J. (1959). A flexible growth function for empirical use. J Exp Bot 10, 290-300.
2- Giraldo J, Vivas NM, Vila E, Badia A. Assessing the (a)symmetry of concentration-effect curves: empirical versus mechanistic models. Pharmacol Ther. 2002 Jul;95(1):21-45.
3- Motulsky HJ, Brown RE. Detecting outliers when fitting data with nonlinear regression - a new method based on robust nonlinear regression and the false discovery rate. BMC Bioinformatics. 2006 Mar 9;7:123.
convertToProp
, getEstimates
, plot.nplr
, nplrAccessors
# Using the PC-3 data require(nplr) path <- system.file("extdata", "pc3.txt", package = "nplr") pc3 <- read.delim(path) model <- nplr(x = pc3$CONC, y = pc3$GIPROP) plot(model)
# Using the PC-3 data require(nplr) path <- system.file("extdata", "pc3.txt", package = "nplr") pc3 <- read.delim(path) model <- nplr(x = pc3$CONC, y = pc3$GIPROP) plot(model)
nplr
accessor functions Methods for extracting information from an object of class nplr
. Each of the below methods are simply convenience functions which extract the corresponding slots (as the name of each method suggests) from the object of class nplr
.
signature(object = "nplr")
getX(object)
getY(object)
getXcurve(object)
getYcurve(object)
getFitValues(object)
getInflexion(object)
getPar(object)
getAUC(object)
getGoodness(object)
getStdErr(object)
getWeights(object)
nplr
Objects
To superimpose multiple logistic models fitted using nplr
.
overlay(modelList = NULL, showLegend = TRUE, Cols = NULL, ...)
overlay(modelList = NULL, showLegend = TRUE, Cols = NULL, ...)
modelList |
: list. A list of objects of class |
showLegend |
: logical. Whether the legend has to be displayed. |
Cols |
: character. A vector of colors to use. If |
... |
: Other graphical parameters. See |
None
None
None
path <- system.file("extdata", "multicell.tsv", package="nplr") multicell <- read.delim(path) # Computing models (to store in a list) cellsList <- split(multicell, multicell$cell) Models <- lapply(cellsList, function(tmp){ nplr(tmp$conc, tmp$resp, silent = TRUE) }) # Visualizing overlay(Models, xlab = expression(Log[10](Conc.)), ylab = "Resp.", main="Superimposing multiple curves", cex.main=1.5)
path <- system.file("extdata", "multicell.tsv", package="nplr") multicell <- read.delim(path) # Computing models (to store in a list) cellsList <- split(multicell, multicell$cell) Models <- lapply(cellsList, function(tmp){ nplr(tmp$conc, tmp$resp, silent = TRUE) }) # Visualizing overlay(Models, xlab = expression(Log[10](Conc.)), ylab = "Resp.", main="Superimposing multiple curves", cex.main=1.5)
nplr
Objects
This function allows visualizing logistic models fitted using nplr
.
## S3 method for class 'nplr' plot(x, pcol = "aquamarine1", lcol = "red3", showEstim = FALSE, showCI = TRUE, showGOF = TRUE, showInfl = FALSE, showPoints = TRUE, showSDerr = FALSE, B = 1e4, conf.level = .95, unit = "", ...)
## S3 method for class 'nplr' plot(x, pcol = "aquamarine1", lcol = "red3", showEstim = FALSE, showCI = TRUE, showGOF = TRUE, showInfl = FALSE, showPoints = TRUE, showSDerr = FALSE, B = 1e4, conf.level = .95, unit = "", ...)
x |
: an object of class |
pcol |
: the points color. |
lcol |
: the line color. |
showEstim |
: logical/numeric. If a numerical value is passed (a y value to reach), the estimated x value , and interval, is displayed on the plot. Default is |
showCI |
: logical. show the estimated confidence interval |
showGOF |
: logical. show the estimated goodness-of-fit. |
showInfl |
: logical. add the inflexion point on the plot. |
showPoints |
: logical. add the points on the plot. |
showSDerr |
: logical. add the standard errors on the plot (maybe useful in case of experiment with replicates). |
B |
: the length of simulated y values. Used to estimate the confidence interval |
conf.level |
: the confidence level. See |
unit |
: the unit to specify when |
... |
: other graphical parameters. See |
None
The data used in the examples are samples from the NCI-60 Growth Inhibition Data:
https://wiki.nci.nih.gov/display/NCIDTPdata/NCI-60+Growth+Inhibition+Data,
except for multicell.tsv which are simulated data.
None
None
# Using the PC-3 data require(nplr) path <- system.file("extdata", "pc3.txt", package = "nplr") pc3 <- read.delim(path) model <- nplr(x = pc3$CONC, y = pc3$GIPROP) plot(model, showEstim = 0.5, unit = "nM")
# Using the PC-3 data require(nplr) path <- system.file("extdata", "pc3.txt", package = "nplr") pc3 <- read.delim(path) model <- nplr(x = pc3$CONC, y = pc3$GIPROP) plot(model, showEstim = 0.5, unit = "nM")
nplr
Objects
A S3 method to visualize a model summary as a table.
## S3 method for class 'nplr' summary(object, ...)
## S3 method for class 'nplr' summary(object, ...)
object |
: an object of class |
... |
: other optional parameters (not used). |
None
The data used in the examples are samples from the NCI-60 Growth Inhibition Data:
https://wiki.nci.nih.gov/display/NCIDTPdata/NCI-60+Growth+Inhibition+Data,
except for multicell.tsv which are simulated data.
None
None
# Using the PC-3 data require(nplr) path <- system.file("extdata", "pc3.txt", package = "nplr") pc3 <- read.delim(path) model <- nplr(x = pc3$CONC, y = pc3$GIPROP) summary(model)
# Using the PC-3 data require(nplr) path <- system.file("extdata", "pc3.txt", package = "nplr") pc3 <- read.delim(path) model <- nplr(x = pc3$CONC, y = pc3$GIPROP) summary(model)