Models#

Built-in models are retrieved by name with get_model(); Models in the user guide lists them. A custom model subclasses Model, or BindingModel when it computes equilibrium species.

bindcurve.get_model(name)[source]#

Return a built-in model by name.

Parameters:

name (str) – One of "ic50", "dir_simple", "dir_specific", "dir_total", "comp_3st_specific", "comp_3st_total", "comp_4st_specific" or "comp_4st_total". The models and their required assay constants are listed in Models.

Raises:

KeyError – If there is no model of that name.

Return type:

Model

class bindcurve.Model[source]#

Dose-response model mapping a fraction in [0, 1] onto two plateaus.

The response is ymin + (ymax - ymin) * fraction(x).

name#

Name of the model, as used by get_model.

Type:

str

parameters#

All parameters, including ymin and ymax.

Type:

tuple[bindcurve.models.base.Parameter, …]

Notes

A custom model sets name and parameters and implements _fraction(self, x, **params), which receives the concentrations as an array and every parameter as a keyword argument, already validated against its Parameter limits, and returns the fraction at each concentration. Fitted parameters other than the plateaus and concentrations also need a starting value from an extended guess. The model can then be passed to fit in place of a name.

evaluate(x, **params)[source]#

Evaluate the response at concentrations x.

Parameters:
  • x (ndarray) – Concentrations on the linear (not log) scale, x >= 0.

  • **params (float) – A value for every parameter of the model, by name.

Raises:
  • TypeError – If parameters are missing or unknown.

  • ValueError – If a concentration or parameter value is invalid.

Return type:

ndarray

guess(x, y)[source]#

Initial values for fitting replicate means y at concentrations x.

The plateaus come from the response range and every fitted concentration parameter from the concentration closest to the half response. Subclasses with other fitted parameters extend the result.

Parameters:
  • x (ndarray) – Concentrations of one experiment.

  • y (ndarray) – Replicate mean response at each concentration.

Return type:

dict[str, float]

parameter(name)[source]#

Return the parameter called name.

Parameters:

name (str) – Parameter name, e.g. "Kd".

Raises:

KeyError – If the model has no such parameter.

Return type:

Parameter

class bindcurve.BindingModel[source]#

Equilibrium-binding model whose fraction is the tracer-bound fraction.

Notes

A custom binding model implements _species(self, x, **params) in place of _fraction. It returns a dict of arrays that includes the bound fraction "Fbs".

species(x, **params)[source]#

Return the equilibrium concentrations of all species.

Parameters:
  • x (ndarray) – Concentrations of the titrated component, as in Model.evaluate.

  • **params (float) – A value for every parameter of the model, by name.

Returns:

Arrays shaped like x, in the unit of the concentrations:

  • R: free receptor

  • Ls: free tracer

  • RLs: tracer-receptor complex

  • L: free competitor (competitive models)

  • RL: competitor-receptor complex (competitive models)

  • RLLs: ternary complex (four-state models)

  • Ls_nonspecific: nonspecifically bound tracer (dir_total)

  • L_nonspecific: nonspecifically bound competitor (comp_*_total)

  • Fbs: fraction of tracer bound to receptor (dimensionless)

dir_simple returns only R and Fbs.

Return type:

dict[str, numpy.ndarray]

class bindcurve.Parameter(name, concentration=False, fixed=False, min=-inf, max=inf)[source]#

One model parameter.

Parameters:
  • name (str) – Keyword used in Model.evaluate and in the fixed and bounds arguments of fit.

  • concentration (bool) – Whether this is a positive, concentration-like parameter. Such parameters are optimized on a log10 coordinate and summarized across experiments on the log10 scale.

  • fixed (bool) – Whether this is an assay constant that must be given in fit(..., fixed=...).

  • min (float) – Physical limits of the parameter value.

  • max (float) – Physical limits of the parameter value.