Data and fitting#
- class bindcurve.DoseResponseData(table)[source]#
Long-form dose-response observations, one row per measured response.
- Parameters:
table (pandas.DataFrame) – Columns
compound_id,concentrationandresponseare required.experiment_ididentifies independent experiments and defaults to a single experiment. Other columns are kept.
Notes
Concentrations must be finite and positive and share one unit. Rows with the same compound, experiment and concentration are technical replicates.
- classmethod from_wide(table, *, prefix='response_')[source]#
Create data from one row per concentration with replicate columns.
- Parameters:
- Return type:
- classmethod from_csv(path, *, format='long', prefix='response_', **read_csv_kwargs)[source]#
Read a long or wide CSV file.
- Parameters:
format (Literal['long', 'wide']) –
"long"for one row per response, as inDoseResponseData, or"wide"for one row per concentration, as infrom_wide.prefix (str) – Start of the names of the replicate response columns of wide files.
**read_csv_kwargs (object) – Passed to
pandas.read_csv, e.g.sep=";".
- Return type:
- bindcurve.fit(data, model, *, fixed=None, bounds=None, errors='raise')[source]#
Fit a model separately to every experiment of every compound.
Technical replicates are averaged per concentration, each mean is weighted by its replicate count, and standard errors are scaled by the residual scatter.
- Parameters:
data (DoseResponseData) – Observations to fit.
model (str | Model) – A built-in model name such as
"ic50"(seeget_model) or a model.fixed (Mapping[str, float] | None) – Values held fixed in every fit. Assay constants of binding models, such as
RT,LsTandKds, must be given here.bounds (Mapping[str, tuple[float | None, float | None]] | None) –
{name: (lower, upper)}limits of fitted parameters;Noneleaves a side unbounded.errors (Literal['raise', 'collect']) – Re-raise errors, or record them as failed fits and continue.
- Returns:
One fit per compound and experiment.
- Return type:
- Raises:
KeyError – If
fixedorboundsname a parameter the model does not have.ValueError – If an assay constant is missing, or a fixed value or bound is invalid.
- Warns:
UserWarning – If converged fits carry quality warnings, see
FitResult.warnings.
- class bindcurve.FitResults(model, data, fixed, fits)[source]#
Experiment-level fits of one model to a dataset.
Returned by
fit.- model#
The fitted model.
- data#
The fitted observations.
- fits#
One result per compound and experiment, including failed fits.
- Type:
- experiments()[source]#
One row per experiment-level fit with estimates and diagnostics.
Columns are
compound_id,experiment_id,success,message,warnings,n_data,rssandr_squared(seeFitResult), then each fitted parameter and its standard error (Kd,Kd_stderr, …).- Return type:
- summary()[source]#
One row per compound summarizing successful fits across experiments.
Each independent experiment contributes one value per parameter.
N_fit,N_failedandN_flaggedcount the successful, failed and flagged (successful but with warnings) fits.Concentration parameters are summarized on the log10 scale. For
IC50, the columns areIC50(geometric mean),logIC50,logIC50_SD,logIC50_SEM, andIC50_CI95_lowerandIC50_CI95_upper(Student-t 95% confidence interval, back-transformed).Other parameters get the arithmetic mean and the same statistics on the linear scale, e.g.
hill_slope,hill_slope_SD,hill_slope_SEM,hill_slope_CI95_lowerandhill_slope_CI95_upper.SD, SEM and the interval are NaN for a compound with fewer than two successful fits.
- Return type:
- parameters(compound_id)[source]#
Summary parameter values of one compound, ready for
Model.evaluate.Fitted parameters take their
summarycenters (geometric means for concentrations); fixed parameters keep their fixed values.
- report(parameter=None, *, uncertainty='sd', log=False, digits=2, unit=None)[source]#
Format one concentration parameter per compound for publication.
- Parameters:
parameter (str | None) – Concentration parameter to report. Defaults to the only fitted concentration parameter.
uncertainty (Literal['sd', 'sem', 'ci95']) – Spread across independent experiments:
"sd","sem"or"ci95". On the linear scale, every choice is shown as a back-transformed range, e.g.10**(mean ± SD)for"sd".log (bool) – Report log10 values, e.g.
-6.12 ± 0.15, instead of linear ones.digits (int) – Significant figures for linear values, decimals for log values.
unit (str | None) – Unit appended to linear values.
- Returns:
Columns
compound_id,report(the formatted text),N_fit,N_failedandN_flagged.- Return type:
- class bindcurve.FitResult(compound_id, experiment_id, model, success, message='', values=<factory>, stderr=<factory>, free=(), covariance=None, n_data=None, rss=None, r_squared=None, warnings=())[source]#
Fit of one model to one experiment of one compound.
Created by
fitand stored inFitResults.fits.- model#
The fitted model.
- stderr#
Standard errors of the fitted parameters, when they could be estimated.
- covariance#
Covariance matrix of the fitted parameters, scaled by the residual variance; None when it could not be estimated.
- Type:
numpy.ndarray | None