Potency#
Benchmark doses of fitted dose-response curves, with their bounds and the checks of BMDS, NTP 2018, EPA’s ETAP 2024 and EFSA 2022, and the EC50s, Hill slopes and plateaus of their Hill curves, with the EC50s’ intervals; Potency and points of departure explains them, and NTP’s and ETAP’s rule sets the documents’ choices of model.
Benchmark doses of fitted dose-response curves, with profile-likelihood bounds.
A fitted curve says what shape a response takes, not at which dose the response
reaches a given size. Regulators read that dose as a benchmark dose (BMD): the dose at
which the curve’s change from its level at dose 0 reaches a stated benchmark response
(BMR), with a lower bound (BMDL) and an upper bound (BMDU) (Crump 1984; US EPA 2012).
benchmark_doses() computes them for every gene of a
DoseCurveFits, at one or several
BenchmarkResponse values, and BenchmarkDoses holds them with
the statistics that the checks of regulatory guidance read: those of BMDS, NTP 2018,
EPA’s ETAP 2024 and EFSA 2022. The definitions, the bounds and the checks are in
https://docs.nygen.io/CytePool/statistics/potency#benchmark-doses.
- The BMD:
The lowest dose x above 0 at which |f(x) - f(0)| = R, R the BMR’s size, searched from a hundredth of the lowest positive dose (DRomics’
minBMD) to 50 times the top dose. A crossing below the search’s lowest dose is given as that dose, as DRomics gives it; a crossing above the top dose is given, as BMDS gives it.- The bounds:
The BMDL and BMDU are the lowest and highest doses b whose profile log-likelihood, the largest log-likelihood of a curve whose change at b is R in the BMD’s direction, lies within half the chi-square(1) quantile at 0.90 of the maximum: one-sided 95% bounds each, given the gene’s chosen model, and BMDL to BMDU a two-sided 90% interval (US EPA 2012 Sec. 2.3.8). Where the BMR is a multiple of the SD, the SD moves with the curve in the profile, as BMDS profiles it. Where the curves weigh dose-group means with a first-stage variance s^2 on df degrees of freedom, an absolute BMR’s bounds read the increase of the weighted sum of squares over s^2 against F(1, df) at 0.90, which is Fieller’s (1954) exact bound for a straight line; an SD-based BMR’s profile adds the likelihood of s^2 and reads chi-square(1).
- EC50s, Hill slopes and plateaus:
ec50s()reads each gene’s Hill curve, the log-logistic curve of the sets"ll4"and"dromics"or the Hill model of"epa"and"bmdexpress", as pharmacologists read it (Neubig et al. 2003): the EC50, the dose of half the curve’s change from its level at dose 0 to its plateau at high doses (Sebaugh 2011’s relative EC50); the Hill slope, in GraphPad Prism’s sign, positive for a rise; and the two plateaus. The EC50’s two-sided 95% interval holds the EC50s whose profile, the curve’s fit with the EC50 held there, lies within an F quantile at 0.95 of the maximum: F(1, n - 4) on the curve’s residual variance under constant variance, Prism’s extra-sum-of-squares F test, searched as Venzon and Moolgavkar (1988) describe, or F(1, df) on the variance of a moderated fit. An EC50 is reportable with two tested doses beyond each bend of the curve (Sebaugh 2011), where the curve has covered 17.6% and 82.4% of its change: at EC50 / 4.6805^(1/|h|) and EC50 x 4.6805^(1/|h|), h the Hill slope (Sebaugh and McCray 2003, as Micheli et al. 2021 give the constant). https://docs.nygen.io/CytePool/statistics/potency#ec50s explains them.
References
Crump KS (1984). A new method for determining allowable daily intakes. Fundamental and Applied Toxicology 4, 854-871. doi:10.1016/0272-0590(84)90107-6
US EPA (2012). Benchmark Dose Technical Guidance. EPA/100/R-12/001, Risk Assessment Forum, US Environmental Protection Agency, Washington, DC.
Fieller EC (1954). Some problems in interval estimation. Journal of the Royal Statistical Society, Series B 16, 175-185. doi:10.1111/j.2517-6161.1954.tb00159.x
Neubig RR, Spedding M, Kenakin T, Christopoulos A (2003). International Union of Pharmacology Committee on Receptor Nomenclature and Drug Classification. XXXVIII. Update on terms and symbols in quantitative pharmacology. Pharmacological Reviews 55, 597-606. doi:10.1124/pr.55.4.4
Sebaugh JL (2011). Guidelines for accurate EC50/IC50 estimation. Pharmaceutical Statistics 10, 128-134. doi:10.1002/pst.426
Sebaugh JL, McCray PD (2003). Defining the linear portion of a sigmoid-shaped curve: bend points. Pharmaceutical Statistics 2, 167-174. doi:10.1002/pst.62
Micheli P, Ribeiro R, Giorgetti A (2021). A mechanistic model of NMDA and AMPA receptor-mediated synaptic transmission in individual hippocampal CA3-CA1 synapses: a computational multiscale approach. International Journal of Molecular Sciences 22, 1536. doi:10.3390/ijms22041536
Venzon DJ, Moolgavkar SH (1988). A method for computing profile-likelihood-based confidence intervals. Applied Statistics 37, 87-94. doi:10.2307/2347496
- class cytepool.stats.potency.BenchmarkDoses(benchmark_responses, model_set, model, gene_models, variance, bounds, lowest_dose, top_dose, bmr_change, bmd, bmdl, bmdu, direction, status, threshold, fit_p_value, scaled_residual_near_bmd, scaled_residual_at_vehicle, vehicle_sd_ratio, constant_variance_p_value, model_choice, feature_ids=None)#
The benchmark doses of every gene’s curve, with their bounds and the statistics that the checks of BMDS, NTP 2018, EPA’s ETAP 2024 and EFSA 2022 read.
Rows of the arrays of shape
(n_bmrs, n_genes)are the BMRs, in the order ofbenchmark_responses; columns are genes, in the fits’ order. The arrays are read-only. https://docs.nygen.io/CytePool/statistics/potency#benchmark-doses defines each quantity and how to read it.- Variables:
benchmark_responses – The BMRs, as given, then the 1 SD comparison that US EPA 2012 asks to present beside any other BMR, unless given.
model_set – The set of the curves:
"epa","bmdexpress","ll4"or"dromics".model –
"best", each gene’s model of lowest AICc; a document’s choice,"ntp_2018","etap_2024"or"bmds_2026"; or the name of the model every gene’s BMD was computed from.gene_models –
(n_genes,)the model of each gene’s BMD, empty where none; themodelsofDoseCurveFitsname the models fitted.variance – How the curves weighed the dose-group means:
"constant","weighted"or"moderated".bounds – Whether bounds were computed; a cell type that supports only description gets none.
lowest_dose – The lowest positive dose of the fits.
top_dose – The highest dose of the fits.
bmr_change – The BMR’s size R in the values’ units, such as log2 units for an SD-based BMR.
bmd – The BMD; NaN where not reached, without a curve or with the BMR undefined (
status).bmdl – The lower bound, the lowest dose of the likelihood’s region, or under NTP’s and ETAP’s choices of the piece of it that holds the BMD, as BMDS 2 bounds a BMD; 0 where that reaches the search’s lowest dose; NaN without bounds, without a BMD, where the values have no spread about the curve, or, for every BMR of the gene, where the profile found a likelihood above the fit’s, at a BMD or at a dose of the search, so that the fit was not its maximum.
bmdu – The upper bound, the highest dose of the same region or piece; infinity where that reaches the search’s highest dose; NaN as for
bmdl.direction –
"up"or"down", the direction of the change at the BMD; empty without a BMD.status – Where the BMD lies:
"within the doses","below the lowest dose","below a hundredth of the lowest dose"(the BMD is given as that dose),"above the top dose","not reached"(no crossing up to 50 times the top dose),"no curve"(no model to read: none fitted, or none with a finite AICc),"no model chosen"(a document’s choice found no model whose BMD it keeps) or"BMR undefined"(an SD of 0, values without spread about the curve, or no vehicle to scale the SD to).threshold – The deviance the bounds read: chi-square(1) at 0.90, or F(1, df) at 0.90 for an absolute BMR whose curves weigh a first stage’s variance; NaN without bounds.
fit_p_value –
(n_genes,)the p-value of BMDS’s test 4, the likelihood ratio test of each gene’s model against a mean per dose group, (df + K) log(1 + (K - p) F / df) on a chi-square of K - p degrees of freedom, F the curves’ F-test of lack of fit. Outside a document’s choice every parameter counts in p, as in the curves’ AIC, so that where a parameter is at a bound the p-value differs from the fit p-value of BMDS 2 and pybmds, which leave such parameters out; under a document’s choice, p counts the mean parameters as that document’s program does: those not at a bound of BMDS 2’s programs for NTP and ETAP, those pybmds does not flag as bounded for BMDS. NaN without replicates.scaled_residual_near_bmd – The scaled residual of the dose group nearest the BMD on the dose scale, the lower dose on a tie (BMDS’s residual of interest).
scaled_residual_at_vehicle –
(n_genes,)the scaled residual of the vehicle group.vehicle_sd_ratio –
(n_genes,)under constant variance, the curve’s SD over the vehicle replicates’ sample SD (at least 1e-6), BMDS’s check of the modelled SD; NaN otherwise.constant_variance_p_value –
(n_genes,)under constant variance, the likelihood ratio test of one variance against a variance per dose group (BMDS’s test 2), on K - 1 degrees of freedom; NaN otherwise, and where a group has fewer than two samples or no spread.model_choice –
(n_genes,)under a document’s choice, why each gene’s model was chosen, such as"lowest AIC"; empty otherwise.feature_ids –
(n_genes,)the genes’ ids thattable()writes, fromDoseResponseResult.benchmark_doses; None frombenchmark_doses(), whose table numbers the genes.
Explained in: Potency and points of departure
- accepted(flag_set)#
Whether each BMD passes a document’s acceptance: a BMD whose fit p-value is a number and that fails none of the document’s checks but those it keeps aside, such as NTP’s flag of a BMD more than 10-fold below the lowest dose (https://docs.nygen.io/CytePool/statistics/potency#rule-sets). The checks skip what a row lacks, and acceptance asks for all a criterion reads.
- Parameters:
flag_set –
"ntp_2018"or"etap_2024"; BMDS’s bins and EFSA’s indicators accept no gene and are refused.- Returns:
(n_bmrs, n_genes), rows the BMRs in order.- Raises:
ValueError – If
flag_setis not"ntp_2018"or"etap_2024", or the BMDs have no bounds, which both documents’ criteria read.TypeError – If
flag_setis not text.
Explained in: Potency and points of departure
- table(*, feature_ids=None, flags=None)#
Return the benchmark doses as a table, one row per BMR and gene.
The BMRs in order, each with every gene in order:
feature_id,bmr(the BMR’s label),model, under a document’s choicemodel_choiceandfit_p_value, thendirection,bmr_change,bmd,bmdl,bmdu,bmd_status, thenflags_<set>for each set offlags: the checks the row fails, joined by “; “, empty when none (https://docs.nygen.io/CytePool/statistics/potency#benchmark-dose-flags).- Parameters:
feature_ids – One id per gene, as text; by default the result’s
feature_ids, orfeature_0,feature_1, … without them.flags – The checks of BMDS, NTP, ETAP or EFSA, as a set’s name or a list of names:
"bmds_2026","ntp_2018","etap_2024"or"efsa_2022"; None for none.
- Raises:
ValueError – If
feature_idsdoes not give one id per gene, or a set is unknown or repeated.TypeError – If an id or a set is not text, or
feature_idsis a numpy masked array.
Explained in: Potency and points of departure
- class cytepool.stats.potency.EC50s(model_set, model, variance, intervals, lowest_dose, top_dose, ec50, ec50_lower, ec50_upper, hill_slope, bottom_plateau, top_plateau, status, two_doses_beyond_each_bend, best_model, parameters_at_bounds, threshold, feature_ids=None)#
The EC50, Hill slope and plateaus of every gene’s Hill curve, with the EC50’s profile-likelihood interval.
Arrays have one entry per gene, in the fits’ order, and are read-only. https://docs.nygen.io/CytePool/statistics/potency#ec50s defines each number and how to read it.
- Variables:
model_set – The set of the curves:
"ll4","dromics","epa"or"bmdexpress".model – The Hill curve whose EC50s are read:
"ll4", or"hill"for"epa"and"bmdexpress".variance – How the curves weighed the dose-group means:
"constant","weighted"or"moderated".intervals – Whether intervals were computed; a cell type that supports only description gets none.
lowest_dose – The lowest positive dose of the fits.
top_dose – The highest dose of the fits.
ec50 – The dose of half the curve’s change from its level at dose 0 to its plateau at high doses, in the doses’ unit; NaN without a curve. Its log10 is GraphPad Prism’s LogEC50; drc’s
ED()prints the EC50 itself.ec50_lower – The interval’s lower end: 0 where the region of the profile likelihood reaches the lowest EC50 a curve can have, a hundredth of the lowest positive dose for the log-logistic curve and 0 for the Hill model; NaN without an interval.
ec50_upper – The interval’s upper end: infinity where the region reaches the highest, 5 times the top dose, or 1,000 times in
"bmdexpress"; NaN without an interval.hill_slope – The curve’s steepness as GraphPad Prism writes it, positive for a rise and negative for a fall: b of the log-logistic curve or n of the Hill model, with that sign. NaN where the curve’s two levels are equal, and at an EC50 of 0, where the slope no longer changes the curve at positive doses. The slope of a nearly flat curve, such as a gene’s that does not respond, is as arbitrary as its EC50.
bottom_plateau – The lower of the curve’s two levels, GraphPad’s Bottom, in the values’ units, such as log2 for expression.
top_plateau – The higher, GraphPad’s Top. The plateau at high doses, the top plateau of a rise and the bottom plateau of a fall, is an extrapolation when the EC50 lies above the top dose: with the EC50 at 5 times the top dose and the slope at 18, it lies up to about 4 x 10^12 times the change at the top dose away, and further in
"bmdexpress", whose EC50 can reach 1,000 times the top dose.status – Where the EC50 lies:
"within the doses", from the lowest positive dose to the top dose,"below the lowest dose","above the top dose", or"no curve"where the Hill curve was not fitted to the gene.two_doses_beyond_each_bend – Whether two positive doses or more lie strictly below the curve’s lower bend and two or more strictly above its upper bend, Sebaugh’s (2011) condition for reporting an EC50; the bends are where the curve has covered 17.6% and 82.4% of its change, and the vehicle is not counted. False without a slope.
best_model – Whether the Hill curve is the gene’s best model by AICc; always True with
"ll4", a set of one model.parameters_at_bounds –
"ec50","hill_slope"or both, comma-separated, where the fit sits at a bound of the parameter, or within 0.01% of it, whose value is then a limit, not an estimate: slopes of 0.1 and 18 for the log-logistic curve and 1 and 18 for the Hill model, and EC50s at the ends of the interval’s range; empty for none.threshold – The F quantile at 0.95 that each interval read: F(1, n - 4) under constant variance, F(1, df) otherwise; NaN where no interval was computed.
feature_ids –
(n_genes,)the genes’ ids thattable()writes, fromDoseResponseResult.ec50s; None fromec50s(), whose table numbers the genes.
Explained in: Potency and points of departure
- table(*, feature_ids=None)#
Return the EC50s as a table, one row per gene in the fits’ order.
Columns:
feature_id,best_model,ec50,ec50_lower,ec50_upper,hill_slope,bottom_plateau,top_plateau,ec50_status,two_doses_beyond_each_bendandparameters_at_bounds.- Parameters:
feature_ids – One id per gene, as text; by default the result’s
feature_ids, orfeature_0,feature_1, … without them.- Raises:
ValueError – If
feature_idsdoes not give one id per gene.TypeError – If an id is not text, or
feature_idsis a numpy masked array.
Explained in: Potency and points of departure
- cytepool.stats.potency.benchmark_doses(fits, bmr, *, model=BEST, bounds=True, n_threads=None)#
Compute the benchmark dose of every gene’s curve, with its bounds.
The BMD is the lowest dose at which the curve’s change from its level at dose 0 reaches the BMR, and the BMDL and BMDU are one-sided 95% bounds by profile likelihood, given each gene’s chosen model, so that BMDL to BMDU is a two-sided 90% interval (Crump 1984; US EPA 2012); the bounds do not carry the uncertainty of the model’s choice (https://docs.nygen.io/CytePool/statistics/potency#potency-limits). The 1 SD BMD, which US EPA 2012 asks to present beside any other BMR, is added unless given. Results do not depend on the number of threads. https://docs.nygen.io/CytePool/statistics/potency#benchmark-doses defines the BMD, its bounds and where each lies.
- Parameters:
fits – Curves of named models, from
fit_dose_curves()orDoseResponseResult.curve_fits.bmr – A
BenchmarkResponse, or a list of them with distinct labels.model –
"best"(default), each gene’s model of lowest AICc; the name of a model of the fits’ set, for every gene it was fitted to; or a document’s choice:"ntp_2018"or"etap_2024"on the set"bmdexpress", the lowest AIC as BMDS 2 counts it among the models whose BMD has both bounds, ETAP’s leaving out a Hill fit whose k is below a third of the lowest dose;"bmds_2026"on the set"epa", BMDS’s recommended model as pybmds 25.2 chooses it among linear, polynomial 2, power, Hill, exponential 3 and 5, whichdose_responsemakes withselection="bmds_2026", and withrulesthe documents’ choices. Under NTP’s and ETAP’s choices the bounds end at the piece of the likelihood’s region that holds the BMD, as BMDS 2’s do. A document’s choice reads the first BMR, keeps that model for the other BMRs, needs constant variance and bounds, and computes the bounds of the models it passes over, so it costs more.bounds – False gives BMDs without bounds, as for curves of dose groups without replicates.
n_threads – The most threads to use; None keeps numba’s setting.
- Returns:
The BMDs, with their bounds and the statistics the checks of regulatory guidance read. Its
table(flags=...)lists the checks of BMDS, NTP, ETAP or EFSA that each BMD fails.- Raises:
TypeError – If
fitsis not aDoseCurveFits,bmrnot aBenchmarkResponseor a list of them,modelnot a str orboundsnot True or False.ValueError – If
bmris empty or repeats a label,modelnames no model of the set or one not fitted, or a document’s choice for fits of another set, of variance other than constant or without bounds, or bounds are asked for curves without replicates.
Explained in: Choosing a method, Potency and points of departure
- cytepool.stats.potency.ec50s(fits, *, intervals=True, n_threads=None)#
Read every gene’s Hill curve as an EC50, Hill slope and plateaus, with the EC50’s two-sided 95% profile-likelihood interval.
The Hill curve is the set’s: the log-logistic curve of
"ll4"and"dromics", or the Hill model of"epa"and"bmdexpress", for every gene it was fitted to, whether or not it is the gene’s best model (best_modelsays). The EC50 is the dose of half the curve’s change from its level at dose 0 to its plateau at high doses (Sebaugh 2011’s relative EC50), the Hill slope its steepness in GraphPad Prism’s sign, positive for a rise and negative for a fall, and the plateaus its two levels, in the values’ units. The interval holds the EC50s whose profile, the curve’s fit with the EC50 held there, lies within the F quantile at 0.95 of the maximum: under constant variance F(1, n - 4) on the curve’s residual variance, as Prism’s extra-sum-of-squares F test reads it; with the variance of a moderated fit, F(1, df) on it. Its ends are the region’s lowest and highest EC50 over the fit’s range of EC50s, open (0 or infinity) where the region reaches the range’s ends. Two positive doses beyond each bend of the curve, where it has covered 17.6% and 82.4% of its change, make an EC50 reportable (Sebaugh 2011). The intervals take about 5 ms of computing per gene, shared among the threads: 23 s for 10,000 genes on 2 threads in the benchmark; they do not depend on the threads. They need replicates within dose groups: the variance then comes from the replicates as well as from the curve’s residuals, where Prism, given one value per dose, reads the residuals alone. https://docs.nygen.io/CytePool/statistics/potency#ec50s explains each number and https://docs.nygen.io/CytePool/statistics/potency#ec50-intervals the interval.- Parameters:
fits – Curves of a set of named models, from
fit_dose_curves()orDoseResponseResult.curve_fits.intervals – False gives EC50s without intervals, as for curves of dose groups without replicates.
n_threads – The most threads to use; None keeps numba’s setting.
- Returns:
The EC50s, Hill slopes and plateaus, with the intervals and where each EC50 lies.
- Raises:
TypeError – If
fitsis not aDoseCurveFits,intervalsnot True or False, orn_threadsnot an integer or None.ValueError – If the set’s Hill curve was not fitted, as at 4 dose groups, intervals are asked for curves without replicates, or
n_threadsis below 1.
Example
>>> import numpy as np >>> from cytepool.stats.dose_curves import fit_dose_curves >>> doses = np.repeat([0.0, 0.01, 0.03, 0.1, 0.3, 1.0, 3.0, 10.0, 30.0], 3) >>> mean = 6.0 + 2.0 / (1.0 + (0.3 / np.maximum(doses, 1e-12)) ** 1.5) >>> noise = np.tile([-0.2, 0.0, 0.2], 9) >>> fits = fit_dose_curves(doses, (mean + noise)[:, None], models="ll4") >>> found = ec50s(fits) >>> [round(float(found.ec50[0]), 3), round(float(found.hill_slope[0]), 2)] [0.3, 1.5] >>> [round(float(found.ec50_lower[0]), 3), round(float(found.ec50_upper[0]), 3)] [0.225, 0.403]
Explained in: Choosing a method, Potency and points of departure